XD blog

blog page

runpython


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
    print(sys.version_info)

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',
        ...
        'pyquickhelper.sphinxext.sphinx_runpython_extension']

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


Xavier Dupré