]> granicus.if.org Git - python/commitdiff
Issue #26462: Doc: avoid literal_block warnings, fix syntax highlighting.
authorMartin Panter <vadmium+py@gmail.com>
Tue, 26 Jul 2016 09:18:21 +0000 (11:18 +0200)
committerMartin Panter <vadmium+py@gmail.com>
Tue, 26 Jul 2016 09:18:21 +0000 (11:18 +0200)
Patch by Julien Palard.

31 files changed:
Doc/distutils/packageindex.rst
Doc/extending/building.rst
Doc/extending/embedding.rst
Doc/extending/extending.rst
Doc/extending/newtypes.rst
Doc/faq/extending.rst
Doc/howto/logging-cookbook.rst
Doc/howto/logging.rst
Doc/howto/regex.rst
Doc/howto/unicode.rst
Doc/library/2to3.rst
Doc/library/argparse.rst
Doc/library/ast.rst
Doc/library/cgi.rst
Doc/library/doctest.rst
Doc/library/htmlparser.rst
Doc/library/idle.rst
Doc/library/logging.config.rst
Doc/library/optparse.rst
Doc/library/pyexpat.rst
Doc/library/shutil.rst
Doc/library/socketserver.rst
Doc/library/subprocess.rst
Doc/library/zipimport.rst
Doc/reference/lexical_analysis.rst
Doc/tutorial/controlflow.rst
Doc/tutorial/interpreter.rst
Doc/tutorial/modules.rst
Doc/whatsnew/2.3.rst
Doc/whatsnew/2.4.rst
Doc/whatsnew/2.7.rst

index 74944953a6d68627655e43b26de9fe08c122572b..80875845f6807d7547b2d1e9c4df482251158111 100644 (file)
@@ -235,7 +235,9 @@ in the root of the package besides :file:`setup.py`.
 
 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
 
index 656af88131b57ab5248ac91c7a85b7cf9208c8d9..f32192bd535efa7402a812fe9f3db3b328d6038f 100644 (file)
@@ -24,7 +24,9 @@ packages, users don't necessarily need a compiler and distutils to install the
 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 @@ file, :file:`demo.c`.
 
 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 @@ commands can be used to do so. ::
    python setup.py bdist_wininst
    python setup.py bdist_rpm
    python setup.py bdist_dumb
-
index 981e1d546e6dddd65561bcf7a5ac264ab54d4326..2330cdbc208f1efbf76b75afc6597d4450144556 100644 (file)
@@ -151,7 +151,9 @@ array.  If you compile and link this program (let's call the finished executable
            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 @@ available).  This script has several options, of which the following will
 be directly useful to you:
 
 * ``pythonX.Y-config --cflags`` will give you the recommended flags when
-  compiling::
+  compiling:
+
+  .. 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
+     $ /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:
+
+  .. 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
+     $ /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
index 36de32ae0a6938d53675cee8c32363fd6f672923..37abbb7266a1b28f5b07373cf25f6ad9f80d9393 100644 (file)
@@ -763,7 +763,9 @@ the format string is empty, it returns ``None``; if it contains exactly one
 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
index de1849c4a408945cb875c58a31970c56d3b12d2e..a642912b19f91439610ba2f45d5f77f247499db9 100644 (file)
@@ -223,7 +223,9 @@ That's it!  All that remains is to build it; put the above code in a file called
    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 @@ might be something like the following::
 .. [#] 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.
-
index e78da55bf0f89d692f00b7483e50261519e5a6d3..c3806457b0302217f5834b62443dc4bcd8dee5ed 100644 (file)
@@ -156,6 +156,8 @@ The easiest way to do this is to use the StringIO class in the standard library.
 
 Sample code and use for catching stdout:
 
+.. code-block:: pycon
+
    >>> class StdoutCatcher:
    ...     def __init__(self):
    ...         self.data = ''
@@ -219,11 +221,15 @@ How do I debug an extension?
 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 @@ parameter specifications for :c:func:`PyArg_ParseTuple`.
 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'
index 074c396712f6dd8129d314837c7466fe3b3cd501..b7f0fa58780de9e2188c88b65b3920e01fc59cd8 100644 (file)
@@ -998,7 +998,9 @@ script, ``chowntest.py``::
     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 @@ via ``stderr`` and once via ``stdout``). After the ``with`` statement's
 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 @@ If we run the resulting script, the result is as follows::
     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.
