Using process envs
You may pass values to process envs to control report content:
pXXX.config.report_envs.foo = "bar"
pXXX.config.report_template = """
The value of foo is "{{foo}}".
"""
Tip
To disable report generation for a process, just set proc.report = ''
or proc.report = False
.
Preserved envs variables
We have 4 preserved variables under pXXX.envs
:
# Control the level of headings in the
pXXX.config.report_envs.level = 2
# Content to add before the template
pXXX.config.report_envs.pre = ''
# Content to add after the template
pXXX.config.report_envs.post = ''
# The title of the process report
pXXX.config.report_envs.title = None
Process report levels
No matter at which level you want to put this process report in the entire report, you need to each heading from level 1, then according to pXXX.config.report_envs.level
, the headings will be shifted to corresponding level. For example, with pXXX.config.report_envs.level = 2
, following template
# Section
## Subsection
content
will be rendered into:
## Section
### Subsection
content
Note
Comments in codeblock will be preserved.
Adding extra contents to process report
You may add extra contents to the process report. For example, if you put the process report at level 3, then you probably need a level-2 heading. For previous example, if you have pXXX.config.report_envs.level = 3
, without a level-2 heading, the entire report will look like:
# An awesome report
### Section
#### Subsection
content
Then you missed a level-2 heading, which will make your report look wired. Here you can specify a level-2 heading with pXXX.config.report_envs.pre = '## I am H2'
:
# An awesome report
## I am H2
### Section
#### Subsection
content
You may also append something to the process report with pXXX.config.report_envs.post
Warning
Headings added by pre
and post
will not be adjusted by pXXX.config.report_envs.level
Title of the process report
By default, if not assigned or assigned with None
, the process description will be used as the title of the process report. Of course you can overwrite it with pXXX.config.report_envs.title
.
# by default
pXXX = Proc(desc = 'Some analysis')
# ... other necessary settings
pXXX.report = '# {{title}}'
will be rendered as (remember default level is 2):
## Some analysis
with pXXX.config.report_envs.title = 'An amazing analysis'
, we will have:
## An amazing analysis
Making your report flexiable
You can interpolate some variables in the templates to make your report flexiable. For example, you may want to hide an image in some cases:
# {{title}}
I have enough details.
{% if report.get('showimage') %}
![Image](./path/to/image)
{% endif %}
Then you can show that image in the report only when you have pXXX.config.report_envs.showimage = True
.