Why are some theme-specific HTML elements (with CSS classes) inserted?
See original GitHub issueDetails
The file https://github.com/readthedocs/readthedocs.org/blob/master/readthedocs/core/static/core/js/readthedocs-doc-embed.js contains some JavaScript code that inserts a bunch of HTML elements with CSS classes, for example:
<div class='wy-table-responsive'></div>
It looks like this is used in the sphinx_rtd_theme
, but there is a separate JS file over there: https://github.com/readthedocs/sphinx_rtd_theme/blob/71d6d182cfeb7872c2399eac4a47d2f3c6b2c7d1/src/theme.js#L102-L103
Why is this theme-specific manipulation done, even if another theme is used?
Expected Result
No HTML/CSS manipulations unless they are related to the RTD-specific site components.
Especially no theme-specific manipulations.
Actual Result
Site elements that are not provided by RTD (e.g. tables in the main content) are manipulated.
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (11 by maintainers)
Top Results From Across the Web
The Beginner's Guide to CSS Classes - HubSpot Blog
A CSS class is an attribute used to define a group of HTML elements in order to apply unique styling and formatting to...
Read more >HTML Classes and Ids - What They Are (And When to Use What)
Classes and ids are hooks you can assign to HTML elements to make them more specific. That you have additional identifiers to assign...
Read more >WordPress School: HTML and CSS – Identifying IDs and ...
This is an example of the CSS styles to match the HTML. CSS Classes are not always a specific design element.
Read more >Lesson 1: Understanding ID and Class in CSS
It's generally a good practice though to include the element because it helps you to remember which elements had certain id's. Sometimes you'll...
Read more >Pseudo-classes and pseudo-elements - MDN Web Docs
There are a couple of special pseudo-elements, which are used along with the content property to insert content into your document using CSS....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This problem needs to be fixed in both sides. We are calling code from the theme from our side and the theme has rtd specific code.
The underlying issue is that we are calling
enable()
on the theme exported code (for badge only flyout on non-sphinx-rtd-theme themes), but there is sphinx-rtd-theme specific code in the theme’sinit()
function.There are several calls that happen in the theme
init()
(called by the theme’senable()
function) related to table display, and those should only happen when the the theme used by sphinx is a derivative of sphinx_rtd_theme. I believe these calls are:https://github.com/readthedocs/sphinx_rtd_theme/blob/71d6d182cfeb7872c2399eac4a47d2f3c6b2c7d1/src/theme.js#L101-L123
We don’t have a way to turn this off currently. A feature flag doesn’t quite solve this, there are some functions in there specifically for the badge only version of the flyout that are valid, but the table selector calls are definitely not required for all themes.
The best options are probably to resolve this in sphinx_rtd_theme 1.0.1/1.1.0, alter how we are calling the theme code from RTD embed.js, or both in some fashion most likely.