-
Notifications
You must be signed in to change notification settings - Fork 29
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
Sphinx v4 support: exclude pygments css from layout #125
Conversation
Not sure I'm following what's going on here. You added the ability to loop through Also not sure what the change is in Sphinx 4 that necessitates that new Sorry, I may not be the most qualified person to review these PRs 😆 |
Yes, this is a bit of a confusing change due to how sphinx changed its behavior in version 4. To your point, the v4 version check is not necessary to exclude pygments, but I just happened to discover that in v4 the theme file was being included twice. Current code outputted by this theme: <!-- This is manually hard-coded in layout.html -->
<link rel="stylesheet" type="text/css" href="../_static/dist/theme.css" />
<link rel="stylesheet" type="text/css" href="../_static/dist/fontawesome.css" />
<!-- These are coming from css_files -->
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/dist/theme.css" />
<link rel="stylesheet" type="text/css" href="https://assets.readthedocs.org/static/css/badge_only.css" /> Prior to v4:
After v4:
See diff in I am using RTD theme as a reference point, since it is actively maintained: https://github.com/readthedocs/sphinx_rtd_theme/blob/master/sphinx_rtd_theme/layout.html |
@tbrlpld could I get a quick review/approval to merge this in? |
@vsalvino Trying to wrap my head around this at the moment. Could we fix the indentation so that template tags also cause a level of indentation? E.g. {% for item in the_list %}
<li>{ item }</li>
{% endfor %} instead of {% for item in the_list %}
<li>{ item }</li>
{% endfor %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I get what this does but I'm wondering if there is a better/smarter way to do this. This feels like swimming against the current so to speak 😉
Possibly we could extract our pygments styling and include it through the pygments_style
option? That way we...
- ...probably wouldn't need a 'hack' to exclude Sphinx's default pygments style.
- ...would allow users of our theme to provide their own pygments styles without ours conflicting.
What do you think @vsalvino? Would the above be a viable option? Happy to hear your thoughts since you appear to have more experience with Sphinx than me.
Yeah I think so. I didn't even see this sorry. I'll close and @vsalvino please review the commit reference above and let us know if we need further work done. |
The templating logic in this PR is still needed. If you run the package as-is without this change, using Sphinx version 4, you will see broken links (404s) in the stylesheet links in the If you run the package as-is without this change, using Sphinx older than 4, you will see the wrong styles in the source code syntax highlighting. As sphinx will still be pulling in the default pygments style. It might be a good idea to render the docs from the main branch, on both versions of sphinx, and confirm those two issues. If they are not issues in the main branch then this PR can be ignored. |
Are older versions of Sphinx still being maintained? Can we maybe just drop support for them? |
Read the docs defaults to Sphinx 1.6. So it is likely that we will want to continue support. Alternatively we can specify only sphinx v4 or higher. There are fields for this both in setup.py and also in the sphinx theme config. |
We could do the following.
|
Noticed a bug caused by my recent change of allowing the user's custom css... it was also pulling in pygments css file (sphinx>=4) which was causing style weirdness.
Blocking that file since our
theme.css
manually includes pygments styles instead.Tested the build output on sphinx versions 1, 2, 3, 4 to ensure it looks good on all.