index 5b431f0ae0388dee20c7baef71ad6496e70f9cc7..6b17b088cded00bafb2dfea62082013ca0ed8ca7 100644 (file)
@@ -106,7 +106,9 @@ A very simple example is::
    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 @@ append the variable data as arguments. For example::
    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, a console handler, and a simple formatter using Python code::
     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 @@ Here is the logging.conf file::
     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 @@ take up any memory.
       Useful handlers included with the logging module.
 
    :ref:`A logging cookbook <logging-cookbook>`
-
index 2c95fb425c1cbf48d2962a45066b67f158d5e452..0d0e9f56093d67f3ace58040dedd440530416163 100644 (file)
@@ -79,7 +79,9 @@ of the RE by repeating them or changing their meaning.  Much of this document is
 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
 
    . ^ $ * + ? { } [ ] \ | ( )
 
index afd89c7a372733d0ff1d9f24353307c9eb3bc28c..b94e5b5636203b6632c0214f5ace4a742639675a 100644 (file)
@@ -619,7 +619,9 @@ default filesystem encoding is UTF-8, running the following program::
    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', ...]
index 9f59ddad867dd334d5871b94e04b765e54051920..84966760564edd0515516e8685e82efffe0ae25c 100644 (file)
@@ -33,14 +33,18 @@ Here is a sample Python 2.x source file, :file:`example.py`::
    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 @@ Comments and exact indentation are preserved throughout the translation process.
 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 @@ This option implies the :option:`-w` flag as it would not make sense otherwise.
 
 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 @@ Will cause a converted file named ``example.py3`` to be written.
 .. 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
 
index 1dfebc204096589a22eb02f3c1583d3f5fb25cee..bdc699f6b98c9362c290cc61395c10f84a11f2e9 100644 (file)
@@ -44,7 +44,9 @@ produces either the sum or the max::
    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 @@ be run at the command line and provides useful help messages::
     --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 @@ the command-line integers::
    $ 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 @@ invoked on the command line.  For example, consider a file named
    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 @@ the parser's help message. For example, consider a file named
    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]
index cf0c32e463fee5abef26810120bffe319a323e32..6d5855b52bcce3df4fa9394574e2831da5047411 100644 (file)
@@ -113,6 +113,7 @@ Subversion revision number of the file shown below.
 The abstract grammar is currently defined as follows:
 
 .. literalinclude:: ../../Parser/Python.asdl
+   :language: none
 
 
 :mod:`ast` Helpers
index da15e003b808dd74ec1818759a43542f9f432cb3..1bfdb39067849293444ac6a49c64c60eb401c904 100644 (file)
@@ -450,7 +450,9 @@ installing a copy of this module file (:file:`cgi.py`) as a CGI script.  When
 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 @@ Common problems and solutions
    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.
-
index 45581239fb60d2978a44d58b08fef78a7fc580a5..43be33ef9e05c9fe8d8076b9ca9b9779b7734f2e 100644 (file)
@@ -91,14 +91,18 @@ Here's a complete but small example module::
        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 @@ it's trying, and prints a summary at the end::
        [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 @@ file.  This can be done with the :func:`testfile` function::
 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
    ======================
index e73ce07745ac7aebd43c8dd3f5abd29c323f71cb..6740b43367fa531a41fa315b64802c4816a314d1 100644 (file)
@@ -78,7 +78,9 @@ as they are encountered::
    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
index 84805ff21d23762526107dbdc41385c02ba2e4ee..729ca6e89cf07f4f6fec7d1cf72ca12ac91cee0b 100644 (file)
@@ -520,7 +520,7 @@ functions to be used from IDLE's Python shell.
 Command line usage
 ^^^^^^^^^^^^^^^^^^
 
-::
+.. code-block:: none
 
    idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...
 
index 5460c3ad45447931dce4d749db94ff59ec2f9be0..23333ed688551ae08657f30c6e3df1ce3310ec02 100644 (file)
@@ -209,7 +209,9 @@ otherwise, the context is used to determine what to instantiate.
     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 @@ it unambiguously, and then using the id in the source object's
 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 @@ to provide a 'factory' - a callable which is called with a
 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 @@ configuration must be specified in a section called ``[logger_root]``.
    :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 @@ Examples of these sections in the file are given below. ::
    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 @@ appear in the ``[handlers]`` section. These names must appear in the
 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 @@ indicate that messages are **not** propagated to handlers up the hierarchy. The
 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 @@ a corresponding section in the configuration file.
 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 @@ below, to see how typical entries are constructed. ::
    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 @@ condensed format.
 
    Module :mod:`logging.handlers`
       Useful handlers included with the logging module.
-
-
index c1ed15b0b606394a75f7cd8cc9eb35e0bd3af855..54664622b5bbcb452eb4a16e09f2218e6296a01b 100644 (file)
@@ -680,7 +680,9 @@ automatically adds a ``--version`` option to your parser. If it encounters
 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 @@ program's usage message and an error message to standard error and exits with
 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]
