Skip to content

Commit

Permalink
Merge pull request #20 from python-project-templates/tkp/mm
Browse files Browse the repository at this point in the history
add mermaid support
  • Loading branch information
timkpaine authored Sep 5, 2024
2 parents 727a482 + 60d2e63 commit e4da08c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 25 deletions.
17 changes: 14 additions & 3 deletions docs/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ autodoc_pydantic_model_show_field_summary = false

```toml
[tool.yardang]
jupyter_execute_notebooks = "off"
execution_excludepatterns = []
nb_execution_mode = "off"
nb_execution_excludepatterns = []
```

Notebooks can be included with:
Expand All @@ -156,4 +156,15 @@ An example follows:
:maxdepth: 1
../notebooks/example
```
```


## Mermaid

```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies = [
"sphinx-autoapi",
"sphinx-copybutton",
"sphinx-design",
"sphinxcontrib-mermaid",
"toml",
"typer",
]
Expand Down Expand Up @@ -126,12 +127,7 @@ line-length = 150
combine-as-imports = true
default-section = "third-party"
known-first-party = ["yardang"]
section-order = [
"future",
"third-party",
"first-party",
"local-folder",
]
section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
Expand Down
8 changes: 4 additions & 4 deletions yardang/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ def generate_docs_configuration(
"autodoc_pydantic_settings_show_json",
"autodoc_pydantic_model_show_field_summary",
# myst/myst-nb
"jupyter_execute_notebooks",
"execution_excludepatterns",
"nb_execution_mode",
"nb_execution_excludepatterns",
):
default_value = {
# autodoc/autodoc-pydantic
"autodoc_pydantic_model_member_order": '"bysource"',
"autodoc_pydantic_model_show_json": True,
# myst/myst-nb
"execution_excludepatterns": [],
"jupyter_execute_notebooks": "off",
"nb_execution_excludepatterns": [],
"nb_execution_mode": "off",
}.get(f, False)
config_value = get_config(section=f"{f}")
configuration_args[f] = default_value if config_value is None else config_value
Expand Down
18 changes: 8 additions & 10 deletions yardang/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from sys import executable
from subprocess import Popen, PIPE
from sys import executable, stderr, stdout
from subprocess import Popen
from time import sleep
from typer import Typer

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

if debug:
print(" ".join(build_cmd))

process = Popen(build_cmd, stdout=PIPE)
if quiet:
process = Popen(build_cmd)
else:
process = Popen(build_cmd, stderr=stderr, stdout=stdout)
while process.poll() is None:
text = process.stdout.readline().decode("utf-8")
if text and not quiet:
print(text)
text = process.stdout.readline().decode("utf-8")
if text and not quiet:
print(text)
sleep(0.1)


def debug():
Expand Down
6 changes: 4 additions & 2 deletions yardang/conf.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.inheritance_diagram",
"sphinxcontrib.mermaid",
"sphinxcontrib.autodoc_pydantic",
]
if use_autoapi in (True, None):
Expand Down Expand Up @@ -74,8 +75,9 @@ pygments_style = "sphinx"

# myst / myst-nb
myst_enable_extensions = ["colon_fence"]
jupyter_execute_notebooks = "{{jupyter_execute_notebooks}}"
execution_excludepatterns = {{execution_excludepatterns}}
myst_fence_as_directive = ["mermaid"]
nb_execution_mode = "{{nb_execution_mode}}"
nb_execution_excludepatterns = {{nb_execution_excludepatterns}}

# autosummary
autosummary_generate = True
Expand Down

0 comments on commit e4da08c

Please sign in to comment.