Skip to content

Commit 14f58f0

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 c7b91d9 commit 14f58f0

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
@@ -2028,14 +2028,15 @@ def showtopic(self, topic, more_xrefs=''):
20282028
except KeyError:
20292029
self.output.write('no documentation found for %s\n' % repr(topic))
20302030
return
2031-
pager(doc.strip() + '\n')
2031+
doc = doc.strip() + '\n'
20322032
if more_xrefs:
20332033
xrefs = (xrefs or '') + ' ' + more_xrefs
20342034
if xrefs:
20352035
import textwrap
20362036
text = 'Related help topics: ' + ', '.join(xrefs.split()) + '\n'
20372037
wrapped_text = textwrap.wrap(text, 72)
2038-
self.output.write('\n%s\n' % ''.join(wrapped_text))
2038+
doc += '\n%s\n' % '\n'.join(wrapped_text)
2039+
pager(doc)
20392040

20402041
def _gettopic(self, topic, more_xrefs=''):
20412042
"""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)