From 2979d6151a399ada8f3f83cc7e993592c2efec82 Mon Sep 17 00:00:00 2001 From: Valentin Berlier Date: Wed, 10 Aug 2022 01:36:18 +0200 Subject: [PATCH] feat: add mermaid --- README.md | 1 + docs/index.md | 1 + docs/mermaid_example.md | 23 +++++++++++++++++++++++ mudkip/application.py | 2 ++ poetry.lock | 11 ++++++++++- pyproject.toml | 1 + 6 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 docs/mermaid_example.md diff --git a/README.md b/README.md index 9fa07ce..36d21e7 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Mudkip enables the following Sphinx extensions: - [`sphinx.ext.githubpages`](https://www.sphinx-doc.org/en/master/usage/extensions/githubpages.html) when deploying to GitHub Pages - [`myst_parser`](https://myst-parser.readthedocs.io/en/latest/) for markdown support - [`myst_nb`](https://myst-nb.readthedocs.io/en/latest/) for Jupyter notebook support +- [`sphinxcontrib.mermaid`](https://github.com/mgaitan/sphinxcontrib-mermaid) for [Mermaid](https://mermaid-js.github.io/mermaid/) graphs and flowcharts ## Installation diff --git a/docs/index.md b/docs/index.md index 23b0bbd..2e7db65 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,6 +6,7 @@ A friendly Sphinx wrapper. :hidden: notebook_example +mermaid_example changelog ``` diff --git a/docs/mermaid_example.md b/docs/mermaid_example.md new file mode 100644 index 0000000..e2954e9 --- /dev/null +++ b/docs/mermaid_example.md @@ -0,0 +1,23 @@ +# Mermaid example + +```{mermaid} +graph TD; + A-->B; + A-->C; + B-->D; + C-->D; +``` + +```{mermaid} +sequenceDiagram + participant Alice + participant Bob + Alice->>John: Hello John, how are you? + loop Healthcheck + John->>John: Fight against hypochondria + end + Note right of John: Rational thoughts
prevail! + John-->>Alice: Great! + John->>Bob: How about you? + Bob-->>John: Jolly good! +``` diff --git a/mudkip/application.py b/mudkip/application.py index 48df06b..6dcf9e0 100644 --- a/mudkip/application.py +++ b/mudkip/application.py @@ -160,6 +160,8 @@ def create_sphinx_application(self): "intersphinx_mapping", {"python": ("https://docs.python.org/3", None)} ) + extensions.append("sphinxcontrib.mermaid") + extensions.append("mudkip.extension") self.sphinx = Sphinx( diff --git a/poetry.lock b/poetry.lock index cf72ff6..a839fe0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1445,6 +1445,14 @@ python-versions = ">=3.5" [package.extras] test = ["mypy", "flake8", "pytest"] +[[package]] +name = "sphinxcontrib-mermaid" +version = "0.7.1" +description = "Mermaid diagrams in yours Sphinx powered docs" +category = "main" +optional = false +python-versions = "*" + [[package]] name = "sphinxcontrib-qthelp" version = "1.0.3" @@ -1694,7 +1702,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest- [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "5142d6e92c662d0346b99ec67716f74e02287e35bc4e6d3cdd4179320f7e3d78" +content-hash = "25e0372447373abdfecc059b20b009e4fb82ccfaadfddf25ddcefc2c42f8f1f4" [metadata.files] alabaster = [] @@ -1809,6 +1817,7 @@ sphinxcontrib-applehelp = [] sphinxcontrib-devhelp = [] sphinxcontrib-htmlhelp = [] sphinxcontrib-jsmath = [] +sphinxcontrib-mermaid = [] sphinxcontrib-qthelp = [] sphinxcontrib-serializinghtml = [] sqlalchemy = [] diff --git a/pyproject.toml b/pyproject.toml index 78bf7a5..cdef154 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ jupyter-nbextensions-configurator = "^0.5.0" colorama = {version = "*", markers = 'sys_platform == "win32"'} myst-nb = "^0.16.0" furo = "^2022.6.21" +sphinxcontrib-mermaid = "^0.7.1" [tool.poetry.dev-dependencies] black = "^22.6.0"