Mentions légales du service

Skip to content
Snippets Groups Projects
Verified Commit 4e7c5874 authored by ANDREY Paul's avatar ANDREY Paul
Browse files

Improve API reference navigation in online docs.

parent b1a45853
Branches
Tags
No related merge requests found
Pipeline #777886 waiting for manual action
...@@ -124,6 +124,7 @@ def parse_module( ...@@ -124,6 +124,7 @@ def parse_module(
if not key.startswith("_"): if not key.startswith("_"):
pub_mod[key] = parse_module(mod, docdir) pub_mod[key] = parse_module(mod, docdir)
# Create files for classes and functions exported from private submodules. # Create files for classes and functions exported from private submodules.
pub_obj = {}
for key, obj in module.members.items(): for key, obj in module.members.items():
if obj.is_module or obj.module.name in pub_mod or key.startswith("_"): if obj.is_module or obj.module.name in pub_mod or key.startswith("_"):
continue continue
...@@ -132,11 +133,19 @@ def parse_module( ...@@ -132,11 +133,19 @@ def parse_module(
path = os.path.join(docdir, f"{obj.name}.md") path = os.path.join(docdir, f"{obj.name}.md")
with open(path, "w", encoding="utf-8") as file: with open(path, "w", encoding="utf-8") as file:
file.write(f"#`{obj.path}`\n::: {obj.path}") file.write(f"#`{obj.path}`\n::: {obj.path}")
pub_obj[key] = f"{obj.name}.md"
# Write up an overview file based on the '__init__.py' docs. # Write up an overview file based on the '__init__.py' docs.
path = os.path.join(docdir, "index.md") path = os.path.join(docdir, "index.md")
with open(path, "w", encoding="utf-8") as file: with open(path, "w", encoding="utf-8") as file:
file.write(f"::: {module.path}") file.write(f"::: {module.path}")
return f"{module.name}/index.md" # Write up a literate-nav summary file based on the created files.
index = rf"- [\[{module.name}\]](./index.md)"
index += "".join(f"\n- [{k}](./{pub_obj[k]})" for k in sorted(pub_obj))
index += "".join(f"\n- [{k}](./{pub_mod[k]})" for k in sorted(pub_mod))
path = os.path.join(docdir, "SUMMARY.md")
with open(path, "w", encoding="utf-8") as file:
file.write(index)
return f"{module.name}/"
if __name__ == "__main__": if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment