stats_vty: Improve generation of osmo counters

Use section for all counter headings, the idea is that the generated doc
is included below a chapter describing the implemented counters which
can optionally describe individual items.

If not osmo_counters are present simply omit the whole section to tidy
up the manual. Those are deprecated anyway and not used in the osmo-*
projects that I checked.

Change-Id: I126b39cb9458e0f62efa338967e07151a0eece0f
Related: SYS#5005, OS#4523
diff --git a/src/vty/stats_vty.c b/src/vty/stats_vty.c
index d5d3292..ba45e1e 100644
--- a/src/vty/stats_vty.c
+++ b/src/vty/stats_vty.c
@@ -415,13 +415,6 @@
 
 static void asciidoc_counter_generate(struct vty *vty)
 {
-	if (osmo_counters_count() == 0)
-	{
-		vty_out(vty, "// there are no ungrouped osmo_counters%s",
-			VTY_NEWLINE);
-		return;
-	}
-
 	vty_out(vty, "// ungrouped osmo_counters%s", VTY_NEWLINE);
 	vty_out(vty, ".ungrouped osmo counters%s", VTY_NEWLINE);
 	vty_out(vty, "[options=\"header\"]%s", VTY_NEWLINE);
@@ -542,13 +535,19 @@
 	vty_out(vty, "// generating tables for rate_ctr_group%s", VTY_NEWLINE);
 	rate_ctr_for_each_group(asciidoc_rate_ctr_group_handler, vty);
 
-	vty_out(vty, "== Osmo Stat Items%s%s", VTY_NEWLINE, VTY_NEWLINE);
+	vty_out(vty, "=== Osmo Stat Items%s%s", VTY_NEWLINE, VTY_NEWLINE);
 	vty_out(vty, "// generating tables for osmo_stat_items%s", VTY_NEWLINE);
 	osmo_stat_item_for_each_group(asciidoc_osmo_stat_item_group_handler, vty);
 
-	vty_out(vty, "== Osmo Counters%s%s", VTY_NEWLINE, VTY_NEWLINE);
-	vty_out(vty, "// generating tables for osmo_counters%s", VTY_NEWLINE);
-	asciidoc_counter_generate(vty);
+	if (osmo_counters_count() == 0)
+	{
+		vty_out(vty, "// there are no ungrouped osmo_counters%s",
+			VTY_NEWLINE);
+	} else {
+		vty_out(vty, "=== Osmo Counters%s%s", VTY_NEWLINE, VTY_NEWLINE);
+		vty_out(vty, "// generating tables for osmo_counters%s", VTY_NEWLINE);
+		asciidoc_counter_generate(vty);
+	}
 	return CMD_SUCCESS;
 }