Skip to content

Commit d6b6592

Browse files
committed
vibe-coding auto-creation of documentation pages
1 parent d3b8fe7 commit d6b6592

File tree

7 files changed

+54
-14
lines changed

7 files changed

+54
-14
lines changed

mkdocs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ site_dir: docs
44

55
plugins:
66
- search
7+
- gen-files:
8+
scripts:
9+
- scripts/gen_ref_pages.py
710
- mkdocstrings:
811
handlers:
912
python:
@@ -16,10 +19,7 @@ plugins:
1619

1720
nav:
1821
- Home: index.md
19-
- API Reference:
20-
- plotly: reference/plotly.md
21-
- plotly.graph_objects: reference/graph_objects.md
22-
- plotly.express: reference/express.md
22+
- API Reference: reference/
2323
- Project:
2424
- license.md
2525
- conduct.md

pages/reference/express.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

pages/reference/graph_objects.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

pages/reference/plotly.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ dev_build = [
5454
"markdown-include",
5555
"mkdocs",
5656
"mkdocs-material",
57-
"mkdocstrings[python]"
57+
"mkdocstrings[python]",
58+
"mkdocs-gen-files"
5859
]
5960
dev_optional = [
6061
"plotly[dev_build]",

scripts/gen_ref_pages.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""Generate the code reference pages and navigation."""
2+
3+
from pathlib import Path
4+
import mkdocs_gen_files
5+
6+
nav = mkdocs_gen_files.Nav()
7+
8+
for path in sorted(Path("plotly").rglob("*.py")):
9+
module_path = path.relative_to(".").with_suffix("")
10+
doc_path = path.relative_to(".").with_suffix(".md")
11+
full_doc_path = Path("reference", doc_path)
12+
13+
parts = tuple(module_path.parts)
14+
15+
if parts[-1] == "__init__":
16+
parts = parts[:-1]
17+
doc_path = doc_path.with_name("index.md")
18+
full_doc_path = full_doc_path.with_name("index.md")
19+
elif parts[-1] == "__main__":
20+
continue
21+
22+
nav[parts] = doc_path.as_posix()
23+
24+
with mkdocs_gen_files.open(full_doc_path, "w") as fd:
25+
ident = ".".join(parts)
26+
fd.write(f"# {ident}\n\n")
27+
fd.write(f"::: {ident}")
28+
29+
mkdocs_gen_files.set_edit_path(full_doc_path, path)
30+
31+
with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file:
32+
nav_file.writelines(nav.build_literate_nav())

uv.lock

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)