Skip to content

Commit

Permalink
bpo-940286: Fix pydoc to show cross refs correctly (GH-8390)
Browse files Browse the repository at this point in the history
  • Loading branch information
berkerpeksag authored Jul 23, 2018
1 parent 1426daa commit d04f46c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2028,14 +2028,15 @@ def showtopic(self, topic, more_xrefs=''):
except KeyError:
self.output.write('no documentation found for %s\n' % repr(topic))
return
pager(doc.strip() + '\n')
doc = doc.strip() + '\n'
if more_xrefs:
xrefs = (xrefs or '') + ' ' + more_xrefs
if xrefs:
import textwrap
text = 'Related help topics: ' + ', '.join(xrefs.split()) + '\n'
wrapped_text = textwrap.wrap(text, 72)
self.output.write('\n%s\n' % ''.join(wrapped_text))
doc += '\n%s\n' % '\n'.join(wrapped_text)
pager(doc)

def _gettopic(self, topic, more_xrefs=''):
"""Return unbuffered tuple of (topic, xrefs).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pydoc's ``Helper.showtopic()`` method now prints the cross references of a
topic correctly.

0 comments on commit d04f46c

Please sign in to comment.