oprypin / mkdocs-gen-files

MkDocs plugin to programmatically generate documentation pages during the build
https://oprypin.github.io/mkdocs-gen-files
MIT License
98 stars 7 forks source link

Support empty first item, to create section contents? #31

Open pawamoy opened 1 month ago

pawamoy commented 1 month ago

Without literate-nav, I do this in nav:

    - Layouts:
      - manual/commands/api/layouts/index.md
      - Bsp: manual/commands/api/layouts/bsp.md
      - Columns: manual/commands/api/layouts/columns.md

(I use your section-index plugin)

How would I go about doing the same with literate-nav and gen-files?

If I do the following:

    - Layouts: manual/commands/api/layouts/

...and write this SUMMARY.md manually:

* [](index.md)
* [Bsp](bsp.md)
* [Columns](columns.md)

...it works. But I don't think I can programmatically create such a literate nav with gen-files:

nav = mkdocs_gen_files.Nav()

nav[()] = "index.md"  # error
nav[""] = "index.md"  # error
oprypin commented 1 month ago

The solution in mkdocs_literate_nav for this is:

Bonus style points for actual literate nav:

oprypin commented 1 month ago

To support this workaround in mkdocs-gen-files, this would be the code change: https://github.com/oprypin/mkdocs-gen-files/commit/d6f08a1c34d429f5703f340b3b7eb14960434312

pawamoy commented 1 month ago

implicit_index: true

Awesome, I missed this option in the docs, sorry!

This option solves my use-case, so the change in mkdocs-gen-files is not critical (but could allow per-summary configuration instead of only global configuration :+1:).

Thanks @oprypin.