Skip to content

Commit

Permalink
update gen logic
Browse files Browse the repository at this point in the history
  • Loading branch information
NodeJSmith committed Jun 13, 2024
1 parent 340b501 commit 01d9d78
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions scripts/gen_ref_pages.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Generate the code reference pages and navigation."""

import shutil
from pathlib import Path

import mkdocs_gen_files
Expand All @@ -9,6 +8,10 @@
root = Path(__file__).parent.parent
src = root / "src"

REF_DIR = root / "docs" / "reference"
if REF_DIR.exists():
shutil.rmtree(REF_DIR)

for path in sorted(src.rglob("*.py")):
module_path = path.relative_to(src).with_suffix("")
doc_path = path.relative_to(src).with_suffix(".md")
Expand All @@ -23,7 +26,18 @@
elif parts[-1] == "__main__":
continue

nav[parts] = doc_path.as_posix()
title_parts = []
for part in parts:
sub_parts = part.split("_")
for i, sub_part in enumerate(sub_parts):
if sub_part in ["api", "hr"]:
sub_parts[i] = sub_part.upper()
else:
sub_parts[i] = sub_part.capitalize()
part = " ".join(sub_parts)
title_parts.append(part)

nav[title_parts] = doc_path.as_posix()

with mkdocs_gen_files.open(full_doc_path, "w") as fd:
ident = ".".join(parts)
Expand Down

0 comments on commit 01d9d78

Please sign in to comment.