|
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 | # Used in conf.py and updated here by python/release-tools/run_release.py |
31 | 25 | SOURCE_URI = 'https://github.com/python/cpython/tree/main/%s' |
@@ -57,69 +51,6 @@ def run(self): |
57 | 51 | return PyMethod.run(self) |
58 | 52 |
|
59 | 53 |
|
60 | | -# Support for building "topic help" for pydoc |
61 | | - |
62 | | -pydoc_topic_labels = [ |
63 | | - 'assert', 'assignment', 'assignment-expressions', 'async', 'atom-identifiers', |
64 | | - 'atom-literals', 'attribute-access', 'attribute-references', 'augassign', 'await', |
65 | | - 'binary', 'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object', |
66 | | - 'bltin-null-object', 'bltin-type-objects', 'booleans', |
67 | | - 'break', 'callable-types', 'calls', 'class', 'comparisons', 'compound', |
68 | | - 'context-managers', 'continue', 'conversions', 'customization', 'debugger', |
69 | | - 'del', 'dict', 'dynamic-features', 'else', 'exceptions', 'execmodel', |
70 | | - 'exprlists', 'floating', 'for', 'formatstrings', 'function', 'global', |
71 | | - 'id-classes', 'identifiers', 'if', 'imaginary', 'import', 'in', 'integers', |
72 | | - 'lambda', 'lists', 'naming', 'nonlocal', 'numbers', 'numeric-types', |
73 | | - 'objects', 'operator-summary', 'pass', 'power', 'raise', 'return', |
74 | | - 'sequence-types', 'shifting', 'slicings', 'specialattrs', 'specialnames', |
75 | | - 'string-methods', 'strings', 'subscriptions', 'truth', 'try', 'types', |
76 | | - 'typesfunctions', 'typesmapping', 'typesmethods', 'typesmodules', |
77 | | - 'typesseq', 'typesseq-mutable', 'unary', 'while', 'with', 'yield' |
78 | | -] |
79 | | - |
80 | | - |
81 | | -class PydocTopicsBuilder(Builder): |
82 | | - name = 'pydoc-topics' |
83 | | - |
84 | | - default_translator_class = TextTranslator |
85 | | - |
86 | | - def init(self): |
87 | | - self.topics = {} |
88 | | - self.secnumbers = {} |
89 | | - |
90 | | - def get_outdated_docs(self): |
91 | | - return 'all pydoc topics' |
92 | | - |
93 | | - def get_target_uri(self, docname, typ=None): |
94 | | - return '' # no URIs |
95 | | - |
96 | | - def write(self, *ignored): |
97 | | - writer = TextWriter(self) |
98 | | - for label in status_iterator(pydoc_topic_labels, |
99 | | - 'building topics... ', |
100 | | - length=len(pydoc_topic_labels)): |
101 | | - if label not in self.env.domaindata['std']['labels']: |
102 | | - self.env.logger.warning(f'label {label!r} not in documentation') |
103 | | - continue |
104 | | - docname, labelid, sectname = self.env.domaindata['std']['labels'][label] |
105 | | - doctree = self.env.get_and_resolve_doctree(docname, self) |
106 | | - document = new_document('<section node>') |
107 | | - document.append(doctree.ids[labelid]) |
108 | | - destination = StringOutput(encoding='utf-8') |
109 | | - writer.write(document, destination) |
110 | | - self.topics[label] = writer.output |
111 | | - |
112 | | - def finish(self): |
113 | | - f = open(path.join(self.outdir, 'topics.py'), 'wb') |
114 | | - try: |
115 | | - f.write('# -*- coding: utf-8 -*-\n'.encode('utf-8')) |
116 | | - f.write(('# Autogenerated by Sphinx on %s\n' % asctime()).encode('utf-8')) |
117 | | - f.write('# as part of the release process.\n'.encode('utf-8')) |
118 | | - f.write(('topics = ' + pformat(self.topics) + '\n').encode('utf-8')) |
119 | | - finally: |
120 | | - f.close() |
121 | | - |
122 | | - |
123 | 54 | # Support for documenting Opcodes |
124 | 55 |
|
125 | 56 | opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?') |
@@ -196,7 +127,6 @@ def patch_pairindextypes(app, _env) -> None: |
196 | 127 |
|
197 | 128 |
|
198 | 129 | def setup(app): |
199 | | - app.add_builder(PydocTopicsBuilder) |
200 | 130 | app.add_object_type('opcode', 'opcode', '%s (opcode)', parse_opcode_signature) |
201 | 131 | app.add_object_type('pdbcommand', 'pdbcmd', '%s (pdb command)', parse_pdb_command) |
202 | 132 | app.add_object_type('monitoring-event', 'monitoring-event', '%s (monitoring event)', parse_monitoring_event) |
|
0 commit comments