Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'algorithm': 0.03; 'function,': 0.07; 'parsing': 0.07; '8bit%:30': 0.09; 'docstrings': 0.09; 'input,': 0.09; 'pep': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sep': 0.09; 'splitting': 0.09; 'subject:parsing': 0.09; 'terry': 0.09; 'tuple': 0.09; 'looked': 0.10; 'library': 0.15; 'source,': 0.15; 'docstring': 0.16; 'finney': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.17; 'documented': 0.17; 'module': 0.19; "haven't": 0.23; 'header:User- Agent:1': 0.26; 'am,': 0.27; 'header:X-Complaints-To:1': 0.28; 'writes:': 0.29; 'function': 0.30; 'url:python': 0.32; 'to:addr :python-list': 0.33; 'everyone': 0.33; 'thanks': 0.34; 'ben': 0.35; 'pm,': 0.35; 'received:org': 0.36; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'to:addr:python.org': 0.39; 'takes': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'great': 0.64; 'learned': 0.65; 'lose': 0.71; '2002': 0.78; 'joel': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: SOLVED: Docstring parsing and formatting Date: Tue, 18 Sep 2012 22:34:11 +1000 References: <7wk3vskrz6.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: rasputin.madmonks.org X-Public-Key-ID: 0xBD41714B X-Public-Key-Fingerprint: 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-gpg.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:+Pg5JGIlly5m1VxYjc2HPnLSbHs= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347971665 news.xs4all.nl 6980 [2001:888:2000:d::a6]:43992 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29425 Joel Goldstick writes: > On Tue, Sep 18, 2012 at 1:03 AM, Terry Reedy wrote: > > On 9/17/2012 10:03 PM, Ben Finney wrote: > >> Where can I find a standard implementation of the docstring parsing > >> and splitting algorithm from PEP 257? > > Do you know about pydoc? I haven't looked at its source, but since it > does a great job of printing documentation from docstrings it might > contain what you need Yes, I have now learned about the ‘pydoc’ module following the lead from investigating the interactive interpreter's ‘help’ function . The ‘pydoc.splitdoc’ function, though not documented in the library documentation, does what I need. It takes a docstring as input, and returns a tuple of (synopsis, description). Thanks to everyone who helped. -- \ “Value your freedom or you will lose it, teaches history. | `\ “Don't bother us with politics,” respond those who don't want | _o__) to learn.” —Richard Stallman, 2002 | Ben Finney