homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: namedtuple docstrings are verbose for no added benefit
Type: enhancement Stage:
Components: Documentation, Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: docs@python, nedbat, rhettinger
Priority: normal Keywords:

Created on 2013年12月08日 16:46 by nedbat, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Messages (2)
msg205584 - (view) Author: Ned Batchelder (nedbat) * (Python triager) Date: 2013年12月08日 16:46
When I make a namedtuple, I get automatic docstrings that use a lot of words to say very little. Sphinx autodoc produces this:
```
class Key
 Key(scope, user_id, block_scope_id, field_name)
 __getnewargs__()
 Return self as a plain tuple. Used by copy and pickle.
 __repr__()
 Return a nicely formatted representation string
 block_scope_id None
 Alias for field number 2
 field_name None
 Alias for field number 3
 scope None
 Alias for field number 0
 user_id None
 Alias for field number 1
```
The individual property docstrings offer no new information over the summary at the top. I'd like namedtuple to be not so verbose where it has no useful information to offer. The one-line summary is all the information namedtuple has, so that is all it should include in the docstring:
```
class Key
 Key(scope, user_id, block_scope_id, field_name)
```
msg237250 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2015年03月05日 09:17
I don't think we should strip-out all the docstrings because you're unhappy with automatically (mindlessly) generated documentation. What you really need is more control over the documentation tool (the ability to save how much detail you want, particularly with subclasses of builtins which have a ton of methods with simplistic docstrings and with abstract base classes). 
The docstring for __repr__ isn't especially useful but it is a key feature of a namedtuple. 
The docstring for __getnewargs__ is informative especially if you're subclassing a named tuple and need to know what it is used for. 
The docstring for the individual property attributes doesn't look helpful when you list them all but does add information for one-at-a-time help, such as help(Key.blockscope), or for tooltips. FWIW, there is also a proposal to make it easier to custom the default docstrings for the properties (to turn it into more of a data dictionary).
History
Date User Action Args
2022年04月11日 14:57:55adminsetgithub: 64130
2015年03月05日 09:17:41rhettingersetstatus: open -> closed
versions: - Python 2.7, Python 3.4
messages: + msg237250

assignee: docs@python -> rhettinger
resolution: rejected
2015年03月05日 03:02:16BreamoreBoysetversions: + Python 3.4, Python 3.5, - Python 3.3
nosy: + docs@python

assignee: docs@python
components: + Documentation
type: enhancement
2013年12月08日 16:52:01serhiy.storchakasetnosy: + rhettinger
2013年12月08日 16:46:54nedbatcreate

AltStyle によって変換されたページ (->オリジナル) /