Markdown Reporter
Markdown report generator for ANTA test results.
ANTAReport ¶
ANTAReport(mdfile: TextIOWrapper, results: ResultManager)
Bases: MDReportBase
Generate the # ANTA Report
section of the markdown report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mdfile |
TextIOWrapper
|
An open file object to write the markdown data into. |
required |
results |
ResultManager
|
The ResultsManager instance containing all test results. |
required |
Source code in anta/reporter/md_reporter.py
75 76 77 78 79 80 81 82 83 84 85 86 |
|
generate_section ¶
generate_section() -> None
Generate the # ANTA Report
section of the markdown report.
Source code in anta/reporter/md_reporter.py
191 192 193 194 195 |
|
MDReportBase ¶
MDReportBase(mdfile: TextIOWrapper, results: ResultManager)
Bases: ABC
Base class for all sections subclasses.
Every subclasses must implement the generate_section
method that uses the ResultManager
object
to generate and write content to the provided markdown file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mdfile |
TextIOWrapper
|
An open file object to write the markdown data into. |
required |
results |
ResultManager
|
The ResultsManager instance containing all test results. |
required |
Source code in anta/reporter/md_reporter.py
75 76 77 78 79 80 81 82 83 84 85 86 |
|
generate_heading_name ¶
generate_heading_name() -> str
Generate a formatted heading name based on the class name.
Returns:
Type | Description |
---|---|
str
|
Formatted header name. |
Example
ANTAReport
will becomeANTA Report
.TestResultsSummary
will becomeTest Results Summary
.
Source code in anta/reporter/md_reporter.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
generate_rows ¶
generate_rows() -> Generator[str, None, None]
Generate the rows of a markdown table for a specific report section.
Subclasses can implement this method to generate the content of the table rows.
Source code in anta/reporter/md_reporter.py
97 98 99 100 101 102 103 |
|
generate_section
abstractmethod
¶
generate_section() -> None
Abstract method to generate a specific section of the markdown report.
Must be implemented by subclasses.
Source code in anta/reporter/md_reporter.py
88 89 90 91 92 93 94 95 |
|
safe_markdown ¶
safe_markdown(text: str | None) -> str
Escape markdown characters in the text to prevent markdown rendering issues.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str | None
|
The text to escape markdown characters from. |
required |
Returns:
Type | Description |
---|---|
str
|
The text with escaped markdown characters. |
Source code in anta/reporter/md_reporter.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
write_heading ¶
write_heading(heading_level: int) -> None
Write a markdown heading to the markdown file.
The heading name used is the class name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
heading_level |
int
|
The level of the heading (1-6). |
required |
Example
## Test Results Summary
Source code in anta/reporter/md_reporter.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
write_table ¶
write_table(
table_heading: list[str], *, last_table: bool = False
) -> None
Write a markdown table with a table heading and multiple rows to the markdown file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_heading |
list[str]
|
List of strings to join for the table heading. |
required |
last_table |
bool
|
Flag to determine if it’s the last table of the markdown file to avoid unnecessary new line. Defaults to False. |
False
|
Source code in anta/reporter/md_reporter.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
MDReportGenerator ¶
Class responsible for generating a Markdown report based on the provided ResultManager
object.
It aggregates different report sections, each represented by a subclass of MDReportBase
,
and sequentially generates their content into a markdown file.
The generate
class method will loop over all the section subclasses and call their generate_section
method.
The final report will be generated in the same order as the sections
list of the method.
generate
classmethod
¶
generate(results: ResultManager, md_filename: Path) -> None
Generate and write the various sections of the markdown report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results |
ResultManager
|
The ResultsManager instance containing all test results. |
required |
md_filename |
Path
|
The path to the markdown file to write the report into. |
required |
Source code in anta/reporter/md_reporter.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
SummaryTotals ¶
SummaryTotals(
mdfile: TextIOWrapper, results: ResultManager
)
Bases: MDReportBase
Generate the ### Summary Totals
section of the markdown report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mdfile |
TextIOWrapper
|
An open file object to write the markdown data into. |
required |
results |
ResultManager
|
The ResultsManager instance containing all test results. |
required |
Source code in anta/reporter/md_reporter.py
75 76 77 78 79 80 81 82 83 84 85 86 |
|
generate_rows ¶
generate_rows() -> Generator[str, None, None]
Generate the rows of the summary totals table.
Source code in anta/reporter/md_reporter.py
214 215 216 217 218 219 220 221 222 |
|
generate_section ¶
generate_section() -> None
Generate the ### Summary Totals
section of the markdown report.
Source code in anta/reporter/md_reporter.py
224 225 226 227 |
|
SummaryTotalsDeviceUnderTest ¶
SummaryTotalsDeviceUnderTest(
mdfile: TextIOWrapper, results: ResultManager
)
Bases: MDReportBase
Generate the ### Summary Totals Devices Under Tests
section of the markdown report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mdfile |
TextIOWrapper
|
An open file object to write the markdown data into. |
required |
results |
ResultManager
|
The ResultsManager instance containing all test results. |
required |
Source code in anta/reporter/md_reporter.py
75 76 77 78 79 80 81 82 83 84 85 86 |
|
generate_rows ¶
generate_rows() -> Generator[str, None, None]
Generate the rows of the summary totals device under test table.
Source code in anta/reporter/md_reporter.py
238 239 240 241 242 243 244 245 246 247 |
|
generate_section ¶
generate_section() -> None
Generate the ### Summary Totals Devices Under Tests
section of the markdown report.
Source code in anta/reporter/md_reporter.py
249 250 251 252 |
|
SummaryTotalsPerCategory ¶
SummaryTotalsPerCategory(
mdfile: TextIOWrapper, results: ResultManager
)
Bases: MDReportBase
Generate the ### Summary Totals Per Category
section of the markdown report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mdfile |
TextIOWrapper
|
An open file object to write the markdown data into. |
required |
results |
ResultManager
|
The ResultsManager instance containing all test results. |
required |
Source code in anta/reporter/md_reporter.py
75 76 77 78 79 80 81 82 83 84 85 86 |
|
generate_rows ¶
generate_rows() -> Generator[str, None, None]
Generate the rows of the summary totals per category table.
Source code in anta/reporter/md_reporter.py
263 264 265 266 267 268 269 270 |
|
generate_section ¶
generate_section() -> None
Generate the ### Summary Totals Per Category
section of the markdown report.
Source code in anta/reporter/md_reporter.py
272 273 274 275 |
|
TestResults ¶
TestResults(mdfile: TextIOWrapper, results: ResultManager)
Bases: MDReportBase
Generates the ## Test Results
section of the markdown report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mdfile |
TextIOWrapper
|
An open file object to write the markdown data into. |
required |
results |
ResultManager
|
The ResultsManager instance containing all test results. |
required |
Source code in anta/reporter/md_reporter.py
75 76 77 78 79 80 81 82 83 84 85 86 |
|
generate_rows ¶
generate_rows() -> Generator[str, None, None]
Generate the rows of the all test results table.
Source code in anta/reporter/md_reporter.py
286 287 288 289 290 291 292 293 294 |
|
generate_section ¶
generate_section() -> None
Generate the ## Test Results
section of the markdown report.
Source code in anta/reporter/md_reporter.py
296 297 298 299 |
|
TestResultsSummary ¶
TestResultsSummary(
mdfile: TextIOWrapper, results: ResultManager
)
Bases: MDReportBase
Generate the ## Test Results Summary
section of the markdown report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mdfile |
TextIOWrapper
|
An open file object to write the markdown data into. |
required |
results |
ResultManager
|
The ResultsManager instance containing all test results. |
required |
Source code in anta/reporter/md_reporter.py
75 76 77 78 79 80 81 82 83 84 85 86 |
|
generate_section ¶
generate_section() -> None
Generate the ## Test Results Summary
section of the markdown report.
Source code in anta/reporter/md_reporter.py
201 202 203 |
|