Skip to content

Commit e4da08c

Browse files
authored
Merge pull request #20 from python-project-templates/tkp/mm
add mermaid support
2 parents 727a482 + 60d2e63 commit e4da08c

5 files changed

Lines changed: 32 additions & 25 deletions

File tree

docs/src/configuration.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ autodoc_pydantic_model_show_field_summary = false
134134

135135
```toml
136136
[tool.yardang]
137-
jupyter_execute_notebooks = "off"
138-
execution_excludepatterns = []
137+
nb_execution_mode = "off"
138+
nb_execution_excludepatterns = []
139139
```
140140

141141
Notebooks can be included with:
@@ -156,4 +156,15 @@ An example follows:
156156
:maxdepth: 1
157157
158158
../notebooks/example
159-
```
159+
```
160+
161+
162+
## Mermaid
163+
164+
```mermaid
165+
graph TD;
166+
A-->B;
167+
A-->C;
168+
B-->D;
169+
C-->D;
170+
```

pyproject.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ dependencies = [
3434
"sphinx-autoapi",
3535
"sphinx-copybutton",
3636
"sphinx-design",
37+
"sphinxcontrib-mermaid",
3738
"toml",
3839
"typer",
3940
]
@@ -126,12 +127,7 @@ line-length = 150
126127
combine-as-imports = true
127128
default-section = "third-party"
128129
known-first-party = ["yardang"]
129-
section-order = [
130-
"future",
131-
"third-party",
132-
"first-party",
133-
"local-folder",
134-
]
130+
section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]
135131

136132
[tool.ruff.lint.per-file-ignores]
137133
"__init__.py" = ["F401"]

yardang/build.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ def generate_docs_configuration(
8282
"autodoc_pydantic_settings_show_json",
8383
"autodoc_pydantic_model_show_field_summary",
8484
# myst/myst-nb
85-
"jupyter_execute_notebooks",
86-
"execution_excludepatterns",
85+
"nb_execution_mode",
86+
"nb_execution_excludepatterns",
8787
):
8888
default_value = {
8989
# autodoc/autodoc-pydantic
9090
"autodoc_pydantic_model_member_order": '"bysource"',
9191
"autodoc_pydantic_model_show_json": True,
9292
# myst/myst-nb
93-
"execution_excludepatterns": [],
94-
"jupyter_execute_notebooks": "off",
93+
"nb_execution_excludepatterns": [],
94+
"nb_execution_mode": "off",
9595
}.get(f, False)
9696
config_value = get_config(section=f"{f}")
9797
configuration_args[f] = default_value if config_value is None else config_value

yardang/cli.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from sys import executable
2-
from subprocess import Popen, PIPE
1+
from sys import executable, stderr, stdout
2+
from subprocess import Popen
3+
from time import sleep
34
from typer import Typer
45

56
from .build import generate_docs_configuration
@@ -19,15 +20,12 @@ def build(quiet: bool = False, debug: bool = False):
1920

2021
if debug:
2122
print(" ".join(build_cmd))
22-
23-
process = Popen(build_cmd, stdout=PIPE)
23+
if quiet:
24+
process = Popen(build_cmd)
25+
else:
26+
process = Popen(build_cmd, stderr=stderr, stdout=stdout)
2427
while process.poll() is None:
25-
text = process.stdout.readline().decode("utf-8")
26-
if text and not quiet:
27-
print(text)
28-
text = process.stdout.readline().decode("utf-8")
29-
if text and not quiet:
30-
print(text)
28+
sleep(0.1)
3129

3230

3331
def debug():

yardang/conf.py.j2

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ extensions = [
3636
"sphinx.ext.autodoc",
3737
"sphinx.ext.autosummary",
3838
"sphinx.ext.inheritance_diagram",
39+
"sphinxcontrib.mermaid",
3940
"sphinxcontrib.autodoc_pydantic",
4041
]
4142
if use_autoapi in (True, None):
@@ -74,8 +75,9 @@ pygments_style = "sphinx"
7475

7576
# myst / myst-nb
7677
myst_enable_extensions = ["colon_fence"]
77-
jupyter_execute_notebooks = "{{jupyter_execute_notebooks}}"
78-
execution_excludepatterns = {{execution_excludepatterns}}
78+
myst_fence_as_directive = ["mermaid"]
79+
nb_execution_mode = "{{nb_execution_mode}}"
80+
nb_execution_excludepatterns = {{nb_execution_excludepatterns}}
7981

8082
# autosummary
8183
autosummary_generate = True

0 commit comments

Comments
 (0)