Read the Docs and Sphinx

highlight

Example:

.. highlight:: ccc

This language is used until the next highlight directive is encountered. As discussed previously, language can be any lexer alias supported by Pygments.

Additional options

Pygments can generate line numbers for code blocks. To enable this, use the linenothreshold option.

.. highlight:: python
    :linenothreshold: 5

This will produce line numbers for all code blocks longer than five lines.

To ignore minor errors on highlighting, you can specifiy :force: option.

Changed in version 2.1: :force: option.


Example-1:

The literal blocks are highlighted as HTML, until a new directive is found.

Source Code

.. highlight:: html

::

<html><head></head>
<body>This is a text.</body>
</html>

Result

<html><head></head>
<body>This is a text.</body>
</html>

End Examples

The following directive changes the hightlight language to SQL.

SELECT * FROM mytable

From here on no highlighting will be done.

SELECT * FROM mytable

rst:directive

Example:

.. rst:directive:: foo

Describes a reST directive. The name can be a single directive name or actual directive syntax (.. prefix and :: suffix) with arguments that will be rendered differently. For example:

.. rst:directive:: foo

    Foo description.

.. rst:directive:: .. bar:: baz

    Bar description.

will be rendered as:

.. foo::

Foo description.

.. bar:: baz

Bar description.

Roles

Sphinx uses interpreted text roles to insert semantic markup into documents. They are written as :rolename:`content`.

cite*

Warning

sphinxcontrib-bibtex extension is required.

:cite:

Create a citation to a bibliographic entry. For example:

See :cite:`1987:nelson` for an introduction to non-standard analysis.

which would be equivalent to the following LaTeX code:

See \cite{1987:nelson} for an introduction to non-standard analysis.

Multiple comma-separated keys can be specified at once:

See :cite:`1987:nelson,2001:schechter`.