Sphinx-Extractor¶
A Sphinx extension to extract rst code from text-based files. It is tested for file type of txt, py, puml, and md.
It uses directive extract to extract rst code from specified location in given file.
Usage¶
After Installation and Activation, use directive extract in your rst files like below:
Extract from txt file¶
To extract rst code from the following example content of my.txt file:
This is example test txt file.
@startrst
.. code-block:: ruby
Some Ruby code.
.. note::
something stuff to note.
@endrst
Use the directive extract like following:
.. extract:: ../tests/doc_test/utils/mytxt.txt
:start: @startrst
:end: @endrst
The directive extract block will be replaced with the extracted rst content:
Some Ruby code.
Note
something stuff to note.
Extract from py file¶
Example python file content
def my_app():
"""
@rst
.. code-block:: python
Some python code.
def dummy():
pass
@endrst
"""
pass
Example
.. extract:: ../tests/doc_test/utils/myapp.py
:start: @rst
:end: @endrst
Result
Some python code.
def dummy():
pass