Skip to content

Fix navbar rendering for special pages in toctree#2447

Open
medmunds wants to merge 1 commit into
pydata:mainfrom
medmunds:2446-fix-virtual-docnames-in-toctree
Open

Fix navbar rendering for special pages in toctree#2447
medmunds wants to merge 1 commit into
pydata:mainfrom
medmunds:2446-fix-virtual-docnames-in-toctree

Conversation

@medmunds

Copy link
Copy Markdown

Support Sphinx virtual docnames "genindex", "modindex" and "search" in generate_header_nav_html(). Fixes #2446.

AI disclosure: PyCharm AI Assistant (chat mode, GPT-5.5 Medium) assisted with identifying the problem and refining the solution and the test case.

Support Sphinx virtual docnames "genindex", "modindex" and "search" in
generate_header_nav_html(). Fixes pydata#2446.
Comment on lines +166 to +171
elif page == "genindex":
title = _("Index")
elif page == "modindex":
title = _("Python Module Index")
elif page == "search":
title = _("Search")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This assumes any translations for these strings will be valid html. (That is, the translated strings don't need html escaping. The translation for the "More" menu label makes the same assumption—see _(dropdown_text) on line 315.)

Comment on lines +173 to +175
raise RuntimeError(
f"Could not find title for toctree entry: {page!r}"
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The AI wanted to set title = page here to fall back to the docname. I wasn't sure how that might occur, and since the original code raised a KeyError for an unknown page we compromised on this.

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.

KeyError in _generate_nav_info() with genindex in toctree

1 participant