mkdocs-docdive 0.1.0__tar.gz
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.
- mkdocs_docdive-0.1.0/.gitignore +34 -0
- mkdocs_docdive-0.1.0/LICENSE +21 -0
- mkdocs_docdive-0.1.0/PKG-INFO +45 -0
- mkdocs_docdive-0.1.0/README.md +29 -0
- mkdocs_docdive-0.1.0/pyproject.toml +32 -0
- mkdocs_docdive-0.1.0/src/mkdocs_docdive/__init__.py +1 -0
- mkdocs_docdive-0.1.0/src/mkdocs_docdive/plugin.py +65 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
.venv/
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.pyc
|
|
6
|
+
|
|
7
|
+
# corpus (large, not redistributable)
|
|
8
|
+
corpus/
|
|
9
|
+
|
|
10
|
+
# build outputs
|
|
11
|
+
dist/
|
|
12
|
+
dist-*/
|
|
13
|
+
build/
|
|
14
|
+
build-*/
|
|
15
|
+
site/
|
|
16
|
+
site-*/
|
|
17
|
+
*.log
|
|
18
|
+
*.status
|
|
19
|
+
*.tgz
|
|
20
|
+
|
|
21
|
+
# test and tool caches
|
|
22
|
+
test-results/
|
|
23
|
+
playwright-report/
|
|
24
|
+
.ruff_cache/
|
|
25
|
+
.docusaurus/
|
|
26
|
+
|
|
27
|
+
# local agent tooling
|
|
28
|
+
.agents/
|
|
29
|
+
.claude/
|
|
30
|
+
.github/extensions/
|
|
31
|
+
skills-lock.json
|
|
32
|
+
|
|
33
|
+
# OS / editor
|
|
34
|
+
.DS_Store
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Thibaud Navarre
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mkdocs-docdive
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MkDocs plugin that renders Mermaid fences as interactive docdive diagrams.
|
|
5
|
+
Project-URL: Repository, https://github.com/thibaudnavarre/docdive
|
|
6
|
+
Author: Thibaud Navarre
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: mermaid,mkdocs,mkdocs-plugin
|
|
10
|
+
Classifier: Framework :: MkDocs
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Requires-Dist: mkdocs<2,>=1.6
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# mkdocs-docdive
|
|
18
|
+
|
|
19
|
+
[docdive](https://github.com/thibaudnavarre/docdive) plugin for MkDocs: renders Mermaid fences as interactive
|
|
20
|
+
`<docdive-diagram>` elements and, after the build, writes the index and assets to `<site>/docdive/`.
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install mkdocs-docdive
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```yaml
|
|
27
|
+
# mkdocs.yml
|
|
28
|
+
site_url: https://example.com/docs/ # required
|
|
29
|
+
markdown_extensions:
|
|
30
|
+
- pymdownx.superfences:
|
|
31
|
+
custom_fences:
|
|
32
|
+
- name: mermaid
|
|
33
|
+
class: mermaid
|
|
34
|
+
format: !!python/name:pymdownx.superfences.fence_code_format
|
|
35
|
+
plugins:
|
|
36
|
+
- docdive
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Options:
|
|
40
|
+
|
|
41
|
+
- `command`: how to run the docdive CLI. Default `npx --yes docdive@<this plugin's version>`; Node >= 22.12 is needed at
|
|
42
|
+
build time.
|
|
43
|
+
- `src`: repo root that `src:` frontmatter paths are relative to (optional).
|
|
44
|
+
|
|
45
|
+
Supports `mkdocs>=1.6,<2` and Python >= 3.11. MkDocs 2.0 has no plugin system and is not supported. MIT.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# mkdocs-docdive
|
|
2
|
+
|
|
3
|
+
[docdive](https://github.com/thibaudnavarre/docdive) plugin for MkDocs: renders Mermaid fences as interactive
|
|
4
|
+
`<docdive-diagram>` elements and, after the build, writes the index and assets to `<site>/docdive/`.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pip install mkdocs-docdive
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```yaml
|
|
11
|
+
# mkdocs.yml
|
|
12
|
+
site_url: https://example.com/docs/ # required
|
|
13
|
+
markdown_extensions:
|
|
14
|
+
- pymdownx.superfences:
|
|
15
|
+
custom_fences:
|
|
16
|
+
- name: mermaid
|
|
17
|
+
class: mermaid
|
|
18
|
+
format: !!python/name:pymdownx.superfences.fence_code_format
|
|
19
|
+
plugins:
|
|
20
|
+
- docdive
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Options:
|
|
24
|
+
|
|
25
|
+
- `command`: how to run the docdive CLI. Default `npx --yes docdive@<this plugin's version>`; Node >= 22.12 is needed at
|
|
26
|
+
build time.
|
|
27
|
+
- `src`: repo root that `src:` frontmatter paths are relative to (optional).
|
|
28
|
+
|
|
29
|
+
Supports `mkdocs>=1.6,<2` and Python >= 3.11. MkDocs 2.0 has no plugin system and is not supported. MIT.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mkdocs-docdive"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "MkDocs plugin that renders Mermaid fences as interactive docdive diagrams."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{ name = "Thibaud Navarre" }]
|
|
13
|
+
requires-python = ">=3.11"
|
|
14
|
+
dependencies = ["mkdocs>=1.6,<2"]
|
|
15
|
+
keywords = ["mkdocs", "mkdocs-plugin", "mermaid"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Framework :: MkDocs",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Repository = "https://github.com/thibaudnavarre/docdive"
|
|
24
|
+
|
|
25
|
+
[project.entry-points."mkdocs.plugins"]
|
|
26
|
+
docdive = "mkdocs_docdive.plugin:DocdivePlugin"
|
|
27
|
+
|
|
28
|
+
[tool.hatch.version]
|
|
29
|
+
path = "src/mkdocs_docdive/__init__.py"
|
|
30
|
+
|
|
31
|
+
[tool.hatch.build.targets.wheel]
|
|
32
|
+
packages = ["src/mkdocs_docdive"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""docdive adapter for MkDocs. Data only: the product logic lives in the `docdive` CLI."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import re
|
|
5
|
+
import shlex
|
|
6
|
+
import shutil
|
|
7
|
+
import subprocess
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from urllib.parse import urlparse
|
|
10
|
+
|
|
11
|
+
from mkdocs.config import base
|
|
12
|
+
from mkdocs.config import config_options as c
|
|
13
|
+
from mkdocs.config.defaults import MkDocsConfig
|
|
14
|
+
from mkdocs.exceptions import PluginError
|
|
15
|
+
from mkdocs.plugins import BasePlugin
|
|
16
|
+
from mkdocs.structure.files import Files
|
|
17
|
+
from mkdocs.structure.pages import Page
|
|
18
|
+
|
|
19
|
+
from . import __version__
|
|
20
|
+
|
|
21
|
+
FENCE = re.compile(r'(<pre class="mermaid">.*?</pre>)', re.DOTALL)
|
|
22
|
+
ELEMENT_SCRIPT = "docdive/docdive-element.js"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class DocdiveConfig(base.Config):
|
|
26
|
+
# How to run the docdive CLI. Pin it to this plugin's version so the two cannot drift apart.
|
|
27
|
+
command = c.Type(str, default=f"npx --yes docdive@{__version__}")
|
|
28
|
+
# Repo root that `src:` frontmatter paths are relative to (optional).
|
|
29
|
+
src = c.Optional(c.Type(str))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class DocdivePlugin(BasePlugin[DocdiveConfig]):
|
|
33
|
+
def __init__(self) -> None:
|
|
34
|
+
self.doc_urls: dict[str, str] = {}
|
|
35
|
+
|
|
36
|
+
def on_config(self, config: MkDocsConfig) -> MkDocsConfig:
|
|
37
|
+
script = c.ExtraScriptValue(ELEMENT_SCRIPT)
|
|
38
|
+
script.type = "module"
|
|
39
|
+
config.extra_javascript.append(script)
|
|
40
|
+
return config
|
|
41
|
+
|
|
42
|
+
def on_files(self, files: Files, config: MkDocsConfig) -> Files:
|
|
43
|
+
# src_uri -> site-absolute URL (site_url path + file url), so the element needs no base-URL logic.
|
|
44
|
+
base_path = urlparse(config.site_url or "").path.rstrip("/")
|
|
45
|
+
self.doc_urls = {f.src_uri: f"{base_path}/{f.url}" for f in files.documentation_pages()}
|
|
46
|
+
return files
|
|
47
|
+
|
|
48
|
+
def on_page_content(self, html: str, page: Page, config: MkDocsConfig, files: Files) -> str:
|
|
49
|
+
# Wrap the fence before the theme mounts it; the element takes the text out of the light DOM.
|
|
50
|
+
return FENCE.sub(r"<docdive-diagram>\1</docdive-diagram>", html)
|
|
51
|
+
|
|
52
|
+
def on_post_build(self, config: MkDocsConfig) -> None:
|
|
53
|
+
dest = Path(config.site_dir) / "docdive"
|
|
54
|
+
command = shlex.split(self.config.command)
|
|
55
|
+
executable = shutil.which(command[0])
|
|
56
|
+
if executable is None:
|
|
57
|
+
raise PluginError(f"docdive: cannot run `{command[0]}`; Node.js >= 22.12 is required at build time")
|
|
58
|
+
args = [executable, *command[1:], "build", str(config.docs_dir), "--out", str(dest)]
|
|
59
|
+
if self.config.src:
|
|
60
|
+
args += ["--src", str(Path(self.config.src).resolve())]
|
|
61
|
+
try:
|
|
62
|
+
subprocess.run(args, check=True)
|
|
63
|
+
except subprocess.CalledProcessError as error:
|
|
64
|
+
raise PluginError(f"docdive: `{' '.join(args)}` exited with {error.returncode}") from error
|
|
65
|
+
(dest / "docdive-map.json").write_text(json.dumps(self.doc_urls, indent=2) + "\n")
|