Skip to content

Commit 6360d7f

Browse files
jeff5ezio-melotti
authored andcommitted
Use an appropriate highlight language throughout (#283)
* Use an appropriate highlight language throughout. Replace the default (Python) highlighting where a Pygments lexer is available, and use "none" elsewhere. For console commands follow the example of gitbootcamp.rst mostly ($-prompt and lang=console). * Document the highlight directive correctly. * Remove spurious prompt from quoted output. * Respect the author's decision to use $ (or not) in console text. Where the $-prompt is explicit, highlight as console, and where implicit as bash (mostly).
1 parent eb29df1 commit 6360d7f

File tree

11 files changed

+102
-42
lines changed

11 files changed

+102
-42
lines changed

buildbots.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Continuous Integration
44
======================
55

6+
.. highlight:: bash
7+
68
To assert that there are no regressions in the :doc:`development and maintenance
79
branches <devcycle>`, Python has a set of dedicated machines (called *buildbots*
810
or *build slaves*) used for continuous integration. They span a number of
@@ -107,7 +109,10 @@ The ``--randseed`` option makes it easy to reproduce the exact randomization
107109
used in a given build. Again, open the ``stdio`` link for the failing test
108110
run, and check the beginning of the test output proper.
109111

110-
Let's assume, for the sake of example, that the output starts with::
112+
Let's assume, for the sake of example, that the output starts with:
113+
114+
.. code-block:: none
115+
:emphasize-lines: 6
111116
112117
./python -Wd -E -bb Lib/test/regrtest.py -uall -rwW
113118
== CPython 3.3a0 (default:22ae2b002865, Mar 30 2011, 13:58:40) [GCC 4.4.5]
@@ -122,7 +127,9 @@ You can reproduce the exact same order using::
122127

123128
./python -Wd -E -bb -m test -uall -rwW --randseed 2613169
124129

125-
It will run the following sequence (trimmed for brevity)::
130+
It will run the following sequence (trimmed for brevity):
131+
132+
.. code-block:: none
126133
127134
[ 1/353] test_augassign
128135
[ 2/353] test_functools
@@ -140,15 +147,19 @@ sequence recorded in that text file::
140147
./python -Wd -E -bb -m test -uall -rwW --fromfile mytestsequence.txt
141148

142149
In the example sequence above, if ``test_unicode`` had failed, you would
143-
first test the following sequence::
150+
first test the following sequence:
151+
152+
.. code-block:: none
144153
145154
[ 1/353] test_augassign
146155
[ 2/353] test_functools
147156
[ 3/353] test_bool
148157
[ 6/353] test_unicode
149158
150159
And, if it succeeds, the following one instead (which, hopefully, shall
151-
fail)::
160+
fail):
161+
162+
.. code-block:: none
152163
153164
[ 4/353] test_contains
154165
[ 5/353] test_compileall
@@ -193,6 +204,8 @@ implementation, or by making its parameters - such as a timeout - more robust.
193204
Custom builders
194205
---------------
195206

207+
.. highlight:: console
208+
196209
When working on a platform-specific issue, you may want to test your changes on
197210
the buildbot fleet rather than just on Travis and AppVeyor. To do so, you can
198211
make use of the `custom builders

buildslave.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Running a buildslave
55
====================
66

7+
.. highlight:: bash
8+
79
Python's :ref:`buildbots` system was discussed earlier. We sometimes refer to
810
the collection of *build slaves* as our "buildbot fleet". The machines that
911
comprise the fleet are voluntarily contributed resources. Many are run by
@@ -135,7 +137,9 @@ For OSX:
135137
If you use pip with Apple's system python, add '/System' to the front of
136138
the path to the Python bin directory.
137139

138-
* Place a file with the following contents into ``/Library/LaunchDaemons``::
140+
* Place a file with the following contents into ``/Library/LaunchDaemons``:
141+
142+
.. code-block:: xml
139143
140144
<?xml version="1.0" encoding="UTF-8"?>
141145
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"

clang.rst

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Dynamic Analysis with Clang
33
***************************
44

5+
.. highlight:: bash
6+
57
This document describes how to use Clang to perform analysis on Python and its
68
libraries. In addition to performing the analysis, the document will cover
79
downloading, building and installing the the latest Clang/LLVM combination
@@ -95,7 +97,9 @@ Perform the following to download, build and install the Clang/LLVM 3.4. ::
9597

9698
After ``make install`` executes, the compilers will be installed in
9799
``/usr/local/bin`` and the various libraries will be installed in
98-
``/usr/local/lib/clang/3.4/lib/linux/``: ::
100+
``/usr/local/lib/clang/3.4/lib/linux/``:
101+
102+
.. code-block:: console
99103
100104
$ ls /usr/local/lib/clang/3.4/lib/linux/
101105
libclang_rt.asan-x86_64.a libclang_rt.profile-x86_64.a
@@ -105,7 +109,9 @@ After ``make install`` executes, the compilers will be installed in
105109
libclang_rt.msan-x86_64.a libclang_rt.ubsan-x86_64.a
106110
107111
On Mac OS X, the libraries are installed in
108-
``/usr/local/lib/clang/3.3/lib/darwin/``: ::
112+
``/usr/local/lib/clang/3.3/lib/darwin/``:
113+
114+
.. code-block:: console
109115
110116
$ ls /usr/local/lib/clang/3.3/lib/darwin/
111117
libclang_rt.10.4.a libclang_rt.ios.a
@@ -181,7 +187,9 @@ The ``-fno-sanitize=vptr`` removes vtable checks that are part of UBSan from C++
181187
projects due to noise. Its not needed with Python, but you will likely need it
182188
for other C++ projects.
183189

184-
After exporting ``CC`` and ``CXX``, ``configure`` as normal: ::
190+
After exporting ``CC`` and ``CXX``, ``configure`` as normal:
191+
192+
.. code-block:: console
185193
186194
$ ./configure
187195
checking build system type... x86_64-unknown-linux-gnu
@@ -194,7 +202,9 @@ After exporting ``CC`` and ``CXX``, ``configure`` as normal: ::
194202
checking whether the C compiler works... yes
195203
...
196204
197-
Next is a standard ``make`` (formatting added for clarity): ::
205+
Next is a standard ``make`` (formatting added for clarity):
206+
207+
.. code-block:: console
198208
199209
$ make
200210
/usr/local/bin/clang -fsanitize=undefined -c -Wno-unused-result
@@ -207,7 +217,9 @@ Next is a standard ``make`` (formatting added for clarity): ::
207217
Parser/acceler.c
208218
...
209219
210-
Finally is ``make test`` (formatting added for clarity): ::
220+
Finally is ``make test`` (formatting added for clarity):
221+
222+
.. code-block:: none
211223
212224
Objects/longobject.c:39:42: runtime error: index -1 out of bounds
213225
for type 'PyLongObject [262]'
@@ -221,7 +233,9 @@ Finally is ``make test`` (formatting added for clarity): ::
221233
222234
If you are using the address sanitizer, its important to pipe the output through
223235
``asan_symbolize.py`` to get a good trace. For example, from Issue 20953 during
224-
compile (formatting added for clarity): ::
236+
compile (formatting added for clarity):
237+
238+
.. code-block:: none
225239
226240
$ make test 2>&1 | asan_symbolize.py
227241
...
@@ -293,22 +307,24 @@ compile (formatting added for clarity): ::
293307
Blacklisting (Ignoring) Findings
294308
--------------------------------
295309

310+
.. highlight:: none
311+
296312
Clang allows you to alter the behavior of sanitizer tools for certain
297313
source-level by providing a special blacklist file at compile-time. The
298314
blacklist is needed because it reports every instance of an issue, even if the
299315
issue is reported 10's of thousands of time in un-managed library code.
300316

301-
You specify the blacklist with ``-fsanitize-blacklist=XXX``. For example: ::
317+
You specify the blacklist with ``-fsanitize-blacklist=XXX``. For example::
302318

303319
-fsanitize-blacklist=my_blacklist.txt
304320

305321
``my_blacklist.txt`` would then contain entries such as the following. The entry
306-
will ignore a bug in ``libc++``'s ``ios`` formatting functions: ::
322+
will ignore a bug in ``libc++``'s ``ios`` formatting functions::
307323

308324
fun:_Ios_Fmtflags
309325

310326
As an example with Python 3.4.0, ``audioop.c`` will produce a number of
311-
findings: ::
327+
findings::
312328

313329
./Modules/audioop.c:422:11: runtime error: left shift of negative value -1
314330
./Modules/audioop.c:446:19: runtime error: left shift of negative value -1
@@ -324,11 +340,11 @@ findings: ::
324340
...
325341

326342
One of the function of interest is ``audioop_getsample_impl`` (flagged at line
327-
422), and the blacklist entry would include: ::
343+
422), and the blacklist entry would include::
328344

329345
fun:audioop_getsample_imp
330346

331-
Or, you could ignore the entire file with: ::
347+
Or, you could ignore the entire file with::
332348

333349
src:Modules/audioop.c
334350

committing.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Accepting Pull Requests
44
=======================
55

6+
.. highlight:: none
7+
68
This page is aimed to core developers, and covers the steps required to
79
accept, merge, and possibly backport a pull request on the main repository.
810

compiler.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Design of CPython's Compiler
44
============================
55

6+
.. highlight:: none
67

78
Abstract
89
--------
@@ -55,9 +56,10 @@ macros (which are all defined in :file:`Include/node.h`):
5556
retrieve the line number of the source code that led to the
5657
creation of the parse rule; defined in :file:`Python/ast.c`
5758

58-
For example, consider the rule for 'while'::
59+
For example, consider the rule for 'while':
5960

60-
while_stmt: 'while' test ':' suite ['else' ':' suite]
61+
.. productionlist::
62+
while_stmt: "while" `expression` ":" `suite` : ["else" ":" `suite`]
6163

6264
The node representing this will have ``TYPE(node) == while_stmt`` and
6365
the number of children can be 4 or 7 depending on whether there is an
@@ -93,13 +95,13 @@ particular programming language.
9395
The following fragment of the Python ASDL construct demonstrates the
9496
approach and syntax::
9597

96-
module Python
97-
{
98-
stmt = FunctionDef(identifier name, arguments args, stmt* body,
99-
expr* decorators)
98+
module Python
99+
{
100+
stmt = FunctionDef(identifier name, arguments args, stmt* body,
101+
expr* decorators)
100102
| Return(expr? value) | Yield(expr? value)
101103
attributes (int lineno)
102-
}
104+
}
103105

104106
The preceding example describes two different kinds of statements and an
105107
expression: function definitions, return statements, and yield expressions.

docquality.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ that makes it harder to break the work up for multiple people to help with.
7070
Helping with the Developer's Guide
7171
----------------------------------
7272

73-
.. highlight:: bash
73+
.. highlight:: console
7474

7575
The Developer's Guide uses the same process as the main Python documentation,
7676
except for some small differences. The source lives in a `separate
@@ -90,13 +90,13 @@ Python projects is to create a virtualenv, and then install dependencies from
9090
a ``requirements.txt`` file. For your convenience, this is all *automated for
9191
you*. To build the devguide on a Unix-like system use::
9292

93-
$ make html
93+
$ make html
9494

9595
in the checkout directory. On Windows use:
9696

97-
.. code-block:: doscon
97+
.. code-block:: doscon
9898
99-
> .\make html
99+
> .\make html
100100
101101
You will find the generated files in ``_build/html``.
102102
Note that ``make check`` is automatically run when

documenting.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Documenting Python
55
==================
66

7+
.. highlight:: rest
8+
79
The Python language has a substantial body of documentation, much of it
810
contributed by various authors. The markup used for the Python documentation is
911
`reStructuredText`_, developed by the `docutils`_ project, amended by custom
@@ -810,27 +812,29 @@ preceding paragraph and delimited by indentation.
810812
Representing an interactive session requires including the prompts and output
811813
along with the Python code. No special markup is required for interactive
812814
sessions. After the last line of input or output presented, there should not be
813-
an "unused" primary prompt; this is an example of what *not* to do::
815+
an "unused" primary prompt; this is an example of what *not* to do:
816+
817+
.. code-block:: python
814818
815819
>>> 1 + 1
816820
2
817821
>>>
818822
819823
Syntax highlighting is handled in a smart way:
820824

821-
* There is a "highlighting language" for each source file. Per default,
825+
* There is a "highlighting language" for each source file. By default,
822826
this is ``'python'`` as the majority of files will have to highlight Python
823827
snippets.
824828

