fastapi-voyager 0.11.2__py3-none-any.whl → 0.11.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
fastapi_voyager/server.py CHANGED
@@ -41,6 +41,7 @@ def create_route(
41
41
  module_color: dict[str, str] | None = None,
42
42
  swagger_url: Optional[str] = None,
43
43
  module_prefix: Optional[str] = None,
44
+ online_repo_url: Optional[str] = None,
44
45
  ):
45
46
  """
46
47
  module_color: dict mapping module name to color string, e.g. {'models': 'lightblue'}
@@ -183,7 +184,7 @@ def create_route(
183
184
 
184
185
  mod = __import__(module_name, fromlist=[class_name])
185
186
  obj = getattr(mod, class_name)
186
- link = get_vscode_link(obj)
187
+ link = get_vscode_link(obj, online_repo_url=online_repo_url)
187
188
 
188
189
  return JSONResponse(content={"link": link})
189
190
  except ImportError as e:
@@ -211,8 +212,14 @@ def create_voyager(
211
212
  gzip_minimum_size: int | None = 500,
212
213
  module_prefix: Optional[str] = None,
213
214
  swagger_url: Optional[str] = None,
215
+ online_repo_url: Optional[str] = None,
214
216
  ) -> FastAPI:
215
- router = create_route(target_app, module_color=module_color, module_prefix=module_prefix, swagger_url=swagger_url)
217
+ router = create_route(
218
+ target_app,
219
+ module_color=module_color,
220
+ module_prefix=module_prefix,
221
+ swagger_url=swagger_url,
222
+ online_repo_url=online_repo_url)
216
223
 
217
224
  app = FastAPI(title="fastapi-voyager demo server")
218
225
  if gzip_minimum_size is not None and gzip_minimum_size >= 0:
@@ -1,7 +1,7 @@
1
1
  import inspect
2
2
  import os
3
3
  from pydantic import BaseModel
4
- from typing import get_origin, get_args, Union, Annotated, Any, Type, Generic
4
+ from typing import get_origin, get_args, Union, Annotated, Any, Type, Generic, Optional
5
5
  from fastapi_voyager.type import FieldInfo
6
6
  from types import UnionType
7
7
  import pydantic_resolve.constant as const
@@ -182,7 +182,7 @@ def get_pydantic_fields(schema: type[BaseModel], bases_fields: set[str]) -> list
182
182
  return fields
183
183
 
184
184
 
185
- def get_vscode_link(kls):
185
+ def get_vscode_link(kls, online_repo_url: Optional[str] = None) -> str:
186
186
  """Build a VSCode deep link to the class definition.
187
187
 
188
188
  Priority:
@@ -197,6 +197,10 @@ def get_vscode_link(kls):
197
197
  _lines, start_line = inspect.getsourcelines(kls)
198
198
 
199
199
  distro = os.environ.get("WSL_DISTRO_NAME")
200
+ if online_repo_url:
201
+ cwd = os.getcwd()
202
+ relative_path = os.path.relpath(source_file, cwd)
203
+ return f"{online_repo_url}/{relative_path}#L{start_line}"
200
204
  if distro:
201
205
  # Ensure absolute path (it should already be under /) and build remote link
202
206
  return f"vscode://vscode-remote/wsl+{distro}{source_file}:{start_line}"
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "0.11.2"
2
+ __version__ = "0.11.3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-voyager
3
- Version: 0.11.2
3
+ Version: 0.11.3
4
4
  Summary: Visualize FastAPI application's routing tree and dependencies
5
5
  Project-URL: Homepage, https://github.com/allmonday/fastapi-voyager
6
6
  Project-URL: Source, https://github.com/allmonday/fastapi-voyager
