Skip to content
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

CSS classes for just attribute/class/method/function name part of signature #240

Closed
jayqi opened this issue Feb 23, 2021 · 4 comments
Closed
Labels
feature New feature or request

Comments

@jayqi
Copy link

jayqi commented Feb 23, 2021

Is your feature request related to a problem? Please describe.

There is currently not a straightforward way to specify CSS selectors to just grab attribute/class/method/function names for styling. For example, I decided to style my docs' headers such that the names are bolded but not the rest of the signature like the type hints and arguments.

Describe the solution you'd like

CSS classes for the names of attribute/class/method/function signatures

Describe alternatives you've considered

Currently, I'm using a work around by first selecting all span elements inside doc-heading and styling them and then selecting all spans except the first and unstyling them. This is approach is obtuse and feels fragile—I'd much rather achieve this declaratively.

Example:

@jayqi jayqi added the feature New feature or request label Feb 23, 2021
@pawamoy
Copy link
Member

pawamoy commented Feb 24, 2021

Maybe we could use spans. Note that you can also override the signature.html template to add these spans yourself, while waiting for something that better suits your needs 😄
See https://mkdocstrings.github.io/usage/#templates

@pawamoy
Copy link
Member

pawamoy commented Apr 15, 2021

Currently, I'm using a work around by first selecting all span elements inside doc-heading and styling them and then selecting all spans except the first and unstyling them.

Couldn't you simply select the first span then?
https://www.w3schools.com/cssref/sel_firstchild.asp
Something like

.doc.doc-heading span:first-child {
    font-weight: bold;
}

@jayqi
Copy link
Author

jayqi commented Apr 16, 2021

It's been a while and I don't recall the details exactly, but I remember reading this StackOverflow answer about how first-child worked and that it may not have done what I wanted. https://stackoverflow.com/a/8539107

pawamoy added a commit to mkdocstrings/python that referenced this issue Apr 30, 2022
@pawamoy
Copy link
Member

pawamoy commented May 28, 2022

The new Python handler now adds these CSS classes to spans containing objects names in headings:

  • doc
  • doc-object-name
  • doc-KIND-name

...KIND being attribute, function, class or module.

Closing, feel free to reopen 🙂

@pawamoy pawamoy closed this as completed May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants