-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Provide a CSS class for classmethod in generated HTML #13454
Comments
Are you sure this isn't RTD theme specific? (I suppose the verbatim
There are Accessibility issues with color coding stuff. Generally theme designers take this into account because it's a design issue that's outside the skillset of most devs. So be advised that if you think about deviating from the usual theme design you might be creating accessibility issues for a number of users without being aware of it. There are likely good reasons why a theme (and RTD theme has had plenty of professional designer support) is organized the way it is. So if a feature isn't present there are also, likely, reasons for the omission that might elude us, |
Please correct me if I'm wrong, but in my understanding the HTML code structure is generated by Sphinx. I'm not aware of RTD bringing it's own HTML5 writer. So the structure of nested
I'm aware of this this. But Sphinx is a tool providing the structure and not the styling. Thus as a structure providing tool, information is currently missing so designers could style it differently. As to my understanding it's impossible to define such a style, because there is way to describe a CSS selector for class methods. My request is not about removing the text
Sorry, but themes are complex and have bugs - like programs have bugs, that's natural. I can imaging lots of time was invested in the themes. I'm also grateful for the RTD theme itself, but it has many visual problems and bugs. Some of them are caused by extensions, some or integral in the theme itself. This post is not complaining about these CSS problems or my personal different view to it. It's about an HTML/CSS API contract provided by Sphinx, so it can be styled by a theme or by user-defined CSS rules. Currently, information is swallowed by the API (here missing CSS classes) to differentiate methods from class methods. |
Not impossible, but... The usual solution (I've considered the problem you're raising years ago) is to break up things in the .. autoclass:: MyClass
.. rst-class:: the_instance_method_css_class_selector
.. automethod:: my_instance_method::
..
.. rst-class:: the_class_method_css_class_selector
.. automethod:: my_class_method::
.. The other workaround being the usual custom directive magic in
I agree, but note that styling doesn't solve the ordering problem mentioned above so, this falls into a strange middle ground between structure and styling that Sphinx hasn't entirely solved (although there are workarounds that require extra time and maintenance from the doc writers). It's a common problem that's likely been asked as often as it's been dismissed... Likely because Sphinx always has more pressing issues...
I'm not 100% sure but I've seen the RTD CSS selectors being different from those in other themes, so I'm guessing the themes extend into writing the CSS selector structure. (To this end there is no perfect solution, I've found RTD selectors to be overcomplicated, with Furo theme missing relevant selectors in more complicated rst combos, to PyData theme having so much pollution in their style sheets -due to using Sphinx Design- that's it's hard to find anything...) By all means, somebody correct me if I'm wrong. |
Is your feature request related to a problem? Please describe.
When trying to modify the ReadTheDocs theme via CSS, I noticed classes, methods, fields etc. are described using definition lists (
dl
,dt
,dd
). Depending on the content, CSS classes likeexception
,class
,method
, orproperty
are used for potentially different styling. E.g. properties could get a different color then methods. See example below.Besides "normal" methods, Sphinx also denotes classmethod (and I would suspect staticmethod too) as a sub category. Unfortunately, classmethods and staticmethods have no own or additional CSS class, in case separate styling is wished.
Describe the solution you'd like
Please provide an additional CSS classes:
classmethod
for class methods, andstaticmethod
for static methods.I would also like to discuss the following additions, which are a consequence of the previous enhancements:
dunder
class, if the method is a Python predefined dunder method (__init__
,__gt__
, ...), but not for user defined dunder methods.Alternative name:
predefined
inherited
class for methods and fields inherited from base classes.Anything I'm missing?
(The colors are just a test for what could be styled - not final :) )

Describe alternatives you've considered
I can't see a way to differentiate normal methods from classmethods and staticmethods by CSS selectors.
Additional context
Theme providers and theme users with local customizations might be interested in styling methods and class methods individually.
The text was updated successfully, but these errors were encountered: