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
# %% ,
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
# %% just before code
#+ term=True, caption='Fancy plots.'. See the example below for the markup.
The scripts can be published using the pypublish scipts:
pypublish FIR_design.py pypublish -f pdf FIR_design.py
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