You're reading the documentation for a development version. For the latest released version, please have a look at v0.8.2.

snl_d3d_cec_verify.report package

class snl_d3d_cec_verify.report.Content(width=None)

Class for storing document content in Pandoc markdown format. Use in conjunction with the Report class.

Content is stored in order, for example:

>>> report = Report()
>>> report.content.add_text("one")
>>> report.content.add_text("two")
>>> print(report)
1: one
2:
3: two
4:

Note that an empty line is placed between each part of the content.

Parameters:

width (Optional[int]) – maximum paragraph width, in characters

width: Optional[int] = None

maximum paragraph width, in characters

add_text(text, wrapped=True)

Add a paragraph of text to the document.

>>> report = Report()
>>> report.content.add_text("one")
>>> print(report)
1: one
2:
Parameters:
  • text (str) – Paragraph text

  • wrapped (bool) – Wrap the text based on the value of the width parameter, defaults to True.

add_heading(text, level=1, label=None)

Add a heading to the document.

>>> report = Report()
>>> report.content.add_heading("Two", level=2, label="sec:two")
>>> print(report)
1: ## Two {#sec:two}
2:
Parameters:
  • text (str) – Heading text

  • level (int) – Heading level, defaults to 1.

  • label (Optional[str]) – label for the heading, must start with ‘sec:’

Raises:

ValueError – if label does not start with ‘sec:’

add_table(dataframe, index=True, caption=None, label=None)

Add a table to the document, converted from a pandas.DataFrame.

>>> report = Report()
>>> a = {"a": [1, 2],
...      "b": [3, 4]}
>>> df = pd.DataFrame(a)
>>> report.content.add_table(df,
...                          index=False,
...                          caption="A table",
...                          label="tbl:a")
>>> print(report)
1: |   a |   b |
2: |----:|----:|
3: |   1 |   3 |
4: |   2 |   4 |
5:
6: Table:  A table {#tbl:a}
7:
Parameters:
  • dataframe (DataFrame) – DataFrame containing the table headings and data

  • index (bool) – include the DataFrame index in the table, defaults to True

  • caption (Optional[str]) – caption for the table

  • label (Optional[str]) – label for the table, requires caption to be set and must start with ‘tbl:’

Raises:

ValueError – if label does not start with ‘tbl:’

add_image(path, caption=None, label=None, width=None, height=None)

Add image to document, passed as path to a compatible image file.

>>> report = Report()
>>> report.content.add_image("high_art.png",
...                          caption="Probably an NFT",
...                          label="fig:hart",
...                          width="6in",
...                          height="4in")
>>> print(report)
1: ![Probably an NFT](high_art.png){ #fig:hart width=6in height=4in }
2:
Parameters:
  • path (Union[str, Path]) – path to the image file

  • caption (Optional[str]) – caption for the image

  • label (Optional[str]) – label for the image, requires caption to be set and must start with ‘fig:’

  • width (Optional[str]) – image width in document, including units

  • height (Optional[str]) – image height in document, including units

Raises:

ValueError – if label does not start with ‘fig:’

clear()

Remove all content from the document

>>> report = Report()
>>> report.content.add_text("one")
>>> report.content.add_text("two")
>>> report.content.clear()
>>> print(report)
undo()

Undo the last content addition

>>> report = Report()
>>> report.content.add_text("one")
>>> report.content.add_text("two")
>>> report.content.undo()
>>> print(report)
1: one
2: