nim doc: simplifiy index generation

This commit is contained in:
Araq 2018-09-13 20:28:51 +02:00
commit 7d9c5be333

View file

@ -361,7 +361,7 @@ proc renderIndexTerm*(d: PDoc, n: PRstNode, result: var string) =
var term = "" var term = ""
renderAux(d, n, term) renderAux(d, n, term)
setIndexTerm(d, "", id, term, d.currentSection) setIndexTerm(d, changeFileExt(extractFilename(d.filename), HtmlExt), id, term, d.currentSection)
dispA(d.target, result, "<span id=\"$1\">$2</span>", "$2\\label{$1}", dispA(d.target, result, "<span id=\"$1\">$2</span>", "$2\\label{$1}",
[id, term]) [id, term])
@ -625,6 +625,8 @@ proc readIndexDir(dir: string):
let i = find(x, '#') let i = find(x, '#')
if i > 0: if i > 0:
x = x.substr(0, i-1) x = x.substr(0, i-1)
if i != 0:
# don't add entries starting with '#'
result.modules.add(x.changeFileExt("")) result.modules.add(x.changeFileExt(""))
else: else:
# Generate the symbolic anchor for index quickjumps. # Generate the symbolic anchor for index quickjumps.
@ -672,6 +674,7 @@ proc mergeIndexes*(dir: string): string =
result.add(generateModuleJumps(modules)) result.add(generateModuleJumps(modules))
result.add("<p />") result.add("<p />")
when false:
# Generate the HTML block with API documents. # Generate the HTML block with API documents.
if docs.len > 0: if docs.len > 0:
result.add("<h2>Documentation files</h2>\n") result.add("<h2>Documentation files</h2>\n")
@ -734,7 +737,7 @@ proc renderHeadline(d: PDoc, n: PRstNode, result: var string) =
# Generate index entry using spaces to indicate TOC level for the output HTML. # Generate index entry using spaces to indicate TOC level for the output HTML.
assert n.level >= 0 assert n.level >= 0
setIndexTerm(d, "", refname, tmp.stripTocHtml, setIndexTerm(d, changeFileExt(extractFilename(d.filename), HtmlExt), refname, tmp.stripTocHtml,
spaces(max(0, n.level)) & tmp) spaces(max(0, n.level)) & tmp)
proc renderOverline(d: PDoc, n: PRstNode, result: var string) = proc renderOverline(d: PDoc, n: PRstNode, result: var string) =