Skip to content

Commit 0344345

Browse files
committed
docs: Don't execute some architecutre code blocks when serving, to speed up the build
1 parent 2b12b46 commit 0344345

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

docs/guide/contributors/architecture.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,23 @@ Users then import `griffe` directly, or import objects from it.
115115
We'll be honest: our code organization is not the most elegant, but it works :shrug: Have a look at the following module dependency graph, which will basically tell you nothing except that we have a lot of inter-module dependencies. Arrows read as "imports from". The code base is generally pleasant to work with though.
116116

117117
```python exec="true" html="true" id="pydeps-module-graph"
118-
from pydeps import cli, colors, dot, py2depgraph
119-
from pydeps.pydeps import depgraph_to_dotsrc
120-
from pydeps.target import Target
121-
122-
cli.verbose = cli._not_verbose
123-
options = cli.parse_args(["src/griffe", "--noshow", "--reverse"])
124-
colors.START_COLOR = 128
125-
target = Target(options["fname"])
126-
with target.chdir_work():
127-
dep_graph = py2depgraph.py2dep(target, **options)
128-
dot_src = depgraph_to_dotsrc(target, dep_graph, **options)
129-
svg = dot.call_graphviz_dot(dot_src, "svg").decode()
130-
svg = "".join(svg.splitlines()[6:])
131-
svg = svg.replace('fill="white"', 'fill="transparent"')
132-
print(f'<div class="interactiveSVG pydeps">{svg}</div>')
118+
import os
119+
if os.getenv("DEPLOY") == "true":
120+
from pydeps import cli, colors, dot, py2depgraph
121+
from pydeps.pydeps import depgraph_to_dotsrc
122+
from pydeps.target import Target
123+
124+
cli.verbose = cli._not_verbose
125+
options = cli.parse_args(["src/griffe", "--noshow", "--reverse"])
126+
colors.START_COLOR = 128
127+
target = Target(options["fname"])
128+
with target.chdir_work():
129+
dep_graph = py2depgraph.py2dep(target, **options)
130+
dot_src = depgraph_to_dotsrc(target, dep_graph, **options)
131+
svg = dot.call_graphviz_dot(dot_src, "svg").decode()
132+
svg = "".join(svg.splitlines()[6:])
133+
svg = svg.replace('fill="white"', 'fill="transparent"')
134+
print(f'<div class="interactiveSVG pydeps">{svg}</div>')
133135
```
134136

135137
<small><i>You can zoom and pan all diagrams on this page with mouse inputs.</i></small>
@@ -155,7 +157,9 @@ render_public_api(heading_level=4)
155157
### Internal API
156158

157159
```python exec="1" idprefix="internal-" session="comment_blocks" id="internal-api"
158-
render_internal_api(heading_level=4)
160+
import os
161+
if os.getenv("DEPLOY") == "true":
162+
render_internal_api(heading_level=4)
159163
```
160164

161165
<style>

0 commit comments

Comments
 (0)