|
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' |
@@ -122,69 +116,6 @@ def run(self): |
122 | 116 | return PyMethod.run(self) |
123 | 117 |
|
124 | 118 |
|
125 | | -# Support for building "topic help" for pydoc |
126 | | - |
127 | | -pydoc_topic_labels = [ |
128 | | - 'assert', 'assignment', 'assignment-expressions', 'async', 'atom-identifiers', |
129 | | - 'atom-literals', 'attribute-access', 'attribute-references', 'augassign', 'await', |
130 | | - 'binary', 'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object', |
131 | | - 'bltin-null-object', 'bltin-type-objects', 'booleans', |
132 | | - 'break', 'callable-types', 'calls', 'class', 'comparisons', 'compound', |
133 | | - 'context-managers', 'continue', 'conversions', 'customization', 'debugger', |
134 | | - 'del', 'dict', 'dynamic-features', 'else', 'exceptions', 'execmodel', |
135 | | - 'exprlists', 'floating', 'for', 'formatstrings', 'function', 'global', |
136 | | - 'id-classes', 'identifiers', 'if', 'imaginary', 'import', 'in', 'integers', |
137 | | - 'lambda', 'lists', 'naming', 'nonlocal', 'numbers', 'numeric-types', |
138 | | - 'objects', 'operator-summary', 'pass', 'power', 'raise', 'return', |
139 | | - 'sequence-types', 'shifting', 'slicings', 'specialattrs', 'specialnames', |
140 | | - 'string-methods', 'strings', 'subscriptions', 'truth', 'try', 'types', |
141 | | - 'typesfunctions', 'typesmapping', 'typesmethods', 'typesmodules', |
142 | | - 'typesseq', 'typesseq-mutable', 'unary', 'while', 'with', 'yield' |
143 | | -] |
144 | | - |
145 | | - |
146 | | -class PydocTopicsBuilder(Builder): |
147 | | - name = 'pydoc-topics' |
148 | | - |
149 | | - default_translator_class = TextTranslator |
150 | | - |
151 | | - def init(self): |
152 | | - self.topics = {} |
153 | | - self.secnumbers = {} |
154 | | - |
155 | | - def get_outdated_docs(self): |
156 | | - return 'all pydoc topics' |
157 | | - |
158 | | - def get_target_uri(self, docname, typ=None): |
159 | | - return '' # no URIs |
160 | | - |
161 | | - def write(self, *ignored): |
162 | | - writer = TextWriter(self) |
163 | | - for label in status_iterator(pydoc_topic_labels, |
164 | | - 'building topics... ', |
165 | | - length=len(pydoc_topic_labels)): |
166 | | - if label not in self.env.domaindata['std']['labels']: |
167 | | - self.env.logger.warning(f'label {label!r} not in documentation') |
168 | | - continue |
169 | | - docname, labelid, sectname = self.env.domaindata['std']['labels'][label] |
170 | | - doctree = self.env.get_and_resolve_doctree(docname, self) |
171 | | - document = new_document('<section node>') |
172 | | - document.append(doctree.ids[labelid]) |
173 | | - destination = StringOutput(encoding='utf-8') |
174 | | - writer.write(document, destination) |
175 | | - self.topics[label] = writer.output |
176 | | - |
177 | | - def finish(self): |
178 | | - f = open(path.join(self.outdir, 'topics.py'), 'wb') |
179 | | - try: |
180 | | - f.write('# -*- coding: utf-8 -*-\n'.encode('utf-8')) |
181 | | - f.write(('# Autogenerated by Sphinx on %s\n' % asctime()).encode('utf-8')) |
182 | | - f.write('# as part of the release process.\n'.encode('utf-8')) |
183 | | - f.write(('topics = ' + pformat(self.topics) + '\n').encode('utf-8')) |
184 | | - finally: |
185 | | - f.close() |
186 | | - |
187 | | - |
188 | 119 | # Support for documenting Opcodes |
189 | 120 |
|
190 | 121 | opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?') |
@@ -263,7 +194,6 @@ def patch_pairindextypes(app, _env) -> None: |
263 | 194 | def setup(app): |
264 | 195 | app.add_role('issue', issue_role) |
265 | 196 | app.add_role('gh', gh_issue_role) |
266 | | - app.add_builder(PydocTopicsBuilder) |
267 | 197 | app.add_object_type('opcode', 'opcode', '%s (opcode)', parse_opcode_signature) |
268 | 198 | app.add_object_type('pdbcommand', 'pdbcmd', '%s (pdb command)', parse_pdb_command) |
269 | 199 | app.add_object_type('monitoring-event', 'monitoring-event', '%s (monitoring event)', parse_monitoring_event) |
|
0 commit comments