| 2111 | self.list(self.topics.keys(), columns=3) |
| 2112 | |
| 2113 | def showtopic(self, topic, more_xrefs=''): |
| 2114 | try: |
| 2115 | import pydoc_data.topics |
| 2116 | except ImportError: |
| 2117 | self.output.write(''' |
| 2118 | Sorry, topic and keyword documentation is not available because the |
| 2119 | module "pydoc_data.topics" could not be found. |
| 2120 | ''') |
| 2121 | return |
| 2122 | target = self.topics.get(topic, self.keywords.get(topic)) |
| 2123 | if not target: |
| 2124 | self.output.write('no documentation found for %s\n' % repr(topic)) |
| 2125 | return |
| 2126 | if isinstance(target, str): |
| 2127 | return self.showtopic(target, more_xrefs) |
| 2128 | |
| 2129 | label, xrefs = target |
| 2130 | try: |
| 2131 | doc = pydoc_data.topics.topics[label] |
| 2132 | except KeyError: |
| 2133 | self.output.write('no documentation found for %s\n' % repr(topic)) |
| 2134 | return |
| 2135 | doc = doc.strip() + '\n' |
| 2136 | if more_xrefs: |
| 2137 | xrefs = (xrefs or '') + ' ' + more_xrefs |
| 2138 | if xrefs: |
| 2139 | text = 'Related help topics: ' + ', '.join(xrefs.split()) + '\n' |
| 2140 | wrapped_text = textwrap.wrap(text, 72) |
| 2141 | doc += '\n%s\n' % '\n'.join(wrapped_text) |
| 2142 | |
| 2143 | if self._output is None: |
| 2144 | pager(doc, f'Help on {topic!s}') |
| 2145 | else: |
| 2146 | self.output.write(doc) |
| 2147 | |
| 2148 | def _gettopic(self, topic, more_xrefs=''): |
| 2149 | """Return unbuffered tuple of (topic, xrefs). |