Skip to content

Provide a CSS class for classmethod in generated HTML #13454

Open
@Paebbels

Description

@Paebbels

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 like exception, class, method, or property 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, and
    -<dl class="py method">
    +<dl class="py method classmethod">
      ...
    </dl>
  • staticmethod for static methods.

I would also like to discuss the following additions, which are a consequence of the previous enhancements:

  • Add a dunder class, if the method is a Python predefined dunder method (__init__, __gt__, ...), but not for user defined dunder methods.
    Alternative name: predefined
  • Add a 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 :) )
Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions