Skip to content

Commit 1e4b4a5

Browse files
author
Zearin
committed
docs/**: Specify language for code-blocks (syntax highlighting! mmm…)
1 parent 471f86b commit 1e4b4a5

File tree

11 files changed

+58
-33
lines changed

11 files changed

+58
-33
lines changed

docs/scenarios/admin.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ latter will ssh into each server, cd to our project directory, activate the
2121
virtual environment, pull the newest codebase, and restart the application
2222
server.
2323

24-
::
24+
.. code-block:: python
2525
2626
from fabric.api import cd, env, prefix, run, task
2727

docs/scenarios/db.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ SQLAlchemy
2020
Unlike many database libraries it not only provides an ORM layer but also a
2121
generalized API for writing database-agnostic code without SQL.
2222

23-
::
23+
.. code-block:: console
2424
25-
pip install sqlalchemy
25+
$ pip install sqlalchemy
2626
2727
Django ORM
2828
----------

docs/scenarios/imaging.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ the instructions for your platform `here <https://pypi.python.org/pypi/Pillow/2.
2323

2424
After that, it's straightforward:
2525

26-
.. code-block:: bash
26+
.. code-block:: console
2727
2828
$ pip install Pillow

docs/scenarios/scrape.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ After a quick analysis, we see that in our page the data is contained in
5656
two elements - one is a div with title 'buyer-name' and the other is a
5757
span with class 'item-price':
5858

59-
::
59+
.. code-block:: html
6060

6161
<div title="buyer-name">Carson Busses</div>
6262
<span class="item-price">$29.95</span>

docs/scenarios/speed.rst

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Using a slightly modified version of `David Beazleys`_ CPU bound test code
88
(added loop for multiple tests), you can see the difference between CPython
99
and PyPy's processing.
1010

11-
::
11+
.. code-block:: console
1212
13-
PyPy
13+
# PyPy
1414
$ ./pypy -V
1515
Python 2.7.1 (7773f8fc4223, Nov 18 2011, 18:47:10)
1616
[PyPy 1.7.0 with GCC 4.4.3]
@@ -21,9 +21,9 @@ and PyPy's processing.
2121
0.0440690517426
2222
0.0695300102234
2323
24-
::
24+
.. code-block:: console
2525
26-
CPython
26+
# CPython
2727
$ ./python -V
2828
Python 2.7.1
2929
$ ./python measure2.py
@@ -72,9 +72,10 @@ Cython
7272
with which you are able to write C and C++ modules for Python. Cython also
7373
allows you to call functions from compiled C libraries. Using Cython allows
7474
you to take advantage of Python's strong typing of variables and operations.
75-
Here is an example of strong typing with Cython:
7675

77-
.. code-block:: python
76+
Here's an example of strong typing with Cython:
77+
78+
.. code-block:: cython
7879
7980
def primes(int kmax):
8081
"""Calculation of prime numbers with additional
@@ -128,7 +129,7 @@ Notice that in the Cython version you declare integers and integer arrays for
128129
to be compiled into C types while also creating a Python list:
129130

130131

131-
.. code-block:: python
132+
.. code-block:: cython
132133
133134
def primes(int kmax):
134135
"""Calculation of prime numbers with additional
@@ -190,18 +191,22 @@ The `pyximport` module allows you to import `pyx` files (e.g., `primesCy.pyx`) w
190191
The `pyximport.install()` command allows the Python interpreter to start the Cython compiler directly to generate C-code,
191192
which is automatically compiled to a `*.so` C-library. Cython is able to import this library for you in your Python-code.
192193
Very easy and very efficient. With the `time.time()` function you are able to compare the time between this 2 different calls to find 500 prime numbers.
194+
On a standard notebook (dual core AMD E-450 1.6 GHz), the measured values are:
195+
196+
.. code-block:: console
197+
198+
Cython time: 0.0054 seconds
193199
194-
On a standard notebook (dualcore AMD E-450 1,6 GHz) the measured values are:
200+
Python time: 0.0566 seconds
195201
196-
Cython time: 0.0054 seconds
197202
198-
Python time: 0.0566 seconds
199203
200204
And here the output of an embedded `ARM beaglebone <http://beagleboard.org/Products/BeagleBone>`_ machine:
205+
.. code-block:: console
201206
202-
Cython time: 0.0196 seconds
207+
Cython time: 0.0196 seconds
203208
204-
Python time: 0.3302 seconds
209+
Python time: 0.3302 seconds
205210
206211
Pyrex
207212
-----

docs/shipping/freezing.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Prerequisite is to install :ref:`Python on Windows <install-windows>`.
5959

6060
2. Write setup.py (`List of configuration options <http://www.py2exe.org/index.cgi/ListOfOptions>`_)::
6161

62+
.. code-block:: python
63+
6264
from distutils.core import setup
6365
import py2exe
6466
@@ -70,7 +72,9 @@ Prerequisite is to install :ref:`Python on Windows <install-windows>`.
7072

7173
4. (Optionally) `one-file mode <http://stackoverflow.com/questions/112698/py2exe-generate-single-executable-file#113014>`_
7274

73-
5. Generate `.exe` into `dist` directory::
75+
5. Generate ``.exe`` into ``dist`` directory:
76+
77+
.. code-block:: console
7478
7579
$ python setup.py py2exe
7680

docs/starting/install/osx.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ line at the bottom of your ``~/.bashrc`` file
5353
5454
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
5555
56-
Now, we can install Python 2.7: ::
56+
Now, we can install Python 2.7:
57+
58+
.. code-block:: console
5759
5860
$ brew install python
5961

docs/starting/install/win.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ tedious, so add the directories for your default Python version to the PATH.
2525
Assuming that your Python installation is in ``C:\Python27\``, add this to your
2626
PATH::
2727

28+
.. code-block:: console
29+
2830
C:\Python27\;C:\Python27\Scripts\
2931
30-
You can do this easily by running the following in ``powershell``::
32+
You can do this easily by running the following in ``powershell``:
33+
34+
.. code-block:: console
3135
3236
[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27\;C:\Python27\Scripts\", "User")
3337

docs/writing/documentation.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ code easier to understand. In Python, comments begin with a hash
100100

101101
.. _docstring-ref:
102102

103-
In Python, *docstrings* describe modules, classes, and functions: ::
103+
In Python, *docstrings* describe modules, classes, and functions:
104+
105+
.. code-block:: python
104106
105107
def square_and_rooter(x):
106108
"""Returns the square root of self times self."""
@@ -130,7 +132,9 @@ Docstrings versus Block comments
130132

131133
These aren't interchangeable. For a function or class, the leading
132134
comment block is a programmer's note. The docstring describes the
133-
operation of the function or class: ::
135+
*operation* of the function or class:
136+
137+
.. code-block:: python
134138
135139
# This function slows down program execution for some reason.
136140
def square_and_rooter(x):

docs/writing/style.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ Instead, use a list comprehension:
336336
four_lists = [[] for __ in xrange(4)]
337337
338338
339-
A common idiom for creating strings is to use :py:meth:`str.join` on an empty string.::
339+
A common idiom for creating strings is to use :py:meth:`str.join` on an empty string.
340+
341+
.. code-block:: python
340342
341343
letters = ['s', 'p', 'a', 'm']
342344
word = ''.join(letters)
@@ -345,7 +347,9 @@ This will set the value of the variable *word* to 'spam'. This idiom can be appl
345347

346348
Sometimes we need to search through a collection of things. Let's look at two options: lists and dictionaries.
347349

348-
Take the following code for example::
350+
Take the following code for example:
351+
352+
.. code-block:: python
349353
350354
d = {'s': [], 'p': [], 'a': [], 'm': []}
351355
l = ['s', 'p', 'a', 'm']
@@ -365,7 +369,7 @@ Zen of Python
365369

366370
Also known as :pep:`20`, the guiding principles for Python's design.
367371

368-
::
372+
.. code-block:: pycon
369373
370374
>>> import this
371375
The Zen of Python, by Tim Peters
@@ -406,14 +410,15 @@ exists a command-line program, `pep8 <https://github.com/jcrocholl/pep8>`_,
406410
that can check your code for conformance. Install it by running the following
407411
command in your Terminal:
408412

409-
::
413+
414+
.. code-block:: console
410415
411416
$ pip install pep8
412417
413418
414419
Then run it on a file or series of files to get a report of any violations.
415420

416-
::
421+
.. code-block:: console
417422
418423
$ pep8 optparse.py
419424
optparse.py:69:11: E401 multiple imports on one line

0 commit comments

Comments
 (0)