Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
4879604d
Commit
4879604d
authored
Oct 10, 2012
by
Georg Brandl
Browse files
Options
Browse Files
Download
Plain Diff
merge 3.2 heads
parents
ddb351c0
f4a29f3b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
2 deletions
+34
-2
Doc/library/doctest.rst
Doc/library/doctest.rst
+5
-2
Doc/tools/sphinxext/pyspecific.py
Doc/tools/sphinxext/pyspecific.py
+29
-0
No files found.
Doc/library/doctest.rst
View file @
4879604d
:
keepdoctest
:
:
mod
:`
doctest
`
---
Test
interactive
Python
examples
===================================================
...
...
@@ -652,7 +654,7 @@ example. Use ``+`` to enable the named behavior, or ``-`` to disable it.
For
example
,
this
test
passes
::
>>>
print
(
list
(
range
(
20
)))
#
doctest
:
+
NORMALIZE_WHITESPACE
>>>
print
(
list
(
range
(
20
)))
#
doctest
:
+
NORMALIZE_WHITESPACE
[
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
]
...
...
@@ -664,7 +666,8 @@ so::
>>> print(list(range(20))) # doctest: +ELLIPSIS
[0, 1, ..., 18, 19]
Multiple directives can be used on a single physical line, separated by commas::
Multiple directives can be used on a single physical line, separated by
commas::
>>> print(list(range(20))) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
[0, 1, ..., 18, 19]
...
...
Doc/tools/sphinxext/pyspecific.py
View file @
4879604d
...
...
@@ -33,9 +33,38 @@ def new_visit_versionmodified(self, node):
self
.
body
.
append
(
'<span class="versionmodified">%s</span> '
%
text
)
from
sphinx.writers.html
import
HTMLTranslator
from
sphinx.writers.latex
import
LaTeXTranslator
from
sphinx.locale
import
versionlabels
HTMLTranslator
.
visit_versionmodified
=
new_visit_versionmodified
HTMLTranslator
.
visit_versionmodified
=
new_visit_versionmodified
# monkey-patch HTML and LaTeX translators to keep doctest blocks in the
# doctest docs themselves
orig_visit_literal_block
=
HTMLTranslator
.
visit_literal_block
def
new_visit_literal_block
(
self
,
node
):
meta
=
self
.
builder
.
env
.
metadata
[
self
.
builder
.
current_docname
]
old_trim_doctest_flags
=
self
.
highlighter
.
trim_doctest_flags
if
'keepdoctest'
in
meta
:
self
.
highlighter
.
trim_doctest_flags
=
False
try
:
orig_visit_literal_block
(
self
,
node
)
finally
:
self
.
highlighter
.
trim_doctest_flags
=
old_trim_doctest_flags
HTMLTranslator
.
visit_literal_block
=
new_visit_literal_block
orig_depart_literal_block
=
LaTeXTranslator
.
depart_literal_block
def
new_depart_literal_block
(
self
,
node
):
meta
=
self
.
builder
.
env
.
metadata
[
self
.
curfilestack
[
-
1
]]
old_trim_doctest_flags
=
self
.
highlighter
.
trim_doctest_flags
if
'keepdoctest'
in
meta
:
self
.
highlighter
.
trim_doctest_flags
=
False
try
:
orig_depart_literal_block
(
self
,
node
)
finally
:
self
.
highlighter
.
trim_doctest_flags
=
old_trim_doctest_flags
LaTeXTranslator
.
depart_literal_block
=
new_depart_literal_block
# Support for marking up and linking to bugs.python.org issues
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment