mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-19 23:24:23 +01:00
chore: update docs again (#77)
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
"""Generate the code reference pages and navigation."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import mkdocs_gen_files
|
||||
@@ -9,9 +7,16 @@ nav = mkdocs_gen_files.Nav()
|
||||
root = Path(__file__).parent.parent.parent
|
||||
src = root / "src"
|
||||
|
||||
# Collecting all modules for the index page
|
||||
module_links = []
|
||||
core_modules = []
|
||||
toolkit_modules = []
|
||||
utils_modules = []
|
||||
|
||||
for path in sorted(src.rglob("*.py")):
|
||||
module_path = path.relative_to(src).with_suffix("")
|
||||
doc_path = path.relative_to(src).with_suffix(".md")
|
||||
module_path = path.relative_to(src).with_suffix("") # Removes the '.py' suffix
|
||||
doc_path = path.relative_to(src).with_suffix(".md") # Creates .md path
|
||||
|
||||
full_doc_path = Path("reference", doc_path)
|
||||
|
||||
parts = tuple(module_path.parts)
|
||||
@@ -23,13 +28,41 @@ for path in sorted(src.rglob("*.py")):
|
||||
elif parts[-1] == "__main__":
|
||||
continue
|
||||
|
||||
nav[parts] = doc_path.as_posix()
|
||||
# Construct a dynamic identifier based on module path
|
||||
ident = ".".join(parts)
|
||||
|
||||
# Organize modules into categories
|
||||
if "toolkit" in ident:
|
||||
toolkit_modules.append(f"- [{ident}]({doc_path})")
|
||||
elif "utils" in ident:
|
||||
utils_modules.append(f"- [{ident}]({doc_path})")
|
||||
else:
|
||||
core_modules.append(f"- [{ident}]({doc_path})")
|
||||
|
||||
# Generate the markdown file for each module
|
||||
with mkdocs_gen_files.open(full_doc_path, "w") as fd:
|
||||
ident = ".".join(parts)
|
||||
fd.write(f"::: {ident}")
|
||||
|
||||
mkdocs_gen_files.set_edit_path(full_doc_path, path.relative_to(root))
|
||||
nav[parts] = doc_path.as_posix()
|
||||
|
||||
# Write the enhanced SUMMARY.md with categories
|
||||
with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file:
|
||||
nav_file.writelines(nav.build_literate_nav())
|
||||
nav_file.write("# Reference Documentation Summary\n\n")
|
||||
|
||||
nav_file.write("## Core Modules\n")
|
||||
nav_file.write("\n".join(core_modules) + "\n\n")
|
||||
|
||||
nav_file.write("## Toolkit Modules\n")
|
||||
nav_file.write("\n".join(toolkit_modules) + "\n\n")
|
||||
|
||||
nav_file.write("## Utility Modules\n")
|
||||
nav_file.write("\n".join(utils_modules) + "\n\n")
|
||||
|
||||
# Create an index.md file for the reference section
|
||||
with mkdocs_gen_files.open("reference/index.md", "w") as index_file:
|
||||
index_file.write("# Reference Documentation\n\n")
|
||||
index_file.write("Welcome to the reference documentation for the project's Python modules.\n\n")
|
||||
index_file.write("Below is a list of available modules:\n\n")
|
||||
index_file.write("\n".join(core_modules + toolkit_modules + utils_modules))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user