Return unbuffered tuple of (topic, xrefs). If an error occurs here, the exception is caught and displayed by the url handler. This function duplicates the showtopic method but returns its result directly so it can be formatted for display in an html page.
(self, topic, more_xrefs='')
| 2146 | self.output.write(doc) |
| 2147 | |
| 2148 | def _gettopic(self, topic, more_xrefs=''): |
| 2149 | """Return unbuffered tuple of (topic, xrefs). |
| 2150 | |
| 2151 | If an error occurs here, the exception is caught and displayed by |
| 2152 | the url handler. |
| 2153 | |
| 2154 | This function duplicates the showtopic method but returns its |
| 2155 | result directly so it can be formatted for display in an html page. |
| 2156 | """ |
| 2157 | try: |
| 2158 | import pydoc_data.topics |
| 2159 | except ImportError: |
| 2160 | return(''' |
| 2161 | Sorry, topic and keyword documentation is not available because the |
| 2162 | module "pydoc_data.topics" could not be found. |
| 2163 | ''' , '') |
| 2164 | target = self.topics.get(topic, self.keywords.get(topic)) |
| 2165 | if not target: |
| 2166 | raise ValueError('could not find topic') |
| 2167 | if isinstance(target, str): |
| 2168 | return self._gettopic(target, more_xrefs) |
| 2169 | label, xrefs = target |
| 2170 | doc = pydoc_data.topics.topics[label] |
| 2171 | if more_xrefs: |
| 2172 | xrefs = (xrefs or '') + ' ' + more_xrefs |
| 2173 | return doc, xrefs |
| 2174 | |
| 2175 | def showsymbol(self, symbol): |
| 2176 | target = self.symbols[symbol] |