I'm trying to document namedtuple. When I build the docs I get a warning WARNING: duplicate object description and same empty functions after documented ones. For example: 
How to delete those aliases?
I've already tried this solution, writing few functions to conf.py to create empty properties.
Also, I think it worth to mention that after building I get a note to use :noindex: but I don't understand where should I use it? In my docstring, rst file or somewhere else?
Code example:
File = namedtuple("File", ["path", "size", "extension",
"adate", "mdate", "links",
"user_owner", "group_owner",
"inode", "device", "permissions",
"depth"])
"""File attributes.
.. py:attribute:: path
**-** path to the found file
.. note::
depending on command-line arguments can be absolute or relative
...
I ran into a, I think, much better solution than the accepted answer, just wanted to share it:
Just write this in your conf.py:
# -- Post process ------------------------------------------------------------
import collections
def remove_namedtuple_attrib_docstring(app, what, name, obj, skip, options):
if type(obj) is collections._tuplegetter:
return True
return skip
def setup(app):
app.connect('autodoc-skip-member', remove_namedtuple_attrib_docstring)
This remove all parameters auto documented with this "Alias for field .." from all NamedTuple classes.
Explanation
This uses the autodoc event autodoc-skip-member which triggers an handler each time it comes across any type of member
app.connect('autodoc-skip-member', remove_namedtuple_attrib_docstring) attaches the handler remove_namedtuple_attrib_docstring to the eventIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With