pradyunsg / lutra

Ooops, I wrote another Sphinx theme! [very WIP, do not use]
https://pradyunsg.me/lutra/
MIT License
37 stars 7 forks source link

Investigate alternative mechanisms for trimming the toctree HTML (site navigation) #8

Closed pradyunsg closed 2 years ago

pradyunsg commented 2 years ago

https://github.com/pradyunsg/lutra/blob/23ef5df197d3e0c85ea66453b1d9d6c361f59a77/src/lutra/navigation.py#L35

Instead of parsing the toctree HTML for every page, explore if there's any other mechanism to trim the navigation tree to "only the toctree directive this came out of".

pradyunsg commented 2 years ago

This took a lot of figuring stuff out, but I got there!

https://github.com/pradyunsg/lutra/commit/d40716a4f933ca0d6495389d7c46ad922109ef52 is the change which contains the removal of BeautifulSoup from the toctree handling, that basically gets the docutils tree that Sphinx uses to render the toctree, manipulates it and renders it in the same way that Sphinx would've. This means that we have a rich data structure to work with, and it should fit within Sphinx's backwards compatibility policies as well. :)