Closed CBroz1 closed 8 months ago
I think you could just skip the 2 levels when putting them into the Nav object, rather than when rendering it
That's true. I suppose the generator script would look something like this:
nav = mkdocs_gen_files.Nav()
for path in sorted(Path("src/project/").glob("**/*.py")):
rel_path = path.relative_to("src/project")
with mkdocs_gen_files.open(f"api/{rel_path.with_suffix('')}.md", "w") as f:
module_path = ".".join([p for p in path.with_suffix("").parts])
print(f"::: {module_path}", file=f)
nav[rel_path.parts] = f"{rel_path.with_suffix('')}.md"
I've worked on projects where the core codebase was in a subdirectory (e.g.,
src/project/
), which resulted in additional clicks to go from top -> api reference -> src -> project -> relevant filesI propose an optional build_literate_nav parameter that would skip the first N levels as follows:
In my case, this would permit me to include
nav.build_literate_nav(skip_levels=2)
in my page-generator script to remove the additional clicks mentioned aboveIf this is of interest, I'd be happy to open a PR
Thanks for all your work on this project!