Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29403 > unrolled thread
| Started by | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| First post | 2012-09-18 12:03 +1000 |
| Last post | 2012-09-18 12:03 +1000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
Docstring parsing and formatting Ben Finney <ben+python@benfinney.id.au> - 2012-09-18 12:03 +1000
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2012-09-18 12:03 +1000 |
| Subject | Docstring parsing and formatting |
| Message-ID | <mailman.853.1347933804.27098.python-list@python.org> |
Howdy all,
Where can I find a standard implementation of the docstring parsing and
splitting algorithm from PEP 257?
PEP 257 describes a convention of structure and formatting for
docstrings <URL: http://www.python.org/dev/peps/pep-0257/>. Docstrings
that conform to this convention can therefore be parsed into their
component parts, and re-formatted.
The PEP describes <URL: http://www.python.org/dev/peps/pep-0257/#id20>
and algorithm for parsing the docstring as found in the string literal.
It says “Docstring processing tools will …” and goes on to describe, in
prose and example code, how the parsing should be done.
Where is a common implementation of that algorithm? It seems that it
should be in the Python standard library, but I can't find it.
Ideally what I want is to be able to write:
import textwrap
(summary, description) = textwrap.pep257_parse(foo.__doc__)
and have ‘summary’ as the docstring's summary line, and ‘description’ as
the docstring's description (as described in <URL:
http://www.python.org/dev/peps/pep-0257/#id19>).
Back to top | Article view | comp.lang.python
csiph-web