MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / showtopic

Method showtopic

tools/python-3.11.9-amd64/Lib/pydoc.py:2212–2242  ·  view source on GitHub ↗
(self, topic, more_xrefs='')

Source from the content-addressed store, hash-verified

2210 self.list(self.topics.keys())
2211
2212 def showtopic(self, topic, more_xrefs=''):
2213 try:
2214 import pydoc_data.topics
2215 except ImportError:
2216 self.output.write('''
2217Sorry, topic and keyword documentation is not available because the
2218module "pydoc_data.topics" could not be found.
2219''')
2220 return
2221 target = self.topics.get(topic, self.keywords.get(topic))
2222 if not target:
2223 self.output.write('no documentation found for %s\n' % repr(topic))
2224 return
2225 if type(target) is type(''):
2226 return self.showtopic(target, more_xrefs)
2227
2228 label, xrefs = target
2229 try:
2230 doc = pydoc_data.topics.topics[label]
2231 except KeyError:
2232 self.output.write('no documentation found for %s\n' % repr(topic))
2233 return
2234 doc = doc.strip() + '\n'
2235 if more_xrefs:
2236 xrefs = (xrefs or '') + ' ' + more_xrefs
2237 if xrefs:
2238 import textwrap
2239 text = 'Related help topics: ' + ', '.join(xrefs.split()) + '\n'
2240 wrapped_text = textwrap.wrap(text, 72)
2241 doc += '\n%s\n' % '\n'.join(wrapped_text)
2242 pager(doc)
2243
2244 def _gettopic(self, topic, more_xrefs=''):
2245 """Return unbuffered tuple of (topic, xrefs).

Callers 2

helpMethod · 0.95
showsymbolMethod · 0.95

Calls 8

pagerFunction · 0.85
stripMethod · 0.80
typeClass · 0.50
writeMethod · 0.45
getMethod · 0.45
joinMethod · 0.45
splitMethod · 0.45
wrapMethod · 0.45

Tested by

no test coverage detected