1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
=====================
Using pweave module
=====================
.. currentmodule:: pweave
Pweave can also be used as module from the Python interpreter. This
has some advantages over just using the scripts. First the execution
of the code will be faster because all modules all already
imported. It is also possible to fully
customize the document execution and formatting using the :py:class:`Pweb` class.
pweave module contains two functions :py:func:`weave` and
:py:func:`tangle` that offer the same functionality as the command
line scripts.
Simple weaving and tangling:
============================
Here's and example of simple weaving and tangling using example
document `ma.mdw <_static/ma.mdw>`_. Notice that pweave prints out the
progress so in case of an error you can tell in which chunk it
occurred.
<<>>=
import pweave
# Weave a pandoc document with default options
pweave.weave('ma.mdw', doctype = "pandoc")
@
<<>>=
# Extract the code
pweave.tangle('ma.mdw')
@
Pweave function reference
--------------------------
.. autofunction:: pweave.weave
.. autofunction:: pweave.tangle
.. autofunction:: pweave.publish
.. autofunction:: pweave.convert
.. autofunction:: pweave.spin
More options with Pweb Class
============================
Weaving, tangling and pweave options are implemented using
:py:class:`Pweb` class. There is an `example <customizing.html>`_
about customizations and the class reference is below.
Pweb Class
----------
.. autoclass:: pweave.Pweb
:members:
|