sphinx_rtd_theme icon indicating copy to clipboard operation
sphinx_rtd_theme copied to clipboard

Style sheet class 'property' conflicts with autodoc generated html of python properties 'py property'

Open gschwaer opened this issue 4 years ago • 2 comments

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

img

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

gschwaer avatar Oct 27 '21 09:10 gschwaer

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;
}

luator avatar Oct 27 '21 12:10 luator

That is a great workaround. Thank you!

gschwaer avatar Oct 27 '21 14:10 gschwaer