@@ -37,6 +37,7 @@ public class MetricsDocGen {
37
37
38
38
void generate () {
39
39
pageHeader ();
40
+ generateTableOfContents ();
40
41
41
42
for (var category : Metric .MetricCategory .values ()) {
42
43
generateCategorySection (category , category .getSectionTitle ());
@@ -54,8 +55,18 @@ void pageHeader() {
54
55
doc .println ("Below are the metrics used to monitor various components of Accumulo.\n " );
55
56
}
56
57
58
+ void generateTableOfContents () {
59
+ doc .println ("## Table of Contents\n " );
60
+ for (var category : Metric .MetricCategory .values ()) {
61
+ String sectionId = generateSectionId (category .getSectionTitle ());
62
+ doc .println ("- [" + category .getSectionTitle () + "](#" + sectionId + ")" );
63
+ }
64
+ doc .println ();
65
+ }
66
+
57
67
void generateCategorySection (Metric .MetricCategory category , String sectionTitle ) {
58
- beginSection (sectionTitle );
68
+ String sectionId = generateSectionId (sectionTitle );
69
+ beginSection (sectionTitle , sectionId );
59
70
60
71
// Enable block-level HTML parsing
61
72
doc .println ("{::options parse_block_html=\" true\" /}" );
@@ -70,10 +81,17 @@ void generateCategorySection(Metric.MetricCategory category, String sectionTitle
70
81
doc .println ("{::options parse_block_html=\" false\" /}\n " );
71
82
}
72
83
73
- void beginSection (String sectionTitle ) {
74
- doc .println ("\n ## " + sectionTitle + "\n " );
84
+ /**
85
+ * Starts a new section in the documentation. In this case a section is a category of metrics.
86
+ * Adds an anchor to the section title so we can link to it.
87
+ */
88
+ void beginSection (String sectionTitle , String sectionId ) {
89
+ doc .println ("\n ## <a id=\" " + sectionId + "\" ></a>" + sectionTitle + "\n " );
75
90
}
76
91
92
+ /**
93
+ * Generates a subsection for a metric. This includes the metric name, type, and description.
94
+ */
77
95
void generateMetricSubsection (Metric metric ) {
78
96
// Open the div block with markdown enabled
79
97
doc .println ("<div markdown=\" 1\" class=\" metric-section\" >" );
@@ -86,6 +104,14 @@ void generateMetricSubsection(Metric metric) {
86
104
doc .println ("</div>" );
87
105
}
88
106
107
+ /**
108
+ * Generates a section ID from a section title. This is used to create anchors for linking to
109
+ * sections.
110
+ */
111
+ String generateSectionId (String sectionTitle ) {
112
+ return sectionTitle .toLowerCase ().replace (" " , "-" ).replace ("." , "" );
113
+ }
114
+
89
115
private MetricsDocGen (PrintStream doc ) {
90
116
this .doc = doc ;
91
117
this .sortedMetrics .addAll (Arrays .asList (Metric .values ()));
0 commit comments