Hello,
What is the best way to document namedtuple fields in Python?
We are using the Sphinx autodoc extension to generate API documentation.
Currently, we document namedtuples as follows:
class MyTuple(typing.NamedTuple):
"""This is my named tuple.
Attributes:
x: This is the X coordinate.
y: This is the Y coordinate.
"""
x: float
y: float
When processing this with Sphinx 3.4.3, I see two problems:
- Sphinx prints warnings like
C:\defs.py:docstring of qmi.defs.MyTuple.x:1: WARNING: duplicate object
description of qmi.defs.MyTuple.x, other instance in generated/qmi.defs,
use :noindex: for one of them
- The generated HTML output actually contains two entries for each
namedtuple field, one entry containing my explicit documentation "This is
the X coordinate", the other entry containing the boilerplate string "Alias
for field number 0".
How can I avoid this. Is there a better way of writing the tuple field
documentation, or some configuration setting of sphinx.ext.autodoc that I
can use ?
Thanks,
Joris.
--
You received this message because you are subscribed to the Google Groups
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sphinx-users/7a327954-3345-4289-82a1-bb9343707d49n%40googlegroups.com.