Skip to content

Commit 46936d5

Browse files
Improve highlighting of some code blocks. (GH-6401)
1 parent 9265dd7 commit 46936d5

29 files changed

+301
-137
lines changed

Doc/distutils/configfile.rst

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ consequences:
3636
* installers can override anything in :file:`setup.cfg` using the command-line
3737
options to :file:`setup.py`
3838

39-
The basic syntax of the configuration file is simple::
39+
The basic syntax of the configuration file is simple:
40+
41+
.. code-block:: ini
4042
4143
[command]
4244
option=value
@@ -51,9 +53,11 @@ option values can be split across multiple lines simply by indenting the
5153
continuation lines.
5254

5355
You can find out the list of options supported by a particular command with the
54-
universal :option:`!--help` option, e.g. ::
56+
universal :option:`!--help` option, e.g.
57+
58+
.. code-block:: shell-session
5559
56-
> python setup.py --help build_ext
60+
$ python setup.py --help build_ext
5761
[...]
5862
Options for 'build_ext' command:
5963
--build-lib (-b) directory for compiled extension modules
@@ -75,14 +79,18 @@ For example, say you want your extensions to be built "in-place"---that is, you
7579
have an extension :mod:`pkg.ext`, and you want the compiled extension file
7680
(:file:`ext.so` on Unix, say) to be put in the same source directory as your
7781
pure Python modules :mod:`pkg.mod1` and :mod:`pkg.mod2`. You can always use the
78-
:option:`!--inplace` option on the command-line to ensure this::
82+
:option:`!--inplace` option on the command-line to ensure this:
83+
84+
.. code-block:: sh
7985
8086
python setup.py build_ext --inplace
8187
8288
But this requires that you always specify the :command:`build_ext` command
8389
explicitly, and remember to provide :option:`!--inplace`. An easier way is to
8490
"set and forget" this option, by encoding it in :file:`setup.cfg`, the
85-
configuration file for this distribution::
91+
configuration file for this distribution:
92+
93+
.. code-block:: ini
8694
8795
[build_ext]
8896
inplace=1
@@ -103,7 +111,9 @@ information comes from the setup script, and some is automatically generated by
103111
the Distutils (such as the list of files installed). But some of it has to be
104112
supplied as options to :command:`bdist_rpm`, which would be very tedious to do
105113
on the command-line for every run. Hence, here is a snippet from the Distutils'
106-
own :file:`setup.cfg`::
114+
own :file:`setup.cfg`:
115+
116+
.. code-block:: ini
107117
108118
[bdist_rpm]
109119
release = 1

Doc/distutils/packageindex.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ The :command:`register` and :command:`upload` commands both check for the
156156
existence of a :file:`.pypirc` file at the location :file:`$HOME/.pypirc`.
157157
If this file exists, the command uses the username, password, and repository
158158
URL configured in the file. The format of a :file:`.pypirc` file is as
159-
follows::
159+
follows:
160+
161+
.. code-block:: ini
160162
161163
[distutils]
162164
index-servers =
@@ -179,7 +181,9 @@ Each section describing a repository defines three variables:
179181
will be prompt to type it when needed.
180182

181183
If you want to define another server a new section can be created and
182-
listed in the *index-servers* variable::
184+
listed in the *index-servers* variable:
185+
186+
.. code-block:: ini
183187
184188
[distutils]
185189
index-servers =

Doc/extending/embedding.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ options. In this case, the :mod:`sysconfig` module is a useful tool to
323323
programmatically extract the configuration values that you will want to
324324
combine together. For example:
325325

326-
.. code-block:: python
326+
.. code-block:: pycon
327327
328328
>>> import sysconfig
329329
>>> sysconfig.get_config_var('LIBS')

Doc/extending/extending.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ Let's create an extension module called ``spam`` (the favorite food of Monty
4343
Python fans...) and let's say we want to create a Python interface to the C
4444
library function :c:func:`system` [#]_. This function takes a null-terminated
4545
character string as argument and returns an integer. We want this function to
46-
be callable from Python as follows::
46+
be callable from Python as follows:
47+
48+
.. code-block:: pycon
4749
4850
>>> import spam
4951
>>> status = spam.system("ls -l")
@@ -439,7 +441,9 @@ part of the Python interpreter, you will have to change the configuration setup
439441
and rebuild the interpreter. Luckily, this is very simple on Unix: just place
440442
your file (:file:`spammodule.c` for example) in the :file:`Modules/` directory
441443
of an unpacked source distribution, add a line to the file
442-
:file:`Modules/Setup.local` describing your file::
444+
:file:`Modules/Setup.local` describing your file:
445+
446+
.. code-block:: sh
443447
444448
spam spammodule.o
445449
@@ -450,7 +454,9 @@ subdirectory, but then you must first rebuild :file:`Makefile` there by running
450454
:file:`Setup` file.)
451455