825829
* Within Python highlighting mode, interactive sessions are recognized
826830
automatically and highlighted appropriately.
827831

828-
* The highlighting language can be changed using the ``highlightlang``
832+
* The highlighting language can be changed using the ``highlight``
829833
directive, used as follows::
830834

831-
.. highlightlang:: c
835+
.. highlight:: c
832836

833-
This language is used until the next ``highlightlang`` directive is
837+
This language is used until the next ``highlight`` directive is
834838
encountered.
835839

836840
* The ``code-block`` directive can be used to specify the highlight language
@@ -1035,7 +1039,7 @@ in a different style:
10351039
The name of a file or directory. Within the contents, you can use curly
10361040
braces to indicate a "variable" part, for example::
10371041

1038-
... is installed in :file:`/usr/lib/python2.{x}/site-packages` ...
1042+
``spam`` is installed in :file:`/usr/lib/python2.{x}/site-packages` ...
10391043

10401044
In the built documentation, the ``x`` will be displayed differently to
10411045
indicate that it is to be replaced by the Python minor version.
@@ -1452,6 +1456,8 @@ default. They are set in the build configuration file :file:`conf.py`.
14521456
Building the documentation
14531457
==========================
14541458

1459+
.. highlight:: bash
1460+
14551461
The toolset used to build the docs is written in Python and is called Sphinx_.
14561462
Sphinx is maintained separately and is not included in this tree. Also needed
14571463
are docutils_, supplying the base markup that Sphinx uses; Jinja_, a templating

gdb.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
gdb Support
44
===========
55

6+
.. highlight:: none
7+
68
If you experience low-level problems such as crashes or deadlocks
79
(e.g. when tinkering with parts of CPython which are written in C),
810
it can be convenient to use a low-level debugger such as gdb in

index.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Python Developer's Guide
33
========================
44

5+
.. highlight:: bash
6+
57
This guide is a comprehensive resource for :ref:`contributing <contributing>`
68
to Python_ -- for both new and experienced contributors. It is
79
:ref:`maintained <helping-with-the-developers-guide>` by the same community
@@ -27,7 +29,9 @@ instructions please see the :ref:`setup guide <setup>`.
2729

2830
./configure --with-pydebug && make -j
2931

30-
and on Windows use::
32+
and on Windows use:
33+
34+
.. code-block:: dosbatch
3135

3236
PCbuild\build.bat -e -d
3337

pullrequest.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Lifecycle of a Pull Request
44
===========================
55

6+
.. highlight:: bash
67

78
Introduction
89
------------
@@ -171,9 +172,11 @@ through the common patch generation checks. To run ``patchcheck``:
171172

172173
make patchcheck
173174

174-
On *Windows* (after any successful build)::
175+
On *Windows* (after any successful build):
175176

176-
python.bat Tools/scripts/patchcheck.py
177+
.. code-block:: dosbatch
178+
179+
python.bat Tools\scripts\patchcheck.py
177180
178181
The automated patch checklist runs through:
179182

0 commit comments

Comments
 (0)