File: pypublish.rst

package info (click to toggle)
python-pweave 0.30.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 5,064 kB
  • sloc: python: 30,281; makefile: 167
file content (49 lines) | stat: -rw-r--r-- 1,946 bytes parent folder | download
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
.. _publish:

Publishing scripts
==================

.. note:: You'll need Pweave >= 0.24 for this.

As option to using the noweb format Pweave can also publish html and pdf
documents from Python scripts with a specific format.

These scripts can be executed normally using Python or published to HTML with Pweave.
Documentation is written in markdown in lines starting with ``#'``, ``#%%`` or ``# %%`` ,
and code is executed and results are included in the published document.
``#%%`` is also  `code cell <https://pythonhosted.org/spyder/editor.html#how-to-define-a-code-cell>`_ mark up used in Spyder IDE.

The concept is similar to publishing documents with MATLAB or
using Knitr's `spin <http://yihui.name/knitr/demo/stitch/>`_.
Pweave will remove the first empty space from each line of documentation.


All lines that are not documentation are treated as code. You can set chunk options
using lines starting with ``#+``, ``#%%`` or ``# %%`` just before code
e.g. ``#+ term=True, caption='Fancy plots.'``. See the example below for the markup.


The scripts can be published using the `pypublish` scipts:

:download:`FIR_design.py <examples/FIR_design.py>`, :download:`FIR_design.html <examples/FIR_design.html>` , :download:`FIR_design.pdf <examples/FIR_design.pdf>` .

.. code:: shell

    pypublish FIR_design.py
    pypublish -f pdf FIR_design.py

You can use diffent themes with pypublish using ``-t`` command line option. The
default option is `skeleton <http://getskeleton.com>`_ , other options are
``pweave`` (the old theme), `bootstrap <http://getbootstrap.com>`_ , `cerulean <https://bootswatch.com/cerulean/>`_ and `journal <https://bootswatch.com/journal/>`_.

.. versionadded:: 0.25

Other mark ups with scripts
---------------------------

You can also use any pweave supported format in the comments and run pweave
using script as input. e.g to get latex output you can use:

.. code:: shell

    pweave -f tex FIR_design.py