Skip to content

Commit d62daa7

Browse files
committed
docs: Document customization of syntax highlight in signatures
1 parent 1fc4cb5 commit d62daa7

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

docs/usage/customization.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,36 @@ Available context:
348348

349349
- `section`: The [DocstringSection][griffe.docstrings.dataclasses.DocstringSection] instance (see `DocstringSection*` subclasses).
350350

351-
## Style recommendations
351+
### Syntax highlight in signatures
352+
353+
You can customize the colors in syntax highlighted signatures.
354+
If you are using the [Material for MkDocs] theme,
355+
here are some customization examples:
352356

353-
<a id="recommended-style-material"></a>
357+
```css
358+
/* Fancier color for operators such as * and |. */
359+
.doc-signature .o {
360+
color: var(--md-code-hl-special-color);
361+
}
354362

363+
/* Fancier color for constants such as None, True, and False. */
364+
.doc-signature .kc {
365+
color: var(--md-code-hl-constant-color);
366+
}
367+
368+
/* Fancier color for built-in types (only useful when cross-references are used). */
369+
.doc-signature .n > a[href^="https://docs.python.org/"][href*="/functions.html#"],
370+
.doc-signature .n > a[href^="https://docs.python.org/"][href*="/stdtypes.html#"] {
371+
color: var(--md-code-hl-constant-color);
372+
}
373+
```
374+
375+
For other themes, use their own CSS variables,
376+
or use plain colors such as `violet` or `#2987f2`.
377+
378+
## Style recommendations
379+
380+
[](){#recommended-style-material}
355381
### Material
356382

357383
Here are some CSS rules for the [Material for MkDocs] theme:
@@ -360,8 +386,7 @@ Here are some CSS rules for the [Material for MkDocs] theme:
360386
--8<-- "docs/css/mkdocstrings.css"
361387
```
362388

363-
<a id="recommended-style-readthedocs"></a>
364-
389+
[](){#recommended-style-readthedocs}
365390
### ReadTheDocs
366391

367392
Here are some CSS rules for the built-in ReadTheDocs theme:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy