https://github.com/keszybz/sphinxcontrib-codesample
Sphinx directive to display and execute Python code
https://github.com/keszybz/sphinxcontrib-codesample
extension python3 sphinx-documentation
Last synced: 11 months ago
JSON representation
Sphinx directive to display and execute Python code
- Host: GitHub
- URL: https://github.com/keszybz/sphinxcontrib-codesample
- Owner: keszybz
- License: bsd-2-clause
- Created: 2017-03-24T16:49:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-07-14T08:52:42.000Z (almost 7 years ago)
- Last Synced: 2025-01-22T20:51:41.986Z (over 1 year ago)
- Topics: extension, python3, sphinx-documentation
- Language: Python
- Size: 1.03 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
########################
sphinxcontrib-codesample
########################
A Sphinx_ extension to insert arbitrary Python code and its output
into documents. Very similar to code samples in docstrings, but the
output is dynamically generated each time documentation is built.
This extension is similar to IPython's `ipython_directive`_, but does
not use IPython formatting conventions and is much simpler by the
virtue of using plain Python to execute commands.
Installation
------------
Install this extension using pip from `pypi`_::
pip install sphinxcontrib-codesample
Usage
-----
Just add this extension to ``extensions``::
extensions = ['sphinxcontrib.codesample']
and insert plain Python code:
.. code-block:: rst
.. codesample::
x = 3
print(x**3)
Output:
.. code-block:: python
>>> x = 3
>>> print(x ** 3)
9
Please refer to the documentation_ for comprehensive information about usage.
Issues
------
Please report issues to the `issue tracker`_ if you found a bug.
Development
-----------
The source code is hosted on github::
git clone https://github.com/keszybz/sphinxcontrib-codesample
.. _Sphinx: http://sphinx.pocoo.org/latest
.. _ipython_directive: http://matplotlib.org/sampledoc/ipython_directive.html
.. _pypi: http://pypi.python.org/pypi/sphinxcontrib-codesample
.. _documentation: https://keszybz.github.io/sphinxcontrib-codesample
.. _issue tracker: https://github.com/keszybz/sphinxcontrib-codesample/issues
.. _Github: https://github.com/keszybz/sphinxcontrib-codesample