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: pydoc does not remove '#'-s from doc comments
Type: behavior Stage: resolved
Components: Versions: Python 3.1
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: ncoghlan, tkiss80
Priority: normal Keywords:

Created on 2011-07-24 23:05 by tkiss80, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg141061 - (view) Author: (tkiss80) Date: 2011-07-24 23:05
If an entity does not have a docstring, pydoc.getdoc() reads the comment associated with that entity and uses that as the source of documentation. However, inspect.getcomments() returns the raw comment with the comment signs ('#') in it, thus the resulting documentation looks ugly and confusing. Is there a way to solve this problem?

I know that this is not an easy task, because by implementing a specific '#' removing solution, the format of the doc comments would be restricted to conform to that algorithm with little formatting freedom. But maybe someone can come up with a good idea, such as counting '#'-s in the first line and strip all the lines accordingly.
msg141062 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2011-07-24 23:22
The best solution is to modify the offending code to use real docstrings.

Failing that, a simple explicit "'\n'.join(line.lstrip('#' for line in comment.split('\n'))" (i.e. not as part of pydoc) will handle most cases.

Anything more sophisticated would need to be tailored to the comment format of the code that is missing docstrings.
History
Date User Action Args
2022-04-11 14:57:20adminsetgithub: 56839
2011-07-24 23:22:19ncoghlansetstatus: open -> closed

nosy: + ncoghlan
messages: + msg141062

resolution: rejected
stage: resolved
2011-07-24 23:05:00tkiss80create