@@ -270,6 +270,8 @@ or you can open router_viz.dot with vscode extension `graphviz interactive previ
270
270
  - 0.11.2
271
271
  - [x] enable/disable module cluster (to save space)
272
272
  - 0.11.3
273
+ - [x] support online repo url
274
+ - 0.11.4
273
275
  - [ ] add loading for field detail panel
274
276
  - [ ] logging information
275
277
  - [ ] sort field name
@@ -3,10 +3,10 @@ fastapi_voyager/cli.py,sha256=kQb4g6JEGZR99e5r8LyFFEeb_-uT-n_gp_sDoYG3R7k,11118
3
3
  fastapi_voyager/filter.py,sha256=GY2J9Vfsf_wbFwC-0t74-Lf-OlO77PnhEXD_rmgkfSw,11574
4
4
  fastapi_voyager/module.py,sha256=Z2QHNmiLk6ZAJlm2nSmO875Q33TweSg8UxZSzIpU9zY,3499
5
5
  fastapi_voyager/render.py,sha256=vdwqIync2wsP8gMPY0v_XjRhdPBtbKyRT8yTBa_Ep3Y,8744
6
- fastapi_voyager/server.py,sha256=TOzGEyzE_lviWMcKuSYHDaoArMApENIfvzHdAzOuKY4,6679
6
+ fastapi_voyager/server.py,sha256=cRTUQik4rvrdZgfkFabCs6LBZnC1FVU4z3lwd1r8GNk,6839
7
7
  fastapi_voyager/type.py,sha256=VmcTB1G-LOT70EWCzi4LU_FUkSGWUIBJX15T_J5HnOo,1764
8
- fastapi_voyager/type_helper.py,sha256=hjBC4E0tgBpQDlYxGg74uK07SXjsrAgictEETJfIpYM,9231
9
- fastapi_voyager/version.py,sha256=0HoMD0zNdXsQi-ZwAZecr3qNO9tE7hFLleGl1vf67AA,49
8
+ fastapi_voyager/type_helper.py,sha256=QqP4c642vEkoWTZAtl_Vvt-kys3MkVDp4BNkLrw5mHQ,9477
9
+ fastapi_voyager/version.py,sha256=lbhVTyfJZpsKCnUAXtQjVxbGBg1jjoqiyaCQRf2W6hk,49
10
10
  fastapi_voyager/voyager.py,sha256=hNal25S5Hi_ZRe-gnmdUKt8tnRd-BRCrzaybAEJ_1HI,13498
11
11
  fastapi_voyager/web/graph-ui.js,sha256=DTedkpZNbtufexONVkJ8mOwF_-VnvxoReYHtox6IKR4,5842
12
12
  fastapi_voyager/web/graphviz.svg.css,sha256=zDCjjpT0Idufu5YOiZI76PL70-avP3vTyzGPh9M85Do,1563
@@ -26,8 +26,8 @@ fastapi_voyager/web/icon/favicon-16x16.png,sha256=JC07jEzfIYxBIoQn_FHXvyHuxESdhW
26
26
  fastapi_voyager/web/icon/favicon-32x32.png,sha256=C7v1h58cfWOsiLp9yOIZtlx-dLasBcq3NqpHVGRmpt4,1859
27
27
  fastapi_voyager/web/icon/favicon.ico,sha256=tZolYIXkkBcFiYl1A8ksaXN2VjGamzcSdes838dLvNc,15406
28
28
  fastapi_voyager/web/icon/site.webmanifest,sha256=ep4Hzh9zhmiZF2At3Fp1dQrYQuYF_3ZPZxc1KcGBvwQ,263
29
- fastapi_voyager-0.11.2.dist-info/METADATA,sha256=ImBnVBoy2rqVkdOrd037aIgj9V8pRc0cN7dl5aXv3dM,9917
30
- fastapi_voyager-0.11.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
- fastapi_voyager-0.11.2.dist-info/entry_points.txt,sha256=pEIKoUnIDXEtdMBq8EmXm70m16vELIu1VPz9-TBUFWM,53
32
- fastapi_voyager-0.11.2.dist-info/licenses/LICENSE,sha256=lNVRR3y_bFVoFKuK2JM8N4sFaj3m-7j29kvL3olFi5Y,1067
33
- fastapi_voyager-0.11.2.dist-info/RECORD,,
29
+ fastapi_voyager-0.11.3.dist-info/METADATA,sha256=2yD09_89vwgOEDQuiGN48d98XWowh8wTr4rnNNu7mVU,9960
30
+ fastapi_voyager-0.11.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
+ fastapi_voyager-0.11.3.dist-info/entry_points.txt,sha256=pEIKoUnIDXEtdMBq8EmXm70m16vELIu1VPz9-TBUFWM,53
32
+ fastapi_voyager-0.11.3.dist-info/licenses/LICENSE,sha256=lNVRR3y_bFVoFKuK2JM8N4sFaj3m-7j29kvL3olFi5Y,1067
33
+ fastapi_voyager-0.11.3.dist-info/RECORD,,