Open
Description
Hi,
I am in need for some module docstring post-processing, and it took me rather long to figure out that:
autoapi
also allows (some?)autodoc-*
events to be captured- There are some differences in the values for
what
Especially it took me quite a while to figure out there are some subtle differences:
- autodoc:
what
can be :"module", "class", "exception", "function", "method", "attribute"
- autoapi:
what
can be :"package", "class", "exception", "function", "method", "attribute", "data"
Im not quite sure if t
I think that would be good to add to the documentation if this is indeed the intent, rather than a side effect of something else in my setup
It appears that the autodoc-process-signature
event is also available, but I have not done any further validation on that, but as it appears to be used internally by autoapi
, it is likely to work as well.
extensions = [
"autoapi.extension",
"sphinx.ext.napoleon",
]
# ...
mpy_lib_modules = {"foo":"bar"}
def process_docstring(
app: Sphinx,
what: str, # "module", "class", "exception", "function", "method", "attribute" ( "package", 'data' with autoapi)
name: str,
obj, # Always None with autoapi
options, # Always None with autoapi
lines: List[str],
):
if what in {"package", "module"} and name in mpy_lib_modules:
lines.extend(
(
"",
f".. seealso:: This is a `{mpy_lib_modules[name]}` module from the `micropython-lib` repository.",
)
)
def process_signature(app, what, name, obj, options, signature, return_annotation):
pass
def setup(sphinx: Sphinx):
sphinx.connect("autodoc-process-docstring", process_docstring) # also fires with autoapi :)
sphinx.connect("autodoc-process-signature", process_signature) # also fires with autoapi :)