XD blog

blog page

python, runpython, sphinx

2017-07-02 Include output of a script in the Python documentation

The directive runpython runs a python script and insert the output in the documentation.

.. runpython::
    import sys

Every printed information is added to the documntation :

sys.version_info(major=3, minor=6, micro=1, releaselevel='final', serial=0)

Two intersections options :

One extension must be added to configuration conf.py:

    extensions = ['sphinx.ext.intersphinx',

One example (in French) : demo runpython. The second one shows how I use to build content (still French): rendering and source.

<-- -->

Xavier Dupré