Exporters#

Exporters are responsible for converting a Report into a target format such as Markdown.

Multiple exporters can be used interchangeably to render the same report in different formats.

Tip

To create custom exporters, inherit from AbstractExporter and implement the render_text(), render_table(), render_figure(), and export() methods.

Abstract Exporter#

class ablate.exporters.AbstractExporter[source]#
abstract export(report)[source]#

Export the report.

Should call render_blocks() to generate the content of the report.

Parameters:

report (Report) – The report to be exported.

Return type:

None

render_blocks(report)[source]#

Render a blocks of the report.

Parameters:

report (Report) – The report to be rendered.

Raises:

ValueError – If the block type is not supported.

Return type:

List[Any]

Returns:

List of rendered blocks.

abstract render_text(block, runs)[source]#

Render a text block.

Parameters:
  • block (AbstractTextBlock) – The text block to be rendered.

  • runs (List[Run]) – The list of runs to be used for the block.

Return type:

Any

Returns:

The rendered text block.

abstract render_table(block, runs)[source]#

Render a table block.

Parameters:
  • block (AbstractTableBlock) – The table block to be rendered.

  • runs (List[Run]) – The list of runs to be used for the block.

Return type:

Any

Returns:

The rendered table block.

abstract render_figure(block, runs)[source]#

Render a figure block.

Parameters:
  • block (AbstractFigureBlock) – The figure block to be rendered.

  • runs (List[Run]) – The list of runs to be used for the block.

Return type:

Any

Returns:

The rendered figure block.

Report Exporters#

class ablate.exporters.Markdown(output_path='report.md', assets_dir=None, export_csv=False)[source]#

Export the report as a markdown file.

Parameters:
  • output_path (str) – The path to the output markdown file. Defaults to “report.md”.

  • assets_dir (Optional[str]) – The directory to store the assets (figures, etc.). If None, defaults to the parent directory of the output file with a “.ablate” subdirectory. Defaults to None.

  • export_csv (bool) – Whether to export tables and plots as CSV files. Defaults to False.

export(report)[source]#

Export the report.

Should call render_blocks() to generate the content of the report.

Parameters:

report (Report) – The report to be exported.

Return type:

None

render_text(block, runs)[source]#

Render a text block.

Parameters:
  • block (AbstractTextBlock) – The text block to be rendered.

  • runs (List[Run]) – The list of runs to be used for the block.

Return type:

str

Returns:

The rendered text block.

render_table(block, runs)[source]#

Render a table block.

Parameters:
  • block (AbstractTableBlock) – The table block to be rendered.

  • runs (List[Run]) – The list of runs to be used for the block.

Return type:

str

Returns:

The rendered table block.

render_figure(block, runs)[source]#

Render a figure block.

Parameters:
  • block (AbstractFigureBlock) – The figure block to be rendered.

  • runs (List[Run]) – The list of runs to be used for the block.

Return type:

str

Returns:

The rendered figure block.

class ablate.exporters.Notebook[source]#
export(report)[source]#

Export the report.

Should call render_blocks() to generate the content of the report.

Parameters:

report (Report) – The report to be exported.

Return type:

None

render_text(block, runs)[source]#

Render a text block.

Parameters:
  • block (AbstractTextBlock) – The text block to be rendered.

  • runs (List[Run]) – The list of runs to be used for the block.

Return type:

None

Returns:

The rendered text block.

render_table(block, runs)[source]#

Render a table block.

Parameters:
  • block (AbstractTableBlock) – The table block to be rendered.

  • runs (List[Run]) – The list of runs to be used for the block.

Return type:

None

Returns:

The rendered table block.

render_figure(block, runs)[source]#

Render a figure block.

Parameters:
  • block (AbstractFigureBlock) – The figure block to be rendered.

  • runs (List[Run]) – The list of runs to be used for the block.

Return type:

None

Returns:

The rendered figure block.