Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hamburger menu and fix local/global toc split #107

Merged
merged 2 commits into from
Jun 1, 2022
Merged

Conversation

jbms
Copy link
Owner

@jbms jbms commented May 28, 2022

This fixes the hamburger menu issue identified by @2bndy5 in #99.

Unfortunately, this fix does not work for the case where a Sphinx page has multiple top-level sections (rather than a single "title"). The design of the hamburger menu in the mkdocs-material theme does not seem to be able to accommodate that possibility.

@jbms jbms requested a review from 2bndy5 May 28, 2022 05:58
Previously, the entire branch of the global TOC corresponding to the
current page was split off and made into the local TOC, then pruned to
exclude the children of other pages.  Any sub-pages were excluded from
the global TOC.

With this commit, the local TOC will exclude all external links, while
the global TOC will contain any external links, along with any local
sections that transitively contain external links.

For example, given the structure:

a.rst:

    A
    =

    Section 1
    ----------

    .. toctree::

       b

Old global TOC:

  A

Old local TOC:

  Section 1
    b

New global TOC:

  A
    Section 1
      b

New local TOC:

  A
    Section 1
@jbms jbms force-pushed the fix-hamburger-menu branch from c2b9bd9 to 8be1496 Compare May 28, 2022 06:10
Previously, the TOC nodes corresponding to any sections within a page
were also marked as "active" and "current".  The mkdocs-material
hamburger menu was not designed to accommodate more than a single path
from the root of TOC nodes marked active, resulting in the menus for
multiple sections being shown on top of each other at the same time,
leading to confusing and incorrect behavior with the back buttons.

With this change, sections within a page are not marked active or
current, which fixes the hamburger menu.
@jbms jbms force-pushed the fix-hamburger-menu branch from 8be1496 to 6d668ee Compare May 28, 2022 06:36
Copy link
Collaborator

@2bndy5 2bndy5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize my concern was theme specific (thought it was specific to the custom python auto-gen ext).

@jbms jbms merged commit e1c50aa into main Jun 1, 2022
@jbms jbms deleted the fix-hamburger-menu branch July 8, 2022 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants