|
7 | 7 |
|
8 | 8 | import mkdocs_gen_files
|
9 | 9 |
|
10 |
| -api_nav = mkdocs_gen_files.Nav() |
| 10 | +gen_nav = mkdocs_gen_files.Nav() |
11 | 11 |
|
12 | 12 | repo_root = Path(__file__).parent.parent.parent
|
13 |
| -src = repo_root / "src" |
14 | 13 |
|
15 |
| -for path in sorted(src.rglob("*.py")): |
16 |
| - module_path = path.relative_to(src).with_suffix("") |
17 |
| - doc_path = path.relative_to(src).with_suffix(".md") |
18 |
| - full_doc_path = Path("gen_reference", doc_path) |
| 14 | +def gen_pkg_docs(): |
| 15 | + src = repo_root / "src" |
| 16 | + # pkg_src = repo_root / "src" / pkg |
| 17 | + for path in sorted(src.rglob("*.py")): |
| 18 | + module_path = path.relative_to(src).with_suffix("") |
| 19 | + doc_path = path.relative_to(src).with_suffix(".md") |
| 20 | + full_doc_path = Path("gen_reference", doc_path) |
19 | 21 |
|
20 |
| - parts = tuple(module_path.parts) |
| 22 | + parts = tuple(module_path.parts) |
21 | 23 |
|
22 |
| - if parts[-1] == "__init__": |
23 |
| - parts = parts[:-1] |
24 |
| - elif parts[-1] == "__main__": |
25 |
| - continue |
| 24 | + if parts[-1] == "__init__": |
| 25 | + parts = parts[:-1] |
| 26 | + doc_path = doc_path.with_name("index.md") |
| 27 | + full_doc_path = full_doc_path.with_name("index.md") |
| 28 | + elif parts[-1] == "__main__": |
| 29 | + continue |
26 | 30 |
|
27 |
| - api_nav[parts] = doc_path.as_posix() |
| 31 | + gen_nav[parts] = doc_path.as_posix() |
28 | 32 |
|
29 |
| - with mkdocs_gen_files.open(full_doc_path, "w") as fd: |
30 |
| - identifier = ".".join(parts) |
31 |
| - print("::: " + identifier, file=fd) |
32 |
| - # TODO: add the options I want. See my old manual api*.md files. |
| 33 | + with mkdocs_gen_files.open(full_doc_path, "w") as fd: |
| 34 | + identifier = ".".join(parts) |
| 35 | + print("::: " + identifier, file=fd) |
| 36 | + # TODO: add the options I want. See my old manual api*.md files. |
33 | 37 |
|
34 |
| - mkdocs_gen_files.set_edit_path(full_doc_path, path.relative_to(repo_root)) |
| 38 | + mkdocs_gen_files.set_edit_path(full_doc_path, path.relative_to(repo_root)) |
35 | 39 |
|
36 | 40 |
|
37 |
| -with mkdocs_gen_files.open("gen_reference/API_NAV.md", "w") as nav_file: |
38 |
| - nav_file.writelines(api_nav.build_literate_nav()) |
| 41 | + with mkdocs_gen_files.open(f"gen_reference/GEN_NAV.md", "w") as nav_file: |
| 42 | + nav_file.writelines(gen_nav.build_literate_nav()) |
| 43 | + |
| 44 | +# FIXME: The current top level nav between root level packages is awkward. |
| 45 | +# The nav bar on the left is hiding "planet_auth" and only showing "planet_auth_utils". |
| 46 | +gen_pkg_docs() |
| 47 | + |
| 48 | +# TODO - separate nav for better doc site navigation? |
| 49 | +# gen_pkg_docs("planet_auth") |
| 50 | +# gen_pkg_docs("planet_auth_utils") |
0 commit comments