452456
If your module requires additional libraries to link with, these can be listed
453-
on the line in the configuration file as well, for instance::
457+
on the line in the configuration file as well, for instance:
458+
459+
.. code-block:: sh
454460
455461
spam spammodule.o -lX11
456462

Doc/extending/newtypes_tutorial.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ field mentioned above. ::
117117
The name of our type. This will appear in the default textual representation of
118118
our objects and in some error messages, for example:
119119

120-
.. code-block:: python
120+
.. code-block:: pycon
121121
122122
>>> "" + custom.Custom()
123123
Traceback (most recent call last):
@@ -183,7 +183,7 @@ set to *NULL*. ::
183183
This adds the type to the module dictionary. This allows us to create
184184
:class:`Custom` instances by calling the :class:`Custom` class:
185185

186-
.. code-block:: python
186+
.. code-block:: pycon
187187
188188
>>> import custom
189189
>>> mycustom = custom.Custom()
@@ -655,7 +655,7 @@ Python has a :term:`cyclic garbage collector (GC) <garbage collection>` that
655655
can identify unneeded objects even when their reference counts are not zero.
656656
This can happen when objects are involved in cycles. For example, consider:
657657

658-
.. code-block:: python
658+
.. code-block:: pycon
659659
660660
>>> l = []
661661
>>> l.append(l)
@@ -672,7 +672,7 @@ Besides, in the second and third versions, we allowed subclassing
672672
:class:`Custom`, and subclasses may add arbitrary attributes. For any of
673673
those two reasons, :class:`Custom` objects can participate in cycles:
674674

675-
.. code-block:: python
675+
.. code-block:: pycon
676676
677677
>>> import custom3
678678
>>> class Derived(custom3.Custom): pass
@@ -796,7 +796,7 @@ built-in :class:`list` type. The new type will be completely compatible with
796796
regular lists, but will have an additional :meth:`increment` method that
797797
increases an internal counter:
798798

799-
.. code-block:: python
799+
.. code-block:: pycon
800800
801801
>>> import sublist
802802
>>> s = sublist.SubList(range(3))

Doc/faq/library.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ interpreter.
7474

7575
Occasionally, a user's environment is so full that the :program:`/usr/bin/env`
7676
program fails; or there's no env program at all. In that case, you can try the
77-
following hack (due to Alex Rezinsky)::
77+
following hack (due to Alex Rezinsky):
78+
79+
.. code-block:: sh
7880
7981
#! /bin/sh
8082
""":"

Doc/faq/windows.rst

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
:tocdepth: 2
22

3+
.. highlightlang:: none
4+
35
.. _windows-faq:
46

57
=====================
@@ -39,12 +41,16 @@ or "Command prompt window". Usually you can create such a window from your
3941
Start menu; under Windows 7 the menu selection is :menuselection:`Start -->
4042
Programs --> Accessories --> Command Prompt`. You should be able to recognize
4143
when you have started such a window because you will see a Windows "command
42-
prompt", which usually looks like this::
44+
prompt", which usually looks like this:
45+
46+
.. code-block:: doscon
4347
4448
C:\>
4549
4650
The letter may be different, and there might be other things after it, so you
47-
might just as easily see something like::
51+
might just as easily see something like:
52+
53+
.. code-block:: doscon
4854
4955
D:\YourName\Projects\Python>
5056
@@ -60,11 +66,15 @@ program. So, how do you arrange for the interpreter to handle your Python?
6066
First, you need to make sure that your command window recognises the word
6167
"python" as an instruction to start the interpreter. If you have opened a
6268
command window, you should try entering the command ``python`` and hitting
63-
return::
69+
return:
70+
71+
.. code-block:: doscon
6472
6573
C:\Users\YourName> python
6674
67-
You should then see something like::
75+
You should then see something like:
76+
77+
.. code-block:: pycon
6878
6979
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32
7080
Type "help", "copyright", "credits" or "license" for more information.
@@ -73,7 +83,9 @@ You should then see something like::
7383
You have started the interpreter in "interactive mode". That means you can enter
7484
Python statements or expressions interactively and have them executed or
7585
evaluated while you wait. This is one of Python's strongest features. Check it
76-
by entering a few expressions of your choice and seeing the results::
86+
by entering a few expressions of your choice and seeing the results:
87+
88+
.. code-block:: pycon
7789
7890
>>> print("Hello")
7991
Hello
@@ -317,7 +329,9 @@ present, and ``getch()`` which gets one character without echoing it.
317329
How do I emulate os.kill() in Windows?
318330
--------------------------------------
319331

320-
Prior to Python 2.7 and 3.2, to terminate a process, you can use :mod:`ctypes`::
332+
Prior to Python 2.7 and 3.2, to terminate a process, you can use :mod:`ctypes`:
333+
334+
.. code-block:: python
321335
322336
import ctypes
323337

0 commit comments

Comments
 (0)