Skip to content

Consider using default Sphinx toctree function instead of our own #220

@choldgraf

Description

@choldgraf

Ever since this theme has existed, building the left navigation bar has been a big pain in the butt. I think this is partially because we're using our own kind-of hacky code to generate that TocTree manually, and we run into weird edge-cases where things don't behave as expected.

So, I was wondering what folks thought about this:

  • Use the regular Sphinx toctree() function (in context["toctree"]() ). This will output the HTML for the toctree, but it won't have the classes etc that we need.
  • Use BeautifulSoup to manipulate the HTML that is generated, remove the pieces we don't want (e.g. top-level headers of non-active pages), and add the tags where we want them.

I feel like manipulating HTML via bs4 could be cleaner than manipulating the docutils tree structure, and we'd have the benefit of using the default Sphinx toctree, which should make this behave more predictably.

Curious what folks think about that...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions