fastapi-voyager 0.7.1__py3-none-any.whl → 0.7.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/filter.py CHANGED
@@ -183,6 +183,13 @@ def filter_subgraph(
183
183
  if next_node not in visited:
184
184
  queue.append(next_node)
185
185
 
186
- filtered_links = tag_route_links + merged_links
186
+ module_prefix_links = [
187
+ lk
188
+ for lk in links
189
+ if (lk.source_origin or "").startswith(module_prefix)
190
+ and (lk.target_origin or "").startswith(module_prefix)
191
+ ]
192
+
193
+ filtered_links = tag_route_links + merged_links + module_prefix_links
187
194
 
188
195
  return tags, routes, filtered_nodes, filtered_links
fastapi_voyager/render.py CHANGED
@@ -1,3 +1,4 @@
1
+ from typing import Optional
1
2
  from fastapi_voyager.type import SchemaNode, ModuleNode, Link, Tag, Route, FieldType, PK, ModuleRoute
2
3
  from fastapi_voyager.module import build_module_schema_tree, build_module_route_tree
3
4
 
@@ -61,33 +62,44 @@ class Renderer:
61
62
  else:
62
63
  raise ValueError(f'Unknown link type: {link.type}')
63
64
 
64
- def render_module_schema(self, mod: ModuleNode) -> str:
65
- color = self.module_color.get(mod.fullname)
66
- inner_nodes = [
67
- f'''
68
- "{node.id}" [
69
- label = {self.render_schema_label(node)}
70
- shape = "plain"
71
- margin="0.5,0.1"
72
- ];''' for node in mod.schema_nodes
73
- ]
74
- inner_nodes_str = '\n'.join(inner_nodes)
75
- child_str = '\n'.join(self.render_module_schema(m) for m in mod.modules)
76
- return f'''
77
- subgraph cluster_module_{mod.fullname.replace('.', '_')} {{
78
- tooltip="{mod.fullname}"
79
- color = "#666"
80
- style="rounded"
81
- label = " {mod.name}"
82
- labeljust = "l"
83
- {(f'pencolor = "{color}"' if color else 'pencolor="#ccc"')}
84
- {(f'penwidth = 3' if color else 'penwidth=""')}
85
- {inner_nodes_str}
86
- {child_str}
87
- }}'''
65
+ def render_module_schema_wrapper(self, mods: list[ModuleNode]) -> str:
66
+ module_color_flag = set(self.module_color.keys())
67
+ print(module_color_flag)
68
+
69
+ def render_module_schema(mod: ModuleNode) -> str:
70
+ color: Optional[str] = None
71
+
72
+ for k in module_color_flag:
73
+ if mod.fullname.startswith(k):
74
+ module_color_flag.remove(k)
75
+ color = self.module_color[k]
76
+ break
77
+
78
+ inner_nodes = [
79
+ f'''
80
+ "{node.id}" [
81
+ label = {self.render_schema_label(node)}
82
+ shape = "plain"
83
+ margin="0.5,0.1"
84
+ ];''' for node in mod.schema_nodes
85
+ ]
86
+ inner_nodes_str = '\n'.join(inner_nodes)
87
+ child_str = '\n'.join(render_module_schema(m) for m in mod.modules)
88
+ return f'''
89
+ subgraph cluster_module_{mod.fullname.replace('.', '_')} {{
90
+ tooltip="{mod.fullname}"
91
+ color = "#666"
92
+ style="rounded"
93
+ label = " {mod.name}"
94
+ labeljust = "l"
95
+ {(f'pencolor = "{color}"' if color else 'pencolor="#ccc"')}
96
+ {(f'penwidth = 3' if color else 'penwidth=""')}
97
+ {inner_nodes_str}
98
+ {child_str}
99
+ }}'''
100
+ return '\n'.join(render_module_schema(m) for m in mods)
88
101
 
89
102
  def render_module_route(self, mod: ModuleRoute) -> str:
90
- color = self.module_color.get(mod.fullname)
91
103
  # Inner route nodes, same style as flat route_str
92
104
  inner_nodes = [
93
105
  f'''
@@ -106,8 +118,6 @@ class Renderer:
106
118
  style="rounded"
107
119
  label = " {mod.name}"
108
120
  labeljust = "l"
109
- {(f'pencolor = "{color}"' if color else 'pencolor="#ccc"')}
110
- {(f'penwidth = 3' if color else 'penwidth=""')}
111
121
  {inner_nodes_str}
112
122
  {child_str}
113
123
  }}'''
@@ -126,7 +136,7 @@ class Renderer:
126
136
  ])
127
137
 
128
138
 
129
- module_schemas_str = '\n'.join(self.render_module_schema(m) for m in module_schemas)
139
+ module_schemas_str = self.render_module_schema_wrapper(module_schemas)
130
140
  module_routes_str = '\n'.join(self.render_module_route(m) for m in module_routes)
