Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29403 > unrolled thread

Docstring parsing and formatting

Started byBen Finney <ben+python@benfinney.id.au>
First post2012-09-18 12:03 +1000
Last post2012-09-18 12:03 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Docstring parsing and formatting Ben Finney <ben+python@benfinney.id.au> - 2012-09-18 12:03 +1000

#29403 — Docstring parsing and formatting

FromBen Finney <ben+python@benfinney.id.au>
Date2012-09-18 12:03 +1000
SubjectDocstring 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>).

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web