index bb0da9dc16ae4558672515479d84f28e37c8c3e3..ffa042b7bcab1d211577df2b7cbfeafa380cee92 100644 (file)
@@ -87,7 +87,9 @@ The :mod:`xml.parsers.expat` module contains two functions:
    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/"
index 2bf9680e97110807c3b9e6440e3363df2ee5e040..527cbd0648bf2e326ee664c7755ee6c517ad806c 100644 (file)
@@ -342,7 +342,9 @@ found in the :file:`.ssh` directory of the user::
     >>> 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 ./
index a7c3e3e96973f0d897467e4321229aa2d7e0ec31..a81214e906c5dcbd6f4ee3c91415dd09992c8c7f 100644 (file)
@@ -481,7 +481,9 @@ This is the client side::
 
 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 @@ Server::
    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 @@ An example for the :class:`ThreadingMixIn` class::
        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
index 86a42aed9633f40ee96fff7d8a3ea7775fe5c61f..1bb3ac10cd4a9191d94ef04393220ce947242ee1 100644 (file)
@@ -706,20 +706,23 @@ been imported from the :mod:`subprocess` module.
 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 @@ The p1.stdout.close() call after starting the p2 is important in order for p1
 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)
 
 
index 91305f6d52ee0963f898111a08229e7226292a9c..e43f2a6a9baf0fe86d91f5da27d7968b7f862746 100644 (file)
@@ -149,7 +149,9 @@ Examples
 --------
 
 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
index 94b003c5c44cfd3e7195ed4fea70402afc9978f8..9f69ef7c8debdb76eb410c890229fa6806152776 100644 (file)
@@ -715,7 +715,10 @@ Operators
 
 .. index:: single: operators
 
-The following tokens are operators::
+The following tokens are operators:
+
+.. code-block:: none
+
 
    +       -       *       **      /       //      %
    <<      >>      &       |       ^       ~
@@ -732,7 +735,9 @@ Delimiters
 
 .. 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 @@ of the list, the augmented assignment operators, serve lexically as delimiters,
 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
 
    $       ?
 
index 2af60d035e5c5b68e43efbefd6d94f08250f7e2c..e1ac89f5e2d658e8b572d777334615dfd2722caf 100644 (file)
@@ -473,7 +473,9 @@ It could be called like this::
               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
index 5f375048f0aae49b5c68b5f2b3eb1ed02021a7e1..50e50c77015df26a8b2aa1dd02262f5aca0d143d 100644 (file)
@@ -93,7 +93,9 @@ mode*.  In this mode it prompts for the next command with the *primary prompt*,
 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)
index 7b6fd9cfbedfd7d77fa4187b4e2b8b6a70ff1a0a..0ef07a3c786a4ffe7350b27af8d71cdcda404e4f 100644 (file)
@@ -135,7 +135,9 @@ the end of your module::
 
 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
index 1d63663d6858c2f1770e3cda491db4c53b8b7c74..9e52200e447e766e6b94c2a6c50c2c3e7072c46b 100644 (file)
@@ -291,7 +291,9 @@ PEP 273: Importing Modules from ZIP Archives
 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 @@ This returns an object containing all of the option values, and a list of
 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 @@ Note that the length argument is automatically converted to an integer. ::
    []
    $
 
-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 @@ Michael Hudson, Chris Lambert, Detlef Lannert, Martin von Löwis, Andrew
 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.
-
index 5555e7dd47198f11ba3214767bd6336c48c4cb08..6081000e533c2057e44f8415fece3b543085945b 100644 (file)
@@ -1425,7 +1425,9 @@ specifying the :const:`doctest.REPORT_UDIFF` (unified diffs),
            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
index c391389f03f0ed240dfcff9a2881cbc89df3dd18..cd97a3caa968fdb3eb7268dfce9c595c5febb51b 100644 (file)
@@ -2266,7 +2266,9 @@ There is an existing data type already used for this,
 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 @@ The author would like to thank the following people for offering
 suggestions, corrections and assistance with various drafts of this
 article: Nick Coghlan, Philip Jenvey, Ryan Lovett, R. David Murray,
 Hugh Secker-Walker.
-