Skip to content

Commit

Permalink
fixes idx properly (nim-lang#22280)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout authored Jul 14, 2023
1 parent db1ce4f commit f928009
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions lib/packages/docutils/rstgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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.
##
Expand Down
2 changes: 1 addition & 1 deletion lib/packages/docutils/rstidx.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f928009

Please sign in to comment.