rest_example¶
Directive to show example reStructuredText and the rendered output.
Enable sphinx_toolbox.rest_example by adding the following
to the extensions variable in your conf.py:
extensions = [
...
'sphinx_toolbox.rest_example',
]
For more information see https://www.sphinx-doc.org/en/master/usage/extensions#third-party-extensions .
Usage¶
-
.. rest-example::¶ Directive to show example reStructuredText and the rendered output.
-
:force:(flag)¶ If given, minor errors on highlighting are ignored.
-
:emphasize-lines:line numbers (comma separated numbers)¶ Emphasize particular lines of the code block:
-
:tab-width:number (number)¶ Sets the size of the indentation in spaces.
-
:dedent:number (number)¶ Strip indentation characters from the code block,
Example
.. rest-example:: :source:`sphinx_toolbox/config.py` Here is the :source:`source code <sphinx_toolbox/config.py>`
:source:`sphinx_toolbox/config.py` Here is the :source:`source code <sphinx_toolbox/config.py>`
Here is the source code
-
API Reference¶
Classes:
|
Directive to show some reStructuredText source, and the rendered output. |
Functions:
|
Make the content of a reST Example node. |
|
Setup |
Data:
Purger to track rest-example nodes, and remove redundant ones. |
-
class
reSTExampleDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]¶ Bases:
SphinxDirectiveDirective to show some reStructuredText source, and the rendered output.
Methods:
run()Create the rest_example node.
-
option_spec= {'dedent': <class 'int'>, 'emphasize-lines': <function unchanged>, 'force': <function flag>, 'tab-width': <class 'int'>}¶
-
-
rest_example_purger= Purger('all_rest_example_nodes')¶ Type:
PurgerPurger to track rest-example nodes, and remove redundant ones.
-
setup(app)[source]¶ Setup
sphinx_toolbox.rest_example.New in version 0.7.0.
- Parameters:
app (
Sphinx) – The Sphinx application.- Return type: