franc.evaluation.report_generation

Tooling to generate pdf reports through latex

Classes

ReportElement

Parent class for elements placed in a report object that generate latex code

ReportFigure

Figure element for reports

ReportTable

Table element for reports

ReportCodeListing

Table element for reports

Report

Base class for report generators

LatexReport

Latex code generator

HTMLReport

HTML code generator

Functions

html_escape(inp)

prepare a string for being put into an html element

_escape_latex_chars(inp)

Module Contents

franc.evaluation.report_generation.html_escape(inp)

prepare a string for being put into an html element

Parameters:

inp (str) –

class franc.evaluation.report_generation.ReportElement

Bases: abc.ABC

Parent class for elements placed in a report object that generate latex code

abstract latex()

Generate latex code

Return type:

str

abstract html()

Generate latex code

Return type:

str

class franc.evaluation.report_generation.ReportFigure(image_path, base_path, caption=None, width=1.0)

Bases: ReportElement

Figure element for reports

Parameters:
  • image_path (str) – Image path within the project location

  • base_path (str | pathlib.Path) – Project location

  • caption (str | None) – Optional figure caption

  • width (float) – Optional display width of the figure

image_path
base_path
caption = None
width = 1.0
latex()

Generate latex code

Return type:

str

html()

Generate latex code

Return type:

str

class franc.evaluation.report_generation.ReportTable(table_content, header=None, caption=None, cell_format=None, horizontal_separator=' ', verb_char='|')

Bases: ReportElement

Table element for reports

Parameters:
  • table_content (collections.abc.Sequence[collections.abc.Sequence[str]]) – Two dimensional sequence of strings representing the table Content will be placed in a verb statement with the defined character being removed

  • header (collections.abc.Sequence[str] | None) – Header values of the table. If none are provided, no header is generated

  • caption (str | None) – Caption for the table

  • cell_format (str | None) – A sequence of latex format values. The default for a 4 column table is {cccc} resulting in centered tables

  • horizontal_separator (str) – If no cell format value is provided, this can be used to enable vertical lines.

  • verb_char (str) – Character used for the verb statements on table content. This character will be removed from the cell content strings.

table_content
caption = None
format = None
verb_char = '|'
latex()

Generate latex code

Return type:

str

html()

Generate latex code

Return type:

str

class franc.evaluation.report_generation.ReportCodeListing(content)

Bases: ReportElement

Table element for reports

Parameters:

content (str) – The code to be displayed

content
latex()

Generate latex code

Return type:

str

html()

Generate latex code

Return type:

str

class franc.evaluation.report_generation.Report

Bases: dict, abc.ABC

Base class for report generators

property file_ending: str
Abstractmethod:

Return type:

str

file ending for generated files

abstract generate(structure=None, level=0)

Generate report code

Parameters:
  • structure (dict | None) –

  • level (int) –

Return type:

str

save(fname)

Save report code to file

Parameters:

fname (str | pathlib.Path) –

Return type:

None

compile(fname)

Not relevant for html output

Parameters:

fname (str | pathlib.Path) –

Return type:

pathlib.Path

franc.evaluation.report_generation._escape_latex_chars(inp)
Parameters:

inp (str) –

class franc.evaluation.report_generation.LatexReport

Bases: Report

Latex code generator

block_start = Multiline-String
Show Value
"""\documentclass[12pt, a4paper]{report}
\usepackage[top=3cm, bottom=3cm, left = 2cm, right = 2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{amsmath} % red arrow for listing line break
\usepackage[hidelinks]{hyperref} % for links within the document

\lstset{
breaklines=true,
postbreak=\mbox{{$\hookrightarrow$}\space},
}


\begin{document}

\tableofcontents

"""
block_end = '\\end{document}'
sectioning_commands = ['chapter', 'section', 'subsection', 'subsubsection', 'paragraph', 'subparagraph']
property file_ending: str

file ending for generated files

Return type:

str

static _generate_entry(entry)

Generate latex code for the given entry

generate(structure=None, level=0)

Generate latex code

Parameters:
  • structure (dict | None) –

  • level (int) –

Return type:

str

compile(fname)

Compile report using pdflatex If not present, the required .pdf and .tex suffixes are added as needed.

returns the path of the generated pdf file

Parameters:

fname (str | pathlib.Path) –

Return type:

pathlib.Path

class franc.evaluation.report_generation.HTMLReport

Bases: Report

HTML code generator

block_start = Multiline-String
Show Value
"""<html>
<head>
  <style>
  html * {
    font-size: 1vw;
  }

  </style>
</head>

<body style="margin:1vw;padding:1vw">

"""
block_end = Multiline-String
Show Value
"""</body>
</html>"""
property file_ending: str

file ending for generated files

Return type:

str

static _generate_entry(entry)

Generate latex code for the given entry

generate(structure=None, level=0)

Generate latex code

Parameters:
  • structure (dict | None) –

  • level (int) –

Return type:

str