Skip to content

Commit e9e6495

Browse files
bpo-940286: Fix pydoc to show cross refs correctly (GH-8390)
(cherry picked from commit d04f46c) Co-authored-by: Berker Peksag <[email protected]>
1 parent 0ff1746 commit e9e6495

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Lib/pydoc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,14 +1992,15 @@ def showtopic(self, topic, more_xrefs=''):
19921992
except KeyError:
19931993
self.output.write('no documentation found for %s\n' % repr(topic))
19941994
return
1995-
pager(doc.strip() + '\n')
1995+
doc = doc.strip() + '\n'
19961996
if more_xrefs:
19971997
xrefs = (xrefs or '') + ' ' + more_xrefs
19981998
if xrefs:
19991999
import textwrap
20002000
text = 'Related help topics: ' + ', '.join(xrefs.split()) + '\n'
20012001
wrapped_text = textwrap.wrap(text, 72)
2002-
self.output.write('\n%s\n' % ''.join(wrapped_text))
2002+
doc += '\n%s\n' % '\n'.join(wrapped_text)
2003+
pager(doc)
20032004

20042005
def _gettopic(self, topic, more_xrefs=''):
20052006
"""Return unbuffered tuple of (topic, xrefs).
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pydoc's ``Helper.showtopic()`` method now prints the cross references of a
2+
topic correctly.

0 commit comments

Comments
 (0)