|
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' |
@@ -90,69 +84,6 @@ def run(self): |
90 | 84 | return PyMethod.run(self) |
91 | 85 |
|
92 | 86 |
|
93 | | -# Support for building "topic help" for pydoc |
94 | | - |
95 | | -pydoc_topic_labels = [ |
96 | | - 'assert', 'assignment', 'assignment-expressions', 'async', 'atom-identifiers', |
97 | | - 'atom-literals', 'attribute-access', 'attribute-references', 'augassign', 'await', |
98 | | - 'binary', 'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object', |
99 | | - 'bltin-null-object', 'bltin-type-objects', 'booleans', |
100 | | - 'break', 'callable-types', 'calls', 'class', 'comparisons', 'compound', |
101 | | - 'context-managers', 'continue', 'conversions', 'customization', 'debugger', |
102 | | - 'del', 'dict', 'dynamic-features', 'else', 'exceptions', 'execmodel', |
103 | | - 'exprlists', 'floating', 'for', 'formatstrings', 'function', 'global', |
104 | | - 'id-classes', 'identifiers', 'if', 'imaginary', 'import', 'in', 'integers', |
105 | | - 'lambda', 'lists', 'naming', 'nonlocal', 'numbers', 'numeric-types', |
106 | | - 'objects', 'operator-summary', 'pass', 'power', 'raise', 'return', |
107 | | - 'sequence-types', 'shifting', 'slicings', 'specialattrs', 'specialnames', |
108 | | - 'string-methods', 'strings', 'subscriptions', 'truth', 'try', 'types', |
109 | | - 'typesfunctions', 'typesmapping', 'typesmethods', 'typesmodules', |
110 | | - 'typesseq', 'typesseq-mutable', 'unary', 'while', 'with', 'yield' |
111 | | -] |
112 | | - |
113 | | - |
114 | | -class PydocTopicsBuilder(Builder): |
115 | | - name = 'pydoc-topics' |
116 | | - |
117 | | - default_translator_class = TextTranslator |
118 | | - |
119 | | - def init(self): |
120 | | - self.topics = {} |
121 | | - self.secnumbers = {} |
122 | | - |
123 | | - def get_outdated_docs(self): |
124 | | - return 'all pydoc topics' |
125 | | - |
126 | | - def get_target_uri(self, docname, typ=None): |
127 | | - return '' # no URIs |
128 | | - |
129 | | - def write(self, *ignored): |
130 | | - writer = TextWriter(self) |
131 | | - for label in status_iterator(pydoc_topic_labels, |
132 | | - 'building topics... ', |
133 | | - length=len(pydoc_topic_labels)): |
134 | | - if label not in self.env.domaindata['std']['labels']: |
135 | | - self.env.logger.warning(f'label {label!r} not in documentation') |
136 | | - continue |
137 | | - docname, labelid, sectname = self.env.domaindata['std']['labels'][label] |
138 | | - doctree = self.env.get_and_resolve_doctree(docname, self) |
139 | | - document = new_document('<section node>') |
140 | | - document.append(doctree.ids[labelid]) |
141 | | - destination = StringOutput(encoding='utf-8') |
142 | | - writer.write(document, destination) |
143 | | - self.topics[label] = writer.output |
144 | | - |
145 | | - def finish(self): |
146 | | - f = open(path.join(self.outdir, 'topics.py'), 'wb') |
147 | | - try: |
148 | | - f.write('# -*- coding: utf-8 -*-\n'.encode('utf-8')) |
149 | | - f.write(('# Autogenerated by Sphinx on %s\n' % asctime()).encode('utf-8')) |
150 | | - f.write('# as part of the release process.\n'.encode('utf-8')) |
151 | | - f.write(('topics = ' + pformat(self.topics) + '\n').encode('utf-8')) |
152 | | - finally: |
153 | | - f.close() |
154 | | - |
155 | | - |
156 | 87 | # Support for documenting Opcodes |
157 | 88 |
|
158 | 89 | opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?') |
@@ -231,7 +162,6 @@ def patch_pairindextypes(app, _env) -> None: |
231 | 162 | def setup(app): |
232 | 163 | app.add_role('issue', issue_role) |
233 | 164 | app.add_role('gh', gh_issue_role) |
234 | | - app.add_builder(PydocTopicsBuilder) |
235 | 165 | app.add_object_type('opcode', 'opcode', '%s (opcode)', parse_opcode_signature) |
236 | 166 | app.add_object_type('pdbcommand', 'pdbcmd', '%s (pdb command)', parse_pdb_command) |
237 | 167 | app.add_object_type('monitoring-event', 'monitoring-event', '%s (monitoring event)', parse_monitoring_event) |
|
0 commit comments