mkdocs-print-site-plugin icon indicating copy to clipboard operation
mkdocs-print-site-plugin copied to clipboard

Rewrite sidebar TOC generation to be recursive

Open sunshowers opened this issue 1 year ago • 4 comments

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:

Screenshot from 2024-08-17 22-30-37

to:

Screenshot from 2024-08-17 22-29-43

I believe this should fix #111 and #83.

sunshowers avatar Aug 18 '24 05:08 sunshowers

I tested it and it seem to work pretty great for me!

brenard avatar Aug 18 '24 08:08 brenard

(I personally would prefer a different numbering scheme btw, but that is a separate consideration)

sunshowers avatar Aug 18 '24 18:08 sunshowers

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?

timvink avatar Aug 19 '24 08:08 timvink

I fixed the merge conflict. @sunshowers could you have a look at the other comment?

timvink avatar Sep 12 '24 11:09 timvink

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.

sunshowers avatar Oct 18 '24 22:10 sunshowers

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?

sunshowers avatar Oct 18 '24 22:10 sunshowers

Sure

timvink avatar Oct 22 '24 05:10 timvink

This should close https://github.com/timvink/mkdocs-print-site-plugin/issues/123 also

timvink avatar Oct 22 '24 05:10 timvink

@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

fiowro avatar Nov 27 '24 09:11 fiowro

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.

timvink avatar Mar 10 '25 09:03 timvink