sphinx_rtd_theme
sphinx_rtd_theme copied to clipboard
Style sheet class 'property' conflicts with autodoc generated html of python properties 'py property'
Problem
I am using sphinx.ext.autodoc to generate documentation for a python project. Python properties can become ordered horizontally instead of vertically, depending on the width of the docstring (see B in the image below).
Autodoc generates html tags with class="py [element_type]" where element_type is class, method, attribute, property, and so on (D).
Unfortunately, the CSS class for the prefix of a class (A) also has class="property", which this theme stylizes (E).
Yes, this problem very much originates from autodoc or sphinx (not sure here). But I doubt they will change the generated class names, because it would break many existing themes.
Reproducible Project
See repo here.
Error Logs/Results

Expected Results
Maybe this theme can use a not(.py) classifier in the CSS for .property such that the class = "py property" is not matched. I'm not a frontend person, so I don't know if this is viable or how to achieve it.
Related to sphinx-doc/sphinx#9663
Environment Info
- Python Version: 3.8.10
- Sphinx Version: v4.2.0
- RTD Theme Version: 1.0.0
I just stumbled upon this very issue as well. As an easy workaround until it is fixed, adding the following custom CSS works well for me:
dl.py.property {
display: block !important;
}
That is a great workaround. Thank you!