diff --git a/compiler/docgen.nim b/compiler/docgen.nim index af940db00..22350a2bb 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -27,6 +27,7 @@ type seenSymbols: StringTableRef # avoids duplicate symbol generation for HTML. jArray: JsonNode types: TStrTable + isPureRst: bool PDoc* = ref TDocumentor ## Alias to type less. @@ -634,7 +635,9 @@ proc genOutFile(d: PDoc): Rope = # Modules get an automatic title for the HTML, but no entry in the index. title = "Module " & extractFilename(changeFileExt(d.filename, "")) - let bodyname = if d.hasToc: "doc.body_toc" else: "doc.body_no_toc" + let bodyname = if d.hasToc and not d.isPureRst: "doc.body_toc_group" + elif d.hasToc: "doc.body_toc" + else: "doc.body_no_toc" content = ropeFormatNamedVars(getConfigVar(bodyname), ["title", "tableofcontents", "moduledesc", "date", "time", "content"], [title.rope, toc, d.modDesc, rope(getDateStr()), @@ -699,6 +702,7 @@ proc commandDoc*() = proc commandRstAux(filename, outExt: string) = var filen = addFileExt(filename, "txt") var d = newDocumentor(filen, options.gConfigVars) + d.isPureRst = true var rst = parseRst(readFile(filen), filen, 0, 1, d.hasToc, {roSupportRawDirective}) var modDesc = newStringOfCap(30_000) diff --git a/config/nimdoc.cfg b/config/nimdoc.cfg index d19286703..2d6ce1861 100644 --- a/config/nimdoc.cfg +++ b/config/nimdoc.cfg @@ -83,6 +83,26 @@ doc.body_toc = """ """ +doc.body_toc_group = """ +
+
+
+ Group by: + +
+ $tableofcontents +
+
+
+

$moduledesc

+ $content +
+
+""" + doc.body_no_toc = """ $moduledesc $content @@ -1248,6 +1268,7 @@ dt pre > span.Operator ~ span.Identifier, dt pre > span.Operator ~ span.Operator } +