Module datapane.client.api.templates
Datapane helper functions to make creating your reports a bit simpler and reduce common tasks
Note: Please submit any new templates you've used to our repo - it's open-source and will help everyone in creating great reports!
Functions
def add_code(block: Union[ForwardRef('Group'), ForwardRef('Select'), ForwardRef('DataBlock'), Any], code: str, language: str = 'python') ‑> Select
-
Attach code fragment to an existing plot/figure/dataframe for use within a report
Args
block
- The existing object to add code to - can be either an existing dp Block or an Python object
code
- The code fragment to add
language
- The language of the code fragment (optional)
Returns
A Select block that provides the figure and the code in tabs that can be selected by the user
def add_header(report: Report, header: Union[ForwardRef('Group'), ForwardRef('Select'), ForwardRef('DataBlock'), Any], all_pages: bool = True) ‑> Report
-
Add a header to the report, returning a modified version of the same report
Args
report
- The report to add the header to
header
- The header block - this can be any dp Block, e.g a File, Plot, Logo, or anything
all_pages
- Apply the header to all pages or just the first page only
Returns
A modified report with the header applied
-
Add a footer to the report, returning a modified version of the same report
Args
report
- The report to add the header to
footer
- The footer block - this can be any dp Block, e.g a File, Plot, Logo, or anything
all_pages
- Apply the header to all pages or just the first page only
Returns
A modified report with the footer applied
def build_md_report(text_or_file: Union[str, pathlib.Path, os.PathLike], *args: Union[ForwardRef('Group'), ForwardRef('Select'), ForwardRef('DataBlock'), Any], **kwargs: Union[ForwardRef('Group'), ForwardRef('Select'), ForwardRef('DataBlock'), Any]) ‑> Report
-
An easy way to build a complete report from a single top-level markdown text / file template. Any additional context can be passed in and will be inserted into the Markdown template.
Args
text_or_file
- The markdown text, or path to a markdown file, using {} for templating
*args
- positional template context arguments
**kwargs
- keyword template context arguments
Tip: either text or file is required
Tip: Either Python objects, e.g. dataframes, and plots, or Datapane blocks as context
def build_demo_report() ‑> Report
-
Generate a sample demo report
Returns
A datapane Report object for saving or publishing