gh-86986: Drop compatibility support for Sphinx 2 (GH-93737)

* Revert "bpo-42843: Keep Sphinx 1.8 and Sphinx 2 compatibility (GH-24282)"

This reverts commit 5c1f15b4b1

* Revert "bpo-42579: Make workaround for various versions of Sphinx more robust (GH-23662)"

This reverts commit b63a620014.
(cherry picked from commit 0efe3a1636)

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2022-06-21 10:50:47 -07:00 committed by GitHub
parent 1347607db1
commit cc42716275
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 18 additions and 52 deletions

View file

@ -237,5 +237,3 @@ c_allow_pre_v3 = True
# bpo-40204: Disable warnings on Sphinx 2 syntax of the C domain since the # bpo-40204: Disable warnings on Sphinx 2 syntax of the C domain since the
# documentation is built with -W (warnings treated as errors). # documentation is built with -W (warnings treated as errors).
c_warn_on_allowed_pre_v3 = False c_warn_on_allowed_pre_v3 = False
strip_signature_backslash = True

View file

@ -192,7 +192,7 @@ StreamReader
can be read. Use the :attr:`IncompleteReadError.partial` can be read. Use the :attr:`IncompleteReadError.partial`
attribute to get the partially read data. attribute to get the partially read data.
.. coroutinemethod:: readuntil(separator=b'\\n') .. coroutinemethod:: readuntil(separator=b'\n')
Read data from the stream until *separator* is found. Read data from the stream until *separator* is found.

View file

@ -201,7 +201,7 @@ The modern interface provides:
.. versionadded:: 3.4 .. versionadded:: 3.4
.. function:: a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \\t\\n\\r\\v') .. function:: a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v')
Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *b* and Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *b* and
return the decoded :class:`bytes`. return the decoded :class:`bytes`.

View file

@ -149,7 +149,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
contains a good example of its use. contains a good example of its use.
.. function:: context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\\n') .. function:: context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n')
Compare *a* and *b* (lists of strings); return a delta (a :term:`generator` Compare *a* and *b* (lists of strings); return a delta (a :term:`generator`
generating the delta lines) in context diff format. generating the delta lines) in context diff format.
@ -279,7 +279,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
emu emu
.. function:: unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\\n') .. function:: unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n')
Compare *a* and *b* (lists of strings); return a delta (a :term:`generator` Compare *a* and *b* (lists of strings); return a delta (a :term:`generator`
generating the delta lines) in unified diff format. generating the delta lines) in unified diff format.
@ -321,7 +321,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
See :ref:`difflib-interface` for a more detailed example. See :ref:`difflib-interface` for a more detailed example.
.. function:: diff_bytes(dfunc, a, b, fromfile=b'', tofile=b'', fromfiledate=b'', tofiledate=b'', n=3, lineterm=b'\\n') .. function:: diff_bytes(dfunc, a, b, fromfile=b'', tofile=b'', fromfiledate=b'', tofiledate=b'', n=3, lineterm=b'\n')
Compare *a* and *b* (lists of bytes objects) using *dfunc*; yield a Compare *a* and *b* (lists of bytes objects) using *dfunc*; yield a
sequence of delta lines (also bytes) in the format returned by *dfunc*. sequence of delta lines (also bytes) in the format returned by *dfunc*.

View file

@ -116,7 +116,7 @@ Here is the :class:`Header` class description:
if *s* is a byte string. if *s* is a byte string.
.. method:: encode(splitchars=';, \\t', maxlinelen=None, linesep='\\n') .. method:: encode(splitchars=';, \t', maxlinelen=None, linesep='\n')
Encode a message header into an RFC-compliant format, possibly wrapping Encode a message header into an RFC-compliant format, possibly wrapping
long lines and encapsulating non-ASCII parts in base64 or quoted-printable long lines and encapsulating non-ASCII parts in base64 or quoted-printable

View file

@ -1393,7 +1393,7 @@ are always available. They are listed here in alphabetical order.
supported. supported.
.. function:: print(*objects, sep=' ', end='\\n', file=sys.stdout, flush=False) .. function:: print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
Print *objects* to the text stream *file*, separated by *sep* and followed Print *objects* to the text stream *file*, separated by *sep* and followed
by *end*. *sep*, *end*, *file*, and *flush*, if present, must be given as keyword by *end*. *sep*, *end*, *file*, and *flush*, if present, must be given as keyword

View file

@ -93,7 +93,7 @@ Cookie Objects
:meth:`value_decode` are inverses on the range of *value_decode*. :meth:`value_decode` are inverses on the range of *value_decode*.
.. method:: BaseCookie.output(attrs=None, header='Set-Cookie:', sep='\\r\\n') .. method:: BaseCookie.output(attrs=None, header='Set-Cookie:', sep='\r\n')
Return a string representation suitable to be sent as HTTP headers. *attrs* and Return a string representation suitable to be sent as HTTP headers. *attrs* and
*header* are sent to each :class:`Morsel`'s :meth:`output` method. *sep* is used *header* are sent to each :class:`Morsel`'s :meth:`output` method. *sep* is used

View file

@ -1042,7 +1042,7 @@ Text I/O
The method supports ``encoding="locale"`` option. The method supports ``encoding="locale"`` option.
.. class:: StringIO(initial_value='', newline='\\n') .. class:: StringIO(initial_value='', newline='\n')
A text stream using an in-memory text buffer. It inherits A text stream using an in-memory text buffer. It inherits
:class:`TextIOBase`. :class:`TextIOBase`.

View file

@ -180,7 +180,7 @@ module documentation. This section lists the differences between the API and
.. versionchanged:: 3.9 .. versionchanged:: 3.9
The *standalone* parameter was added. The *standalone* parameter was added.
.. method:: Node.toprettyxml(indent="\\t", newl="\\n", encoding=None, \ .. method:: Node.toprettyxml(indent="\t", newl="\n", encoding=None, \
standalone=None) standalone=None)
Return a pretty-printed version of the document. *indent* specifies the Return a pretty-printed version of the document. *indent* specifies the

View file

@ -418,12 +418,7 @@ class DeprecatedRemoved(Directive):
translatable=False) translatable=False)
node.append(para) node.append(para)
env = self.state.document.settings.env env = self.state.document.settings.env
# deprecated pre-Sphinx-2 method env.get_domain('changeset').note_changeset(node)
if hasattr(env, 'note_versionchange'):
env.note_versionchange('deprecated', version[0], node, self.lineno)
# new method
else:
env.get_domain('changeset').note_changeset(node)
return [node] + messages return [node] + messages

View file

@ -44,7 +44,6 @@ Copyright 2009 Gabriel A. Genellina
import os import os
import re import re
import csv import csv
import sys
from docutils import nodes from docutils import nodes
from sphinx.builders import Builder from sphinx.builders import Builder
@ -55,9 +54,7 @@ detect_all = re.compile(r'''
:[a-zA-Z][a-zA-Z0-9]+| # :foo :[a-zA-Z][a-zA-Z0-9]+| # :foo
`| # ` (seldom used by itself) `| # ` (seldom used by itself)
(?<!\.)\.\.[ \t]*\w+: # .. foo: (but NOT ... else:) (?<!\.)\.\.[ \t]*\w+: # .. foo: (but NOT ... else:)
''', re.UNICODE | re.VERBOSE).finditer ''', re.VERBOSE).finditer
py3 = sys.version_info >= (3, 0)
class Rule: class Rule:
@ -152,32 +149,15 @@ class CheckSuspiciousMarkupBuilder(Builder):
def report_issue(self, text, lineno, issue): def report_issue(self, text, lineno, issue):
self.any_issue = True self.any_issue = True
self.write_log_entry(lineno, issue, text) self.write_log_entry(lineno, issue, text)
if py3: self.logger.warning('[%s:%d] "%s" found in "%-.120s"' %
self.logger.warning('[%s:%d] "%s" found in "%-.120s"' %
(self.docname, lineno, issue, text)) (self.docname, lineno, issue, text))
else:
self.logger.warning(
'[%s:%d] "%s" found in "%-.120s"' % (
self.docname.encode(sys.getdefaultencoding(),'replace'),
lineno,
issue.encode(sys.getdefaultencoding(),'replace'),
text.strip().encode(sys.getdefaultencoding(),'replace')))
self.app.statuscode = 1 self.app.statuscode = 1
def write_log_entry(self, lineno, issue, text): def write_log_entry(self, lineno, issue, text):
if py3: f = open(self.log_file_name, 'a')
f = open(self.log_file_name, 'a') writer = csv.writer(f, dialect)
writer = csv.writer(f, dialect) writer.writerow([self.docname, lineno, issue, text.strip()])
writer.writerow([self.docname, lineno, issue, text.strip()]) f.close()
f.close()
else:
f = open(self.log_file_name, 'ab')
writer = csv.writer(f, dialect)
writer.writerow([self.docname.encode('utf-8'),
lineno,
issue.encode('utf-8'),
text.strip().encode('utf-8')])
f.close()
def load_rules(self, filename): def load_rules(self, filename):
"""Load database of previously ignored issues. """Load database of previously ignored issues.
@ -188,10 +168,7 @@ class CheckSuspiciousMarkupBuilder(Builder):
self.logger.info("loading ignore rules... ", nonl=1) self.logger.info("loading ignore rules... ", nonl=1)
self.rules = rules = [] self.rules = rules = []
try: try:
if py3: f = open(filename, 'r')
f = open(filename, 'r')
else:
f = open(filename, 'rb')
except IOError: except IOError:
return return
for i, row in enumerate(csv.reader(f)): for i, row in enumerate(csv.reader(f)):
@ -203,10 +180,6 @@ class CheckSuspiciousMarkupBuilder(Builder):
lineno = int(lineno) lineno = int(lineno)
else: else:
lineno = None lineno = None
if not py3:
docname = docname.decode('utf-8')
issue = issue.decode('utf-8')
text = text.decode('utf-8')
rule = Rule(docname, lineno, issue, text) rule = Rule(docname, lineno, issue, text)
rules.append(rule) rules.append(rule)
f.close() f.close()