bpo-940286: Fix pydoc to show cross refs correctly (GH-8390)

This commit is contained in:
Berker Peksag 2018-07-23 08:37:47 +03:00 committed by GitHub
parent 1426daa4fe
commit d04f46c59f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -2028,14 +2028,15 @@ module "pydoc_data.topics" could not be found.
except KeyError: except KeyError:
self.output.write('no documentation found for %s\n' % repr(topic)) self.output.write('no documentation found for %s\n' % repr(topic))
return return
pager(doc.strip() + '\n') doc = doc.strip() + '\n'
if more_xrefs: if more_xrefs:
xrefs = (xrefs or '') + ' ' + more_xrefs xrefs = (xrefs or '') + ' ' + more_xrefs
if xrefs: if xrefs:
import textwrap import textwrap
text = 'Related help topics: ' + ', '.join(xrefs.split()) + '\n' text = 'Related help topics: ' + ', '.join(xrefs.split()) + '\n'
wrapped_text = textwrap.wrap(text, 72) 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=''): def _gettopic(self, topic, more_xrefs=''):
"""Return unbuffered tuple of (topic, xrefs). """Return unbuffered tuple of (topic, xrefs).

View file

@ -0,0 +1,2 @@
pydoc's ``Helper.showtopic()`` method now prints the cross references of a
topic correctly.