question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why are some theme-specific HTML elements (with CSS classes) inserted?

See original GitHub issue

Details

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:open
  • Created 2 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
stsewdcommented, Mar 2, 2022

should this issue be closed and tracked directly in https://github.com/readthedocs/sphinx_rtd_theme/issues/1239 instead?

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.

1reaction
agjohnsoncommented, Sep 29, 2021

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’s init() function.

There are several calls that happen in the theme init() (called by the theme’s enable() 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found