Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodoc's autoclass directive should include constructor docstring #46978

Closed
abhik mannequin opened this issue Apr 30, 2008 · 3 comments
Closed

Autodoc's autoclass directive should include constructor docstring #46978

abhik mannequin opened this issue Apr 30, 2008 · 3 comments
Assignees
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@abhik
Copy link
Mannequin

abhik mannequin commented Apr 30, 2008

BPO 2726
Nosy @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/birkenfeld'
closed_at = <Date 2008-05-04.09:38:02.220>
created_at = <Date 2008-04-30.14:04:09.147>
labels = ['type-bug', 'docs']
title = "Autodoc's autoclass directive should include constructor docstring"
updated_at = <Date 2008-05-07.20:21:03.556>
user = 'https://bugs.python.org/abhik'

bugs.python.org fields:

activity = <Date 2008-05-07.20:21:03.556>
actor = 'abhik'
assignee = 'georg.brandl'
closed = True
closed_date = <Date 2008-05-04.09:38:02.220>
closer = 'georg.brandl'
components = ['Documentation tools (Sphinx)']
creation = <Date 2008-04-30.14:04:09.147>
creator = 'abhik'
dependencies = []
files = []
hgrepos = []
issue_num = 2726
keywords = []
message_count = 3.0
messages = ['66002', '66200', '66372']
nosy_count = 2.0
nosy_names = ['georg.brandl', 'abhik']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue2726'
versions = ['Python 2.5']

@abhik
Copy link
Mannequin Author

abhik mannequin commented Apr 30, 2008

The autoclass directive adds the class constructor's argspec to the header and shows the class docstring
below it but doesn't add the constructor's docstring. I usually use the class docstring to describe the
class and the constructor's docstring to describe the constructor arguments so if the constructor argspec
is being shown, I would expect the description of it to be included below.

Result of svn diff sphinx/ext/autodoc.py:

Index: sphinx/ext/autodoc.py
===================================================================

--- sphinx/ext/autodoc.py	(revision 62582)
+++ sphinx/ext/autodoc.py	(working copy)
@@ -154,6 +154,13 @@
     result.append(indent + '.. %s:: %s%s' % (what, qualname, args), '<autodoc>')
     result.append('', '<autodoc>')
 
+    # added by abhik (4/29/08)
+    if what == 'class':
+        initdoc = inspect.getdoc(getattr(todoc, '__init__'))
+        if initdoc:
+            docstring = docstring if docstring else ''
+            docstring += "\n" + indent + initdoc
+
     # the module directive doesn't like content
     if what != 'module':
         indent += '   '

I don't know how other people would expect autodoc to work so maybe this behavior could be controlled by
a config param?

@abhik abhik mannequin assigned birkenfeld Apr 30, 2008
@abhik abhik mannequin added docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error labels Apr 30, 2008
@birkenfeld
Copy link
Member

Okay, I added a config value ("autoclass_content") in r62697. Let me
know what you think!

@abhik
Copy link
Mannequin Author

abhik mannequin commented May 7, 2008

Works great.. Thanks!

On Sun, May 4, 2008 at 5:38 AM, Georg Brandl <report@bugs.python.org> wrote:

Georg Brandl <georg@python.org> added the comment:

Okay, I added a config value ("autoclass_content") in r62697. Let me
know what you think!

----------
resolution: -> fixed
status: open -> closed


Tracker <report@bugs.python.org>
<http://bugs.python.org/issue2726\>


@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant