Skip to content

Commit 5c1f15b

Browse files
authored
bpo-42843: Keep Sphinx 1.8 and Sphinx 2 compatibility (GH-24282)
1 parent 4833591 commit 5c1f15b

11 files changed

+30
-48
lines changed

.azure-pipelines/docs-steps.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ steps:
1212
inputs:
1313
versionSpec: '>=3.6'
1414

15-
- script: python -m pip install sphinx==3.2.1 blurb python-docs-theme
15+
- script: python -m pip install sphinx==2.2.0 blurb python-docs-theme
1616
displayName: 'Install build dependencies'
1717

1818
- ${{ if ne(parameters.latex, 'true') }}:

Doc/conf.py

+2
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,5 @@
237237
# bpo-40204: Disable warnings on Sphinx 2 syntax of the C domain since the
238238
# documentation is built with -W (warnings treated as errors).
239239
c_warn_on_allowed_pre_v3 = False
240+
241+
strip_signature_backslash = True

Doc/library/asyncio-stream.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ StreamReader
185185
can be read. Use the :attr:`IncompleteReadError.partial`
186186
attribute to get the partially read data.
187187

188-
.. coroutinemethod:: readuntil(separator=b'\n')
188+
.. coroutinemethod:: readuntil(separator=b'\\n')
189189

190190
Read data from the stream until *separator* is found.
191191

Doc/library/base64.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ The modern interface provides:
199199
.. versionadded:: 3.4
200200

201201

202-
.. function:: a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v')
202+
.. function:: a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \\t\\n\\r\\v')
203203

204204
Decode the Ascii85 encoded :term:`bytes-like object` or ASCII string *b* and
205205
return the decoded :class:`bytes`.

Doc/library/difflib.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
149149
contains a good example of its use.
150150

151151

152-
.. function:: context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n')
152+
.. function:: context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\\n')
153153

154154
Compare *a* and *b* (lists of strings); return a delta (a :term:`generator`
155155
generating the delta lines) in context diff format.
@@ -279,7 +279,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
279279
emu
280280

281281

282-
.. function:: unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n')
282+
.. function:: unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\\n')
283283

284284
Compare *a* and *b* (lists of strings); return a delta (a :term:`generator`
285285
generating the delta lines) in unified diff format.
@@ -321,7 +321,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
321321

322322
See :ref:`difflib-interface` for a more detailed example.
323323

324-
.. function:: diff_bytes(dfunc, a, b, fromfile=b'', tofile=b'', fromfiledate=b'', tofiledate=b'', n=3, lineterm=b'\n')
324+
.. function:: diff_bytes(dfunc, a, b, fromfile=b'', tofile=b'', fromfiledate=b'', tofiledate=b'', n=3, lineterm=b'\\n')
325325

326326
Compare *a* and *b* (lists of bytes objects) using *dfunc*; yield a
327327
sequence of delta lines (also bytes) in the format returned by *dfunc*.

Doc/library/doctest.rst

+17-37
Original file line numberDiff line numberDiff line change
@@ -719,51 +719,36 @@ above.
719719
An example's doctest directives modify doctest's behavior for that single
720720
example. Use ``+`` to enable the named behavior, or ``-`` to disable it.
721721

722-
For example, this test passes:
722+
For example, this test passes::
723723

724-
.. doctest::
725-
:no-trim-doctest-flags:
726-
727-
>>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE
724+
>>> print(list(range(20))) # doctest: +NORMALIZE_WHITESPACE
728725
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
729726
10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
730727

731728
Without the directive it would fail, both because the actual output doesn't have
732729
two blanks before the single-digit list elements, and because the actual output
733730
is on a single line. This test also passes, and also requires a directive to do
734-
so:
735-
736-
.. doctest::
737-
:no-trim-doctest-flags:
731+
so::
738732

739-
>>> print(list(range(20))) # doctest: +ELLIPSIS
733+
>>> print(list(range(20))) # doctest: +ELLIPSIS
740734
[0, 1, ..., 18, 19]
741735

742736
Multiple directives can be used on a single physical line, separated by
743-
commas:
737+
commas::
744738

745-
.. doctest::
746-
:no-trim-doctest-flags:
747-
748-
>>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
739+
>>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
749740
[0, 1, ..., 18, 19]
750741

751742
If multiple directive comments are used for a single example, then they are
752-
combined:
753-
754-
.. doctest::
755-
:no-trim-doctest-flags:
743+
combined::
756744

757-
>>> print(list(range(20))) # doctest: +ELLIPSIS
758-
... # doctest: +NORMALIZE_WHITESPACE
745+
>>> print(list(range(20))) # doctest: +ELLIPSIS
746+
... # doctest: +NORMALIZE_WHITESPACE
759747
[0, 1, ..., 18, 19]
760748

761749
As the previous example shows, you can add ``...`` lines to your example
762750
containing only directives. This can be useful when an example is too long for
763-
a directive to comfortably fit on the same line:
764-
765-
.. doctest::
766-
:no-trim-doctest-flags:
751+
a directive to comfortably fit on the same line::
767752

768753
>>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40)))
769754
... # doctest: +ELLIPSIS
@@ -808,23 +793,18 @@ instead. Another is to do ::
808793

809794
There are others, but you get the idea.
810795

811-
Another bad idea is to print things that embed an object address, like
812-
813-
.. doctest::
796+
Another bad idea is to print things that embed an object address, like ::
814797

815-
>>> id(1.0) # certain to fail some of the time # doctest: +SKIP
798+
>>> id(1.0) # certain to fail some of the time
816799
7948648
817800
>>> class C: pass
818-
>>> C() # the default repr() for instances embeds an address # doctest: +SKIP
819-
<C object at 0x00AC18F0>
820-
821-
The :const:`ELLIPSIS` directive gives a nice approach for the last example:
801+
>>> C() # the default repr() for instances embeds an address
802+
<__main__.C instance at 0x00AC18F0>
822803

823-
.. doctest::
824-
:no-trim-doctest-flags:
804+
The :const:`ELLIPSIS` directive gives a nice approach for the last example::
825805

826-
>>> C() # doctest: +ELLIPSIS
827-
<C object at 0x...>
806+
>>> C() #doctest: +ELLIPSIS
807+
<__main__.C instance at 0x...>
828808

829809
Floating-point numbers are also subject to small output variations across
830810
platforms, because Python defers to the platform C library for float formatting,

Doc/library/email.header.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Here is the :class:`Header` class description:
116116
if *s* is a byte string.
117117

118118

119-
.. method:: encode(splitchars=';, \t', maxlinelen=None, linesep='\n')
119+
.. method:: encode(splitchars=';, \\t', maxlinelen=None, linesep='\\n')
120120

121121
Encode a message header into an RFC-compliant format, possibly wrapping
122122
long lines and encapsulating non-ASCII parts in base64 or quoted-printable

Doc/library/functions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ are always available. They are listed here in alphabetical order.
13341334
supported.
13351335

13361336

1337-
.. function:: print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
1337+
.. function:: print(*objects, sep=' ', end='\\n', file=sys.stdout, flush=False)
13381338

13391339
Print *objects* to the text stream *file*, separated by *sep* and followed
13401340
by *end*. *sep*, *end*, *file* and *flush*, if present, must be given as keyword

Doc/library/http.cookies.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Cookie Objects
9393
:meth:`value_decode` are inverses on the range of *value_decode*.
9494

9595

96-
.. method:: BaseCookie.output(attrs=None, header='Set-Cookie:', sep='\r\n')
96+
.. method:: BaseCookie.output(attrs=None, header='Set-Cookie:', sep='\\r\\n')
9797

9898
Return a string representation suitable to be sent as HTTP headers. *attrs* and
9999
*header* are sent to each :class:`Morsel`'s :meth:`output` method. *sep* is used

Doc/library/io.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ Text I/O
964964
.. versionadded:: 3.7
965965

966966

967-
.. class:: StringIO(initial_value='', newline='\n')
967+
.. class:: StringIO(initial_value='', newline='\\n')
968968

969969
A text stream using an in-memory text buffer. It inherits
970970
:class:`TextIOBase`.

Doc/library/xml.dom.minidom.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ module documentation. This section lists the differences between the API and
174174
The :meth:`toxml` method now preserves the attribute order specified
175175
by the user.
176176

177-
.. method:: Node.toprettyxml(indent="\t", newl="\n", encoding=None, \
177+
.. method:: Node.toprettyxml(indent="\\t", newl="\\n", encoding=None, \
178178
standalone=None)
179179

180180
Return a pretty-printed version of the document. *indent* specifies the

0 commit comments

Comments
 (0)