diff options
| author | Steve Piercy <web@stevepiercy.com> | 2016-11-20 22:15:19 -0800 |
|---|---|---|
| committer | Steve Piercy <web@stevepiercy.com> | 2016-11-20 22:15:19 -0800 |
| commit | ff8acd6f545ca55f9c9588ee77aee559d68ab194 (patch) | |
| tree | e2e9373180beebd8f5d8ea28c257d8b8c2110200 /docs | |
| parent | e33b2ce88af4fb6d9412757ca0ac4f6a95bfc578 (diff) | |
| download | pyramid-ff8acd6f545ca55f9c9588ee77aee559d68ab194.tar.gz pyramid-ff8acd6f545ca55f9c9588ee77aee559d68ab194.tar.bz2 pyramid-ff8acd6f545ca55f9c9588ee77aee559d68ab194.zip | |
add syntax highlighting
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/style-guide.rst | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/docs/style-guide.rst b/docs/style-guide.rst index 2304e9d6b..cb1a15be1 100644 --- a/docs/style-guide.rst +++ b/docs/style-guide.rst @@ -228,6 +228,96 @@ The directive's sole argument is interpreted as the topic title, and next line m interpreted as body elements. +.. _style-guide-syntax-highlighting: + +Syntax highlighting +^^^^^^^^^^^^^^^^^^^ + +Sphinx does syntax highlighting using the `Pygments <http://pygments.org/>`_ library. + +Do not use two colons "::" at the end of a line, followed by a blank line, then indented code. Always specify the language to be used for syntax highlighting by using the ``code-block`` directive and indenting the code. + + .. code-block:: rst + + .. code-block:: python + + if "foo" == "bar": + # This is Python code + pass + +XML: + + .. code-block:: rst + + .. code-block:: xml + + <somesnippet>Some XML</somesnippet> + +Unix shell: + + .. code-block:: rst + + .. code-block:: bash + + # Start Plone in foreground mode for a test run + cd ~/Plone/zinstance + bin/plonectl fg + +Windows console: + + .. code-block:: rst + + .. code-block:: doscon + + c:\> %VENV%\Scripts\pcreate -s starter MyProject + +cfg: + + .. code-block:: rst + + .. code-block:: cfg + + [some-part] + # A random part in the buildout + recipe = collective.recipe.foo + option = value + +ini: + + .. code-block:: rst + + .. code-block:: ini + + [nosetests] + match=^test + where=pyramid + nocapture=1 + +Interactive Python: + + .. code-block:: rst + + .. code-block:: pycon + + >>> class Foo: + ... bar = 100 + ... + >>> f = Foo() + >>> f.bar + 100 + >>> f.bar / 0 + Traceback (most recent call last): + File "<stdin>", line 1, in <module> + ZeroDivisionError: integer division or modulo by zero + +If syntax highlighting is not enabled for your code block, you probably have a syntax error and Pygments will fail silently. + +View the `full list of lexers and associated short names <http://pygments.org/docs/lexers/>`_. + + + + + Literals, filenames, and function arguments are presented using the following style: |
