Fix/9093 theme basic css import#14260
Open
mhughes2012 wants to merge 16 commits intosphinx-doc:masterfrom
Open
Fix/9093 theme basic css import#14260mhughes2012 wants to merge 16 commits intosphinx-doc:masterfrom
mhughes2012 wants to merge 16 commits intosphinx-doc:masterfrom
Conversation
Previously, if a theme defined a stylesheet, it would completely
overwrite the stylesheet list of any parent themes. This caused
inherited themes (like 'agogo' or 'traditional') to lose the
foundation 'basic.css' from the 'basic' theme.
This change:
1. Modifies Theme initialization to append inherited stylesheets
rather than replacing them.
2. Ensures stylesheets are deduplicated while preserving order.
3. Updates existing tests that relied on the previous replacement
behavior to expect the full inheritance chain.
Python 3.15's argparse is stricter with '%' sequences in version and help strings. Switching to an f-string for the version argument avoids the ValueError caused by the previous manual string formatting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This PR fixes a bug where HTML themes that inherit from a parent theme would accidentally overwrite the parent's stylesheet list instead of extending it. This was particularly problematic for themes like
agogoortraditionalthat inherit from thebasictheme; they would lose the corebasic.cssstyles if they defined their own stylesheets.Changes:
sphinx/theming.pyto merge stylesheet lists from the entire inheritance chain.basic.css) while preserving the correct loading order.tests/test_theming/test_theming.pythat were previously asserting the "replacement" behavior.I have verified this fix using a reproduction script that builds a project with the
agogotheme and confirms thatbasic.cssis correctly included in the final HTML output.References