mkdocs-print-site-plugin
mkdocs-print-site-plugin copied to clipboard
Rewrite sidebar TOC generation to be recursive
Hi there, and thanks for maintaining this plugin!
Currently, sidebar TOCs only assume one level of nesting, and don't obey excludes. This leads to both missing items and unexpected items that should have been excluded.
- Rewrite it to be recursive, such that all subsections are generated and appended as children.
- Also obey excludes and don't add anchors for them.
There was also a fixture for nested sections, but no corresponding test. Used that fixture to test this out. (I've also verified that it works against nextest's site.)
The result goes from:
to:
I believe this should fix #111 and #83.
I tested it and it seem to work pretty great for me!
(I personally would prefer a different numbering scheme btw, but that is a separate consideration)
Thanks for taking the effort to tackle this tricky topic ! Really appreciate it.
Couple of comments:
- There's a conflict to address (another PR merged that solved the excluding page from toc side bar issue)
- I also don't like the numbering scheme in this new setup. We should change it. Initially, each page is a chapter and would get a number. And sections (these are groups of pages in the navigation) would get a roman numbering. Shall we go implement a 'classic' numbering scheme like 1. section name 1.1 first chapter ?
Would you mind making the updates?
I fixed the merge conflict. @sunshowers could you have a look at the other comment?
Thanks, sorry I completely missed this because I fell sick in between :(
I tried doing some small updates and bringing this up-to-date with master, but ran into merge conflicts that I don't have time to resolve. I'd still really love to have this but I don't quite have time to work on it at the moment, work is too busy. I like the 1.1 scheme.
Please feel free to make changes to this and land this as you see fit. I might have time later this year, but please don't count on it.
If you can handle the CSS bits (I couldn't really follow them) I can probably take care of the Python. Does that sound okay?
Sure
This should close https://github.com/timvink/mkdocs-print-site-plugin/issues/123 also
@sunshowers We are considering to use this great plugin in Percona for single-page HTML and PDF versions of our docs for all the products. TOC artifacts seem to be the only thing stopping us, so we are really looking forward to this PR
So @bittorala picked up the work from this PR in #128 .
Thanks so much for all the effort to this PR @sunshowers ! I'll make sure to credit once the release is ready.