| 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(''' |
| 2217 | Sorry, topic and keyword documentation is not available because the |
| 2218 | module "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). |