Issue #26462: Doc: avoid literal_block warnings, fix syntax highlighting.
Patch by Julien Palard.
diff --git a/Doc/distutils/packageindex.rst b/Doc/distutils/packageindex.rst
index 7494495..8087584 100644
--- a/Doc/distutils/packageindex.rst
+++ b/Doc/distutils/packageindex.rst
@@ -235,7 +235,9 @@
To prevent registering broken reStructuredText content, you can use the
:program:`rst2html` program that is provided by the :mod:`docutils` package and
-check the ``long_description`` from the command line::
+check the ``long_description`` from the command line:
+
+.. code-block:: shell-session
$ python setup.py --long-description | rst2html.py > output.html
diff --git a/Doc/extending/building.rst b/Doc/extending/building.rst
index 656af88..f32192b 100644
--- a/Doc/extending/building.rst
+++ b/Doc/extending/building.rst
@@ -24,7 +24,9 @@
extension.
A distutils package contains a driver script, :file:`setup.py`. This is a plain
-Python file, which, in the most simple case, could look like this::
+Python file, which, in the most simple case, could look like this:
+
+.. code-block:: python
from distutils.core import setup, Extension
@@ -64,7 +66,9 @@
In many cases, building an extension is more complex, since additional
preprocessor defines and libraries may be needed. This is demonstrated in the
-example below. ::
+example below.
+
+.. code-block:: python
from distutils.core import setup, Extension
@@ -129,4 +133,3 @@
python setup.py bdist_wininst
python setup.py bdist_rpm
python setup.py bdist_dumb
-
diff --git a/Doc/extending/embedding.rst b/Doc/extending/embedding.rst
index 981e1d5..2330cdb 100644
--- a/Doc/extending/embedding.rst
+++ b/Doc/extending/embedding.rst
@@ -151,7 +151,9 @@
c = c + b
return c
-then the result should be::
+then the result should be:
+
+.. code-block:: shell-session
$ call multiply multiply 3 2
Will compute 3 times 2
@@ -274,16 +276,20 @@
be directly useful to you:
* ``pythonX.Y-config --cflags`` will give you the recommended flags when
- compiling::
+ compiling:
- $ /opt/bin/python2.7-config --cflags
- -I/opt/include/python2.7 -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
+ .. code-block:: shell-session
+
+ $ /opt/bin/python2.7-config --cflags
+ -I/opt/include/python2.7 -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes
* ``pythonX.Y-config --ldflags`` will give you the recommended flags when
- linking::
+ linking:
- $ /opt/bin/python2.7-config --ldflags
- -L/opt/lib/python2.7/config -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic
+ .. code-block:: shell-session
+
+ $ /opt/bin/python2.7-config --ldflags
+ -L/opt/lib/python2.7/config -lpthread -ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic
.. note::
To avoid confusion between several Python installations (and especially
diff --git a/Doc/extending/extending.rst b/Doc/extending/extending.rst
index 36de32a..37abbb7 100644
--- a/Doc/extending/extending.rst
+++ b/Doc/extending/extending.rst
@@ -763,7 +763,9 @@
format unit, it returns whatever object is described by that format unit. To
force it to return a tuple of size 0 or one, parenthesize the format string.
-Examples (to the left the call, to the right the resulting Python value)::
+Examples (to the left the call, to the right the resulting Python value):
+
+.. code-block:: none
Py_BuildValue("") None
Py_BuildValue("i", 123) 123
diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst
index de1849c..a642912 100644
--- a/Doc/extending/newtypes.rst
+++ b/Doc/extending/newtypes.rst
@@ -223,7 +223,9 @@
setup(name="noddy", version="1.0",
ext_modules=[Extension("noddy", ["noddy.c"])])
-in a file called :file:`setup.py`; then typing ::
+in a file called :file:`setup.py`; then typing
+
+.. code-block:: shell-session
$ python setup.py build
@@ -1580,4 +1582,3 @@
.. [#] Even in the third version, we aren't guaranteed to avoid cycles. Instances of
string subclasses are allowed and string subclasses could allow cycles even if
normal strings don't.
-
diff --git a/Doc/faq/extending.rst b/Doc/faq/extending.rst
index e78da55..c380645 100644
--- a/Doc/faq/extending.rst
+++ b/Doc/faq/extending.rst
@@ -156,6 +156,8 @@
Sample code and use for catching stdout:
+.. code-block:: pycon
+
>>> class StdoutCatcher:
... def __init__(self):
... self.data = ''
@@ -219,11 +221,15 @@
When using GDB with dynamically loaded extensions, you can't set a breakpoint in
your extension until your extension is loaded.
-In your ``.gdbinit`` file (or interactively), add the command::
+In your ``.gdbinit`` file (or interactively), add the command:
+
+.. code-block:: none
br _PyImport_LoadDynamicModule
-Then, when you run GDB::
+Then, when you run GDB:
+
+.. code-block:: shell-session
$ gdb /local/bin/python
gdb) run myscript.py
@@ -469,6 +475,8 @@
You can check the size of the Unicode character a Python interpreter is using by
checking the value of sys.maxunicode:
+.. code-block:: pycon
+
>>> import sys
>>> if sys.maxunicode > 65535:
... print 'UCS4 build'
diff --git a/Doc/howto/logging-cookbook.rst b/Doc/howto/logging-cookbook.rst
index 074c396..b7f0fa5 100644
--- a/Doc/howto/logging-cookbook.rst
+++ b/Doc/howto/logging-cookbook.rst
@@ -998,7 +998,9 @@
logger = logging.getLogger('mylogger')
logger.debug('A debug message')
-To run this, you will probably need to run as ``root``::
+To run this, you will probably need to run as ``root``:
+
+.. code-block:: shell-session
$ sudo python3.3 chowntest.py
$ cat chowntest.log
@@ -1500,7 +1502,9 @@
completion, the status is as it was before so message #6 appears (like message
#1) whereas message #7 doesn't (just like message #2).
-If we run the resulting script, the result is as follows::
+If we run the resulting script, the result is as follows:
+
+.. code-block:: shell-session
$ python logctx.py
1. This should appear just once on stderr.
@@ -1510,12 +1514,16 @@
6. This should appear just once on stderr.
If we run it again, but pipe ``stderr`` to ``/dev/null``, we see the following,
-which is the only message written to ``stdout``::
+which is the only message written to ``stdout``:
+
+.. code-block:: shell-session
$ python logctx.py 2>/dev/null
5. This should appear twice - once on stderr and once on stdout.
-Once again, but piping ``stdout`` to ``/dev/null``, we get::
+Once again, but piping ``stdout`` to ``/dev/null``, we get:
+
+.. code-block:: shell-session
$ python logctx.py >/dev/null
1. This should appear just once on stderr.
diff --git a/Doc/howto/logging.rst b/Doc/howto/logging.rst
index 5b431f0..6b17b08 100644
--- a/Doc/howto/logging.rst
+++ b/Doc/howto/logging.rst
@@ -106,7 +106,9 @@
logging.warning('Watch out!') # will print a message to the console
logging.info('I told you so') # will not print anything
-If you type these lines into a script and run it, you'll see::
+If you type these lines into a script and run it, you'll see:
+
+.. code-block:: none
WARNING:root:Watch out!
@@ -230,7 +232,9 @@
import logging
logging.warning('%s before you %s', 'Look', 'leap!')
-will display::
+will display:
+
+.. code-block:: none
WARNING:root:Look before you leap!
@@ -585,7 +589,9 @@
logger.error('error message')
logger.critical('critical message')
-Running this module from the command line produces the following output::
+Running this module from the command line produces the following output:
+
+.. code-block:: shell-session
$ python simple_logging_module.py
2005-03-19 15:10:26,618 - simple_example - DEBUG - debug message
@@ -644,7 +650,9 @@
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
datefmt=
-The output is nearly identical to that of the non-config-file-based example::
+The output is nearly identical to that of the non-config-file-based example:
+
+.. code-block:: shell-session
$ python simple_logging_config.py
2005-03-19 15:38:55,977 - simpleExample - DEBUG - debug message
@@ -1041,4 +1049,3 @@
Useful handlers included with the logging module.
:ref:`A logging cookbook <logging-cookbook>`
-
diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst
index 2c95fb4..0d0e9f5 100644
--- a/Doc/howto/regex.rst
+++ b/Doc/howto/regex.rst
@@ -79,7 +79,9 @@
devoted to discussing various metacharacters and what they do.
Here's a complete list of the metacharacters; their meanings will be discussed
-in the rest of this HOWTO. ::
+in the rest of this HOWTO.
+
+.. code-block:: none
. ^ $ * + ? { } [ ] \ | ( )
diff --git a/Doc/howto/unicode.rst b/Doc/howto/unicode.rst
index afd89c7..b94e5b5 100644
--- a/Doc/howto/unicode.rst
+++ b/Doc/howto/unicode.rst
@@ -619,7 +619,9 @@
print os.listdir('.')
print os.listdir(u'.')
-will produce the following output::
+will produce the following output:
+
+.. code-block:: shell-session
amk:~$ python t.py
['.svn', 'filename\xe4\x94\x80abc', ...]
diff --git a/Doc/library/2to3.rst b/Doc/library/2to3.rst
index 9f59dda..8496676 100644
--- a/Doc/library/2to3.rst
+++ b/Doc/library/2to3.rst
@@ -33,14 +33,18 @@
name = raw_input()
greet(name)
-It can be converted to Python 3.x code via 2to3 on the command line::
+It can be converted to Python 3.x code via 2to3 on the command line:
+
+.. code-block:: shell-session
$ 2to3 example.py
A diff against the original source file is printed. 2to3 can also write the
needed modifications right back to the source file. (A backup of the original
file is made unless :option:`-n` is also given.) Writing the changes back is
-enabled with the :option:`-w` flag::
+enabled with the :option:`-w` flag:
+
+.. code-block:: shell-session
$ 2to3 -w example.py
@@ -57,17 +61,23 @@
By default, 2to3 runs a set of :ref:`predefined fixers <2to3-fixers>`. The
:option:`-l` flag lists all available fixers. An explicit set of fixers to run
can be given with :option:`-f`. Likewise the :option:`!-x` explicitly disables a
-fixer. The following example runs only the ``imports`` and ``has_key`` fixers::
+fixer. The following example runs only the ``imports`` and ``has_key`` fixers:
+
+.. code-block:: shell-session
$ 2to3 -f imports -f has_key example.py
-This command runs every fixer except the ``apply`` fixer::
+This command runs every fixer except the ``apply`` fixer:
+
+.. code-block:: shell-session
$ 2to3 -x apply example.py
Some fixers are *explicit*, meaning they aren't run by default and must be
listed on the command line to be run. Here, in addition to the default fixers,
-the ``idioms`` fixer is run::
+the ``idioms`` fixer is run:
+
+.. code-block:: shell-session
$ 2to3 -f all -f idioms example.py
@@ -113,7 +123,9 @@
The :option:`--add-suffix` option specifies a string to append to all output
filenames. The :option:`-n` flag is required when specifying this as backups
-are not necessary when writing to different filenames. Example::
+are not necessary when writing to different filenames. Example:
+
+.. code-block:: shell-session
$ 2to3 -n -W --add-suffix=3 example.py
@@ -122,7 +134,9 @@
.. versionadded:: 2.7.3
The :option:`--add-suffix` option was added.
-To translate an entire project from one directory tree to another use::
+To translate an entire project from one directory tree to another use:
+
+.. code-block:: shell-session
$ 2to3 --output-dir=python3-version/mycode -W -n python2-version/mycode
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index 1dfebc2..bdc699f 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -44,7 +44,9 @@
print args.accumulate(args.integers)
Assuming the Python code above is saved into a file called ``prog.py``, it can
-be run at the command line and provides useful help messages::
+be run at the command line and provides useful help messages:
+
+.. code-block:: shell-session
$ python prog.py -h
usage: prog.py [-h] [--sum] N [N ...]
@@ -59,7 +61,9 @@
--sum sum the integers (default: find the max)
When run with the appropriate arguments, it prints either the sum or the max of
-the command-line integers::
+the command-line integers:
+
+.. code-block:: shell-session
$ python prog.py 1 2 3 4
4
@@ -67,7 +71,9 @@
$ python prog.py 1 2 3 4 --sum
10
-If invalid arguments are passed in, it will issue an error::
+If invalid arguments are passed in, it will issue an error:
+
+.. code-block:: shell-session
$ python prog.py a b c
usage: prog.py [-h] [--sum] N [N ...]
@@ -187,7 +193,9 @@
args = parser.parse_args()
The help for this program will display ``myprogram.py`` as the program name
-(regardless of where the program was invoked from)::
+(regardless of where the program was invoked from):
+
+.. code-block:: shell-session
$ python myprogram.py --help
usage: myprogram.py [-h] [--foo FOO]
@@ -550,7 +558,9 @@
args = parser.parse_args()
If ``-h`` or ``--help`` is supplied at the command line, the ArgumentParser
-help will be printed::
+help will be printed:
+
+.. code-block:: shell-session
$ python myprogram.py --help
usage: myprogram.py [-h] [--foo FOO]
diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
index cf0c32e..6d5855b 100644
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -113,6 +113,7 @@
The abstract grammar is currently defined as follows:
.. literalinclude:: ../../Parser/Python.asdl
+ :language: none
:mod:`ast` Helpers
diff --git a/Doc/library/cgi.rst b/Doc/library/cgi.rst
index da15e00..1bfdb39 100644
--- a/Doc/library/cgi.rst
+++ b/Doc/library/cgi.rst
@@ -450,7 +450,9 @@
invoked as a script, the file will dump its environment and the contents of the
form in HTML form. Give it the right mode etc, and send it a request. If it's
installed in the standard :file:`cgi-bin` directory, it should be possible to
-send it a request by entering a URL into your browser of the form::
+send it a request by entering a URL into your browser of the form:
+
+.. code-block:: none
http://yourhostname/cgi-bin/cgi.py?name=Joe+Blow&addr=At+Home
@@ -542,4 +544,3 @@
field values should be supplied in, but knowing whether a request was
received from a conforming browser, or even from a browser at all, is tedious
and error-prone.
-
diff --git a/Doc/library/doctest.rst b/Doc/library/doctest.rst
index 4558123..43be33e 100644
--- a/Doc/library/doctest.rst
+++ b/Doc/library/doctest.rst
@@ -91,14 +91,18 @@
doctest.testmod()
If you run :file:`example.py` directly from the command line, :mod:`doctest`
-works its magic::
+works its magic:
+
+.. code-block:: shell-session
$ python example.py
$
There's no output! That's normal, and it means all the examples worked. Pass
``-v`` to the script, and :mod:`doctest` prints a detailed log of what
-it's trying, and prints a summary at the end::
+it's trying, and prints a summary at the end:
+
+.. code-block:: shell-session
$ python example.py -v
Trying:
@@ -117,7 +121,9 @@
[1, 1, 2, 6, 24, 120]
ok
-And so on, eventually ending with::
+And so on, eventually ending with:
+
+.. code-block:: none
Trying:
factorial(1e100)
@@ -205,7 +211,9 @@
That short script executes and verifies any interactive Python examples
contained in the file :file:`example.txt`. The file content is treated as if it
were a single giant docstring; the file doesn't need to contain a Python
-program! For example, perhaps :file:`example.txt` contains this::
+program! For example, perhaps :file:`example.txt` contains this:
+
+.. code-block:: none
The ``example`` module
======================
diff --git a/Doc/library/htmlparser.rst b/Doc/library/htmlparser.rst
index e73ce07..6740b43 100644
--- a/Doc/library/htmlparser.rst
+++ b/Doc/library/htmlparser.rst
@@ -78,7 +78,9 @@
parser.feed('<html><head><title>Test</title></head>'
'<body><h1>Parse me!</h1></body></html>')
-The output will then be::
+The output will then be:
+
+.. code-block:: none
Encountered a start tag: html
Encountered a start tag: head
diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst
index 84805ff..729ca6e 100644
--- a/Doc/library/idle.rst
+++ b/Doc/library/idle.rst
@@ -520,7 +520,7 @@
Command line usage
^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: none
idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...
diff --git a/Doc/library/logging.config.rst b/Doc/library/logging.config.rst
index 5460c3a..23333ed 100644
--- a/Doc/library/logging.config.rst
+++ b/Doc/library/logging.config.rst
@@ -209,7 +209,9 @@
handler.
All *other* keys are passed through as keyword arguments to the
- handler's constructor. For example, given the snippet::
+ handler's constructor. For example, given the snippet:
+
+ .. code-block:: yaml
handlers:
console:
@@ -318,7 +320,9 @@
configuration to indicate that a connection exists between the source
and the destination object with that id.
-So, for example, consider the following YAML snippet::
+So, for example, consider the following YAML snippet:
+
+.. code-block:: yaml
formatters:
brief:
@@ -375,7 +379,9 @@
configuration dictionary and which returns the instantiated object.
This is signalled by an absolute import path to the factory being
made available under the special key ``'()'``. Here's a concrete
-example::
+example:
+
+.. code-block:: yaml
formatters:
brief:
@@ -592,7 +598,9 @@
:func:`dictConfig`, so it's worth considering transitioning to this newer
API when it's convenient to do so.
-Examples of these sections in the file are given below. ::
+Examples of these sections in the file are given below.
+
+.. code-block:: ini
[loggers]
keys=root,log02,log03,log04,log05,log06,log07
@@ -604,7 +612,9 @@
keys=form01,form02,form03,form04,form05,form06,form07,form08,form09
The root logger must specify a level and a list of handlers. An example of a
-root logger section is given below. ::
+root logger section is given below.
+
+.. code-block:: ini
[logger_root]
level=NOTSET
@@ -621,7 +631,9 @@
file.
For loggers other than the root logger, some additional information is required.
-This is illustrated by the following example. ::
+This is illustrated by the following example.
+
+.. code-block:: ini
[logger_parser]
level=DEBUG
@@ -639,7 +651,8 @@
say the name used by the application to get the logger.
Sections which specify handler configuration are exemplified by the following.
-::
+
+.. code-block:: ini
[handler_hand01]
class=StreamHandler
@@ -663,7 +676,9 @@
The ``args`` entry, when :func:`eval`\ uated in the context of the ``logging``
package's namespace, is the list of arguments to the constructor for the handler
class. Refer to the constructors for the relevant handlers, or to the examples
-below, to see how typical entries are constructed. ::
+below, to see how typical entries are constructed.
+
+.. code-block:: ini
[handler_hand02]
class=FileHandler
@@ -714,7 +729,9 @@
formatter=form09
args=('localhost:9022', '/log', 'GET')
-Sections which specify formatter configuration are typified by the following. ::
+Sections which specify formatter configuration are typified by the following.
+
+.. code-block:: ini
[formatter_form01]
format=F1 %(asctime)s %(levelname)s %(message)s
@@ -750,5 +767,3 @@
Module :mod:`logging.handlers`
Useful handlers included with the logging module.
-
-
diff --git a/Doc/library/optparse.rst b/Doc/library/optparse.rst
index c1ed15b..5466462 100644
--- a/Doc/library/optparse.rst
+++ b/Doc/library/optparse.rst
@@ -680,7 +680,9 @@
this option on the command line, it expands your ``version`` string (by
replacing ``%prog``), prints it to stdout, and exits.
-For example, if your script is called ``/usr/bin/foo``::
+For example, if your script is called ``/usr/bin/foo``:
+
+.. code-block:: shell-session
$ /usr/bin/foo --version
foo 1.0
@@ -730,14 +732,18 @@
error status 2.
Consider the first example above, where the user passes ``4x`` to an option
-that takes an integer::
+that takes an integer:
+
+.. code-block:: shell-session
$ /usr/bin/foo -n 4x
Usage: foo [options]
foo: error: option -n: invalid integer value: '4x'
-Or, where the user fails to pass a value at all::
+Or, where the user fails to pass a value at all:
+
+.. code-block:: shell-session
$ /usr/bin/foo -n
Usage: foo [options]
diff --git a/Doc/library/pyexpat.rst b/Doc/library/pyexpat.rst
index bb0da9d..ffa042b 100644
--- a/Doc/library/pyexpat.rst
+++ b/Doc/library/pyexpat.rst
@@ -87,7 +87,9 @@
separator.
For example, if *namespace_separator* is set to a space character (``' '``) and
- the following document is parsed::
+ the following document is parsed:
+
+ .. code-block:: xml
<?xml version="1.0"?>
<root xmlns = "http://default-namespace.org/"
diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst
index 2bf9680..527cbd0 100644
--- a/Doc/library/shutil.rst
+++ b/Doc/library/shutil.rst
@@ -342,7 +342,9 @@
>>> make_archive(archive_name, 'gztar', root_dir)
'/Users/tarek/myarchive.tar.gz'
-The resulting archive contains::
+The resulting archive contains:
+
+.. code-block:: shell-session
$ tar -tzvf /Users/tarek/myarchive.tar.gz
drwx------ tarek/staff 0 2010-02-01 16:23:40 ./
diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst
index a7c3e3e..a81214e 100644
--- a/Doc/library/socketserver.rst
+++ b/Doc/library/socketserver.rst
@@ -481,7 +481,9 @@
The output of the example should look something like this:
-Server::
+Server:
+
+.. code-block:: shell-session
$ python TCPServer.py
127.0.0.1 wrote:
@@ -489,7 +491,9 @@
127.0.0.1 wrote:
python is nice
-Client::
+Client:
+
+.. code-block:: shell-session
$ python TCPClient.py hello world with TCP
Sent: hello world with TCP
@@ -604,7 +608,9 @@
server.server_close()
-The output of the example should look something like this::
+The output of the example should look something like this:
+
+.. code-block:: shell-session
$ python ThreadedTCPServer.py
Server loop running in thread: Thread-1
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index 86a42ae..1bb3ac1 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -706,20 +706,23 @@
Replacing /bin/sh shell backquote
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: bash
output=`mycmd myarg`
- # becomes
- output = check_output(["mycmd", "myarg"])
+becomes::
+
+ output = check_output(["mycmd", "myarg"])
Replacing shell pipeline
^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: bash
output=`dmesg | grep hda`
- # becomes
+
+becomes::
+
p1 = Popen(["dmesg"], stdout=PIPE)
p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits.
@@ -729,10 +732,14 @@
to receive a SIGPIPE if p2 exits before p1.
Alternatively, for trusted input, the shell's own pipeline support may still
-be used directly::
+be used directly:
+
+.. code-block:: bash
output=`dmesg | grep hda`
- # becomes
+
+becomes::
+
output=check_output("dmesg | grep hda", shell=True)
diff --git a/Doc/library/zipimport.rst b/Doc/library/zipimport.rst
index 91305f6..e43f2a6 100644
--- a/Doc/library/zipimport.rst
+++ b/Doc/library/zipimport.rst
@@ -149,7 +149,9 @@
--------
Here is an example that imports a module from a ZIP archive - note that the
-:mod:`zipimport` module is not explicitly used. ::
+:mod:`zipimport` module is not explicitly used.
+
+.. code-block:: shell-session
$ unzip -l example.zip
Archive: example.zip
diff --git a/Doc/reference/lexical_analysis.rst b/Doc/reference/lexical_analysis.rst
index 94b003c..9f69ef7 100644
--- a/Doc/reference/lexical_analysis.rst
+++ b/Doc/reference/lexical_analysis.rst
@@ -715,7 +715,10 @@
.. index:: single: operators
-The following tokens are operators::
+The following tokens are operators:
+
+.. code-block:: none
+
+ - * ** / // %
<< >> & | ^ ~
@@ -732,7 +735,9 @@
.. index:: single: delimiters
-The following tokens serve as delimiters in the grammar::
+The following tokens serve as delimiters in the grammar:
+
+.. code-block:: none
( ) [ ] { } @
, : . ` = ;
@@ -745,14 +750,18 @@
but also perform an operation.
The following printing ASCII characters have special meaning as part of other
-tokens or are otherwise significant to the lexical analyzer::
+tokens or are otherwise significant to the lexical analyzer:
+
+.. code-block:: none
' " # \
.. index:: single: ASCII@ASCII
The following printing ASCII characters are not used in Python. Their
-occurrence outside string literals and comments is an unconditional error::
+occurrence outside string literals and comments is an unconditional error:
+
+.. code-block:: none
$ ?
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index 2af60d0..e1ac89f 100644
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -473,7 +473,9 @@
client="John Cleese",
sketch="Cheese Shop Sketch")
-and of course it would print::
+and of course it would print:
+
+.. code-block:: none
-- Do you have any Limburger ?
-- I'm sorry, we're all out of Limburger
diff --git a/Doc/tutorial/interpreter.rst b/Doc/tutorial/interpreter.rst
index 5f37504..50e50c7 100644
--- a/Doc/tutorial/interpreter.rst
+++ b/Doc/tutorial/interpreter.rst
@@ -93,7 +93,9 @@
usually three greater-than signs (``>>>``); for continuation lines it prompts
with the *secondary prompt*, by default three dots (``...``). The interpreter
prints a welcome message stating its version number and a copyright notice
-before printing the first prompt::
+before printing the first prompt:
+
+.. code-block:: shell-session
python
Python 2.7 (#1, Feb 28 2010, 00:02:06)
diff --git a/Doc/tutorial/modules.rst b/Doc/tutorial/modules.rst
index 7b6fd9c..0ef07a3 100644
--- a/Doc/tutorial/modules.rst
+++ b/Doc/tutorial/modules.rst
@@ -135,7 +135,9 @@
you can make the file usable as a script as well as an importable module,
because the code that parses the command line only runs if the module is
-executed as the "main" file::
+executed as the "main" file:
+
+.. code-block:: shell-session
$ python fibo.py 50
1 1 2 3 5 8 13 21 34
diff --git a/Doc/whatsnew/2.3.rst b/Doc/whatsnew/2.3.rst
index 1d63663..9e52200 100644
--- a/Doc/whatsnew/2.3.rst
+++ b/Doc/whatsnew/2.3.rst
@@ -291,7 +291,9 @@
The new :mod:`zipimport` module adds support for importing modules from a ZIP-
format archive. You don't need to import the module explicitly; it will be
automatically imported if a ZIP archive's filename is added to ``sys.path``.
-For example::
+For example:
+
+.. code-block:: shell-session
amk@nyman:~/src/python$ unzip -l /tmp/example.zip
Archive: /tmp/example.zip
@@ -1761,7 +1763,9 @@
strings containing the remaining arguments.
Invoking the script with the various arguments now works as you'd expect it to.
-Note that the length argument is automatically converted to an integer. ::
+Note that the length argument is automatically converted to an integer.
+
+.. code-block:: shell-session
$ ./python opt.py -i data arg1
<Values at 0x400cad4c: {'input': 'data', 'length': None}>
@@ -1771,7 +1775,9 @@
[]
$
-The help message is automatically generated for you::
+The help message is automatically generated for you:
+
+.. code-block:: shell-session
$ ./python opt.py --help
usage: opt.py [options]
@@ -2078,4 +2084,3 @@
MacIntyre, Lalo Martins, Chad Netzer, Gustavo Niemeyer, Neal Norwitz, Hans
Nowak, Chris Reedy, Francesco Ricciardi, Vinay Sajip, Neil Schemenauer, Roman
Suzi, Jason Tishler, Just van Rossum.
-
diff --git a/Doc/whatsnew/2.4.rst b/Doc/whatsnew/2.4.rst
index 5555e7d..6081000 100644
--- a/Doc/whatsnew/2.4.rst
+++ b/Doc/whatsnew/2.4.rst
@@ -1425,7 +1425,9 @@
print word
Running the above function's tests with :const:`doctest.REPORT_UDIFF` specified,
-you get the following output::
+you get the following output:
+
+.. code-block:: none
**********************************************************************
File "t.py", line 15, in g
diff --git a/Doc/whatsnew/2.7.rst b/Doc/whatsnew/2.7.rst
index c391389..cd97a3c 100644
--- a/Doc/whatsnew/2.7.rst
+++ b/Doc/whatsnew/2.7.rst
@@ -2266,7 +2266,9 @@
written in pure Python could cause a segmentation fault by taking a
:c:type:`PyCObject` from module A and somehow substituting it for the
:c:type:`PyCObject` in module B. Capsules know their own name,
-and getting the pointer requires providing the name::
+and getting the pointer requires providing the name:
+
+.. code-block:: c
void *vtable;
@@ -2705,4 +2707,3 @@
suggestions, corrections and assistance with various drafts of this
article: Nick Coghlan, Philip Jenvey, Ryan Lovett, R. David Murray,
Hugh Secker-Walker.
-