How to name or number code-block in reStructuredText and Sphinx? -


i line auto number code-blocks in restructuredtext, if auto numbering not possible name/number them manually.

.. code-block:: python     :name: super awesome code exaple no 5     = 1 

when in training can reference them , tell students on witch example work on. don't need reference them in document itself.

is possible in way? out of box or extending sphinx?

it possible via extending sphinx.

you have create own extension (see how create extension , where put own extension) implement new custom directive (see how create directive).

directives usual python classes, namedcodeblock directive class should extend codeblock directive class (see sphinx.directives.code.codeblock) , add support name optional argument able set names code blocks.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -