|
12 | 12 | import re
|
13 | 13 | import io
|
14 | 14 | from os import getenv, path
|
15 |
| -from time import asctime |
16 |
| -from pprint import pformat |
17 | 15 |
|
18 | 16 | from docutils import nodes
|
19 |
| -from docutils.io import StringOutput |
20 | 17 | from docutils.parsers.rst import directives
|
21 |
| -from docutils.utils import new_document, unescape |
| 18 | +from docutils.utils import unescape |
22 | 19 | from sphinx import addnodes
|
23 |
| -from sphinx.builders import Builder |
24 | 20 | from sphinx.domains.python import PyFunction, PyMethod, PyModule
|
25 | 21 | from sphinx.locale import _ as sphinx_gettext
|
26 | 22 | from sphinx.util.docutils import SphinxDirective
|
27 |
| -from sphinx.writers.text import TextWriter, TextTranslator |
28 |
| -from sphinx.util.display import status_iterator |
29 | 23 |
|
30 | 24 |
|
31 | 25 | ISSUE_URI = 'https://bugs.python.org/issue?@action=redirect&bpo=%s'
|
@@ -223,69 +217,6 @@ def run(self):
|
223 | 217 | return []
|
224 | 218 |
|
225 | 219 |
|
226 |
| -# Support for building "topic help" for pydoc |
227 |
| - |
228 |
| -pydoc_topic_labels = [ |
229 |
| - 'assert', 'assignment', 'assignment-expressions', 'async', 'atom-identifiers', |
230 |
| - 'atom-literals', 'attribute-access', 'attribute-references', 'augassign', 'await', |
231 |
| - 'binary', 'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object', |
232 |
| - 'bltin-null-object', 'bltin-type-objects', 'booleans', |
233 |
| - 'break', 'callable-types', 'calls', 'class', 'comparisons', 'compound', |
234 |
| - 'context-managers', 'continue', 'conversions', 'customization', 'debugger', |
235 |
| - 'del', 'dict', 'dynamic-features', 'else', 'exceptions', 'execmodel', |
236 |
| - 'exprlists', 'floating', 'for', 'formatstrings', 'function', 'global', |
237 |
| - 'id-classes', 'identifiers', 'if', 'imaginary', 'import', 'in', 'integers', |
238 |
| - 'lambda', 'lists', 'naming', 'nonlocal', 'numbers', 'numeric-types', |
239 |
| - 'objects', 'operator-summary', 'pass', 'power', 'raise', 'return', |
240 |
| - 'sequence-types', 'shifting', 'slicings', 'specialattrs', 'specialnames', |
241 |
| - 'string-methods', 'strings', 'subscriptions', 'truth', 'try', 'types', |
242 |
| - 'typesfunctions', 'typesmapping', 'typesmethods', 'typesmodules', |
243 |
| - 'typesseq', 'typesseq-mutable', 'unary', 'while', 'with', 'yield' |
244 |
| -] |
245 |
| - |
246 |
| - |
247 |
| -class PydocTopicsBuilder(Builder): |
248 |
| - name = 'pydoc-topics' |
249 |
| - |
250 |
| - default_translator_class = TextTranslator |
251 |
| - |
252 |
| - def init(self): |
253 |
| - self.topics = {} |
254 |
| - self.secnumbers = {} |
255 |
| - |
256 |
| - def get_outdated_docs(self): |
257 |
| - return 'all pydoc topics' |
258 |
| - |
259 |
| - def get_target_uri(self, docname, typ=None): |
260 |
| - return '' # no URIs |
261 |
| - |
262 |
| - def write(self, *ignored): |
263 |
| - writer = TextWriter(self) |
264 |
| - for label in status_iterator(pydoc_topic_labels, |
265 |
| - 'building topics... ', |
266 |
| - length=len(pydoc_topic_labels)): |
267 |
| - if label not in self.env.domaindata['std']['labels']: |
268 |
| - self.env.logger.warning(f'label {label!r} not in documentation') |
269 |
| - continue |
270 |
| - docname, labelid, sectname = self.env.domaindata['std']['labels'][label] |
271 |
| - doctree = self.env.get_and_resolve_doctree(docname, self) |
272 |
| - document = new_document('<section node>') |
273 |
| - document.append(doctree.ids[labelid]) |
274 |
| - destination = StringOutput(encoding='utf-8') |
275 |
| - writer.write(document, destination) |
276 |
| - self.topics[label] = writer.output |
277 |
| - |
278 |
| - def finish(self): |
279 |
| - f = open(path.join(self.outdir, 'topics.py'), 'wb') |
280 |
| - try: |
281 |
| - f.write('# -*- coding: utf-8 -*-\n'.encode('utf-8')) |
282 |
| - f.write(('# Autogenerated by Sphinx on %s\n' % asctime()).encode('utf-8')) |
283 |
| - f.write('# as part of the release process.\n'.encode('utf-8')) |
284 |
| - f.write(('topics = ' + pformat(self.topics) + '\n').encode('utf-8')) |
285 |
| - finally: |
286 |
| - f.close() |
287 |
| - |
288 |
| - |
289 | 220 | # Support for documenting Opcodes
|
290 | 221 |
|
291 | 222 | opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?')
|
@@ -365,7 +296,6 @@ def setup(app):
|
365 | 296 | app.add_role('issue', issue_role)
|
366 | 297 | app.add_role('gh', gh_issue_role)
|
367 | 298 | app.add_directive('impl-detail', ImplementationDetail)
|
368 |
| - app.add_builder(PydocTopicsBuilder) |
369 | 299 | app.add_object_type('opcode', 'opcode', '%s (opcode)', parse_opcode_signature)
|
370 | 300 | app.add_object_type('pdbcommand', 'pdbcmd', '%s (pdb command)', parse_pdb_command)
|
371 | 301 | app.add_object_type('monitoring-event', 'monitoring-event', '%s (monitoring event)', parse_monitoring_event)
|
|
0 commit comments