Repository: aristanetworks/anta
Pull request #1232 (2025-05-30 19:46:10)

fix(anta): Add Run Overview to Markdown TOC
# Description

Added a new Markdown TOC including Run Overview when this section is generated.

# Checklist:

<!-- Delete not relevant items !-->

- [X] My code follows the style guidelines of this project
- [X] I have performed a self-review of my code
- [X] I have run pre-commit for code linting and typing (`pre-commit run`)
- [X] I have made corresponding changes to the documentation
- [X] I have added tests that prove my fix is effective or that my feature works
- [X] New and existing unit tests pass locally with my changes (`tox -e testenv`)


codspeed-hq[bot]: <!-- __CODSPEED_PERFORMANCE_REPORT_COMMENT__ -->
<!-- __CODSPEED_INSTRUMENTATION_PERFORMANCE_REPORT_COMMENT__ -->

## [CodSpeed Performance Report](https://codspeed.io/aristanetworks/anta/branches/carl-baillargeon%3Afix%2Fadd_run_overview_toc)

### Merging #1232 will **not alter performance**

<sub>Comparing <code>carl-baillargeon:fix/add_run_overview_toc</code> (efb7ece) with <code>main</code> (cb68e38)</sub>



### Summary

`✅ 26` untouched benchmarks  





Patch:
diff --git a/anta/constants.py b/anta/constants.py
index ec0dce24..caf9c7f0 100644
--- a/anta/constants.py
+++ b/anta/constants.py
@@ -38,6 +38,17 @@ MD_REPORT_TOC = """**Table of Contents:**
   - [Test Results](#test-results)"""
 """Table of Contents for the Markdown report."""
 
+MD_REPORT_TOC_WITH_RUN_OVERVIEW = """**Table of Contents:**
+
+- [ANTA Report](#anta-report)
+  - [Run Overview](#run-overview)
+  - [Test Results Summary](#test-results-summary)
+    - [Summary Totals](#summary-totals)
+    - [Summary Totals Device Under Test](#summary-totals-device-under-test)
+    - [Summary Totals Per Category](#summary-totals-per-category)
+  - [Test Results](#test-results)"""
+"""Table of Contents for the Markdown report, including Run Overview."""
+
 KNOWN_EOS_ERRORS = [
     r"BGP inactive",
     r"VRF '.*' is not active",
diff --git a/anta/reporter/md_reporter.py b/anta/reporter/md_reporter.py
index e724143c..1625e699 100644
--- a/anta/reporter/md_reporter.py
+++ b/anta/reporter/md_reporter.py
@@ -11,7 +11,7 @@ from abc import ABC, abstractmethod
 from datetime import datetime, timedelta
 from typing import TYPE_CHECKING, Any, ClassVar, TextIO
 
-from anta.constants import ACRONYM_CATEGORIES, MD_REPORT_TOC
+from anta.constants import ACRONYM_CATEGORIES, MD_REPORT_TOC, MD_REPORT_TOC_WITH_RUN_OVERVIEW
 from anta.logger import anta_log_exception
 from anta.result_manager.models import AntaTestStatus
 from anta.tools import convert_categories
@@ -262,7 +262,7 @@ class ANTAReport(MDReportBase):
     def generate_section(self) -> None:
         """Generate the `# ANTA Report` section of the markdown report."""
         self.write_heading(heading_level=1)
-        toc = MD_REPORT_TOC
+        toc = MD_REPORT_TOC_WITH_RUN_OVERVIEW if self.extra_data else MD_REPORT_TOC
         self.mdfile.write(toc + "\n\n")
 
 


Test patch:
diff --git a/tests/data/test_md_report_extra_data.md b/tests/data/test_md_report_extra_data.md
index 4a17a0e8..f33e2dbe 100644
--- a/tests/data/test_md_report_extra_data.md
+++ b/tests/data/test_md_report_extra_data.md
@@ -3,6 +3,7 @@
 **Table of Contents:**
 
 - [ANTA Report](#anta-report)
+  - [Run Overview](#run-overview)
   - [Test Results Summary](#test-results-summary)
     - [Summary Totals](#summary-totals)
     - [Summary Totals Device Under Test](#summary-totals-device-under-test)