fixes idx properly (#22280)

This commit is contained in:
ringabout
2023-07-14 20:44:02 +08:00
committed by GitHub
parent db1ce4ff12
commit f9280090f6
2 changed files with 13 additions and 10 deletions

View File

@@ -591,16 +591,11 @@ proc readIndexDir*(dir: string):
if path.endsWith(IndexExt):
var (fileEntries, title) = parseIdxFile(path)
# Depending on type add this to the list of symbols or table of APIs.
if title.kind in {ieNimTitle, ieIdxRole}:
if title.kind == ieNimTitle:
for i in 0 ..< fileEntries.len:
if title.kind == ieIdxRole:
# Don't add to symbols TOC entries (they start with a whitespace).
let toc = fileEntries[i].linkTitle
if toc.len > 0 and toc[0] == ' ':
continue
else:
if fileEntries[i].kind != ieNim:
continue
if fileEntries[i].kind != ieNim:
continue
# Ok, non TOC entry, add it.
setLen(result.symbols, L + 1)
result.symbols[L] = fileEntries[i]
@@ -618,6 +613,14 @@ proc readIndexDir*(dir: string):
title.aux = "doc_toc_" & $result.docs.len
result.docs[title] = fileEntries
for i in 0 ..< fileEntries.len:
if fileEntries[i].kind != ieIdxRole:
continue
setLen(result.symbols, L + 1)
result.symbols[L] = fileEntries[i]
inc L
proc mergeIndexes*(dir: string): string =
## Merges all index files in `dir` and returns the generated index as HTML.
##

View File

@@ -121,7 +121,7 @@ proc parseIdxFile*(path: string):
result.fileEntries[f].linkDesc = cols[4].unquoteIndexColumn
result.fileEntries[f].line = parseInt(cols[5])
if result.fileEntries[f].kind in {ieNimTitle, ieMarkupTitle, ieIdxRole}:
if result.fileEntries[f].kind in {ieNimTitle, ieMarkupTitle}:
result.title = result.fileEntries[f]
inc f