131
141
  link_str = '\n'.join(self.render_link(link) for link in links)
132
142
 
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "0.7.1"
2
+ __version__ = "0.7.3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastapi-voyager
3
- Version: 0.7.1
3
+ Version: 0.7.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
@@ -203,7 +203,13 @@ TODO: ...
203
203
 
204
204
  ## Changelog
205
205
 
206
- - 0.7.1:
207
- - support brief mode, you can use `--module_prefix tests.service` to show links between routes and filtered schemas, to make the graph less complicated.
208
- - 0.6.2:
209
- - fix generic related issue
206
+ - 0.7:
207
+ - 0.7.3
208
+ - fix `module_color` failure
209
+ - 0.7.2
210
+ - keep links inside filtered nodes.
211
+ - 0.7.1
212
+ - support brief mode, you can use `--module_prefix tests.service` to show links between routes and filtered schemas, to make the graph less complicated.
213
+ - 0.6:
214
+ - 0.6.2:
215
+ - fix generic related issue
@@ -1,12 +1,12 @@
1
1
  fastapi_voyager/__init__.py,sha256=E5WTV_sYs2LK8I6jzA7AuvFU5a8_vjnDseC3DMha0iQ,149
2
2
  fastapi_voyager/cli.py,sha256=2eixX7mtPsZvukc4vrwQOt6XTPJgHUKIGLBy3IIC2jE,11127
3
- fastapi_voyager/filter.py,sha256=pp2vOWxQVOvN2ClwYVMxHnxo_FSEbgAHO2DqynKls1k,7861
3
+ fastapi_voyager/filter.py,sha256=2Yt37o8mhqSqleafO4YRrumh_ExYUqzXFOxQRPuTbAc,8078
4
4
  fastapi_voyager/module.py,sha256=Z2QHNmiLk6ZAJlm2nSmO875Q33TweSg8UxZSzIpU9zY,3499
5
- fastapi_voyager/render.py,sha256=ctwad-KNbFajhgnA8OI8412s6s67UbV-dvZFXBt_Ssg,7410
5
+ fastapi_voyager/render.py,sha256=rOJEKqiIAPowa3kZheRIgZMnbNzHQz9QoJM5aWUfXXs,7744
6
6
  fastapi_voyager/server.py,sha256=UT-fHggdqicIo5m3uUX86-XFhAVDLXpXBsBQwd1HdIg,4001
7
7
  fastapi_voyager/type.py,sha256=nad4WNxTcZFi7Mskw6p2W7v2Gs4f0giVLNoFjZlKmbA,1778
8
8
  fastapi_voyager/type_helper.py,sha256=f2Gy5r3Zi6a2wTkbqU9W-AkvcetajEYCfroACzcIcVY,9064
9
- fastapi_voyager/version.py,sha256=9L0K0Mei0qJm8M5gxRnUbHrVzN-hpZON05PnRrfBt-Q,48
9
+ fastapi_voyager/version.py,sha256=yQ9Z94li508cueSQbrmr6mCxqTFxZVqAMN1_3i0wslM,48
10
10
  fastapi_voyager/voyager.py,sha256=uOQEzrs3o6UUUswvHGRKELNWYUH1ix0Z7SbzMHwm320,10709
11
11
  fastapi_voyager/web/graph-ui.js,sha256=eEjDnJVMvk35LdRoxcqX_fZxLFS9_bUrGAZL6K2O5C0,4176
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.7.1.dist-info/METADATA,sha256=jMXu2Uz4UHAhDY8AaG6cnQlV3n8cgkFm6M4hX9Pm6eY,7068
30
- fastapi_voyager-0.7.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
- fastapi_voyager-0.7.1.dist-info/entry_points.txt,sha256=pEIKoUnIDXEtdMBq8EmXm70m16vELIu1VPz9-TBUFWM,53
32
- fastapi_voyager-0.7.1.dist-info/licenses/LICENSE,sha256=lNVRR3y_bFVoFKuK2JM8N4sFaj3m-7j29kvL3olFi5Y,1067
33
- fastapi_voyager-0.7.1.dist-info/RECORD,,
29
+ fastapi_voyager-0.7.3.dist-info/METADATA,sha256=zmLDE0ge68ohzR8MyukOKV-HMgAKpbHPXEb3ouOBwLE,7203
30
+ fastapi_voyager-0.7.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
+ fastapi_voyager-0.7.3.dist-info/entry_points.txt,sha256=pEIKoUnIDXEtdMBq8EmXm70m16vELIu1VPz9-TBUFWM,53
32
+ fastapi_voyager-0.7.3.dist-info/licenses/LICENSE,sha256=lNVRR3y_bFVoFKuK2JM8N4sFaj3m-7j29kvL3olFi5Y,1067
33
+ fastapi_voyager-0.7.3.dist-info/RECORD,,