'How to customize Python domain in Sphinx?
I’d like to customize the Sphinx Python domain to recognize a custom field within a docstring for a method and generate custom HTML for it.
For example, let’s say I want to add a category for each method in a module. I want to be able to write a doc string like this:
def func():
“””
Does something
:category: A/B/C
“””
…
and then have custom HTML display on the generated autodoc.
Is this possible?
Solution 1:[1]
Yes, it is, but it will require code (a custom extension) and might not be easy.
There might be a simpler way, but by subclassing PyClassLike, probably changing the values of doc_field_types and registering this with app.add_directive_to_domain("py", "class", YourClass, override=True) in a setup(app) fonction in your conf.py, you might get what you want.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | abstrus |
