Publishing scipts¶
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 mark up used in Spyder IDE.
The concept is similar to publishing documents with MATLAB or using Knitr’s spin. 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:
FIR_design.py
, FIR_design.html
, FIR_design.pdf
.
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 , other options are
pweave
(the old theme), bootstrap , cerulean and journal.
New in version 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:
pweave -f tex FIR_design.py