parent
5ebd1248df
commit
557d79e7a2
3 changed files with 29 additions and 10 deletions
|
|
@ -1124,6 +1124,8 @@ proc genJsonItem(d: PDoc, n, nameNode: PNode, k: TSymKind): JsonItem =
|
||||||
for kind in genericParam.sym.typ.sons:
|
for kind in genericParam.sym.typ.sons:
|
||||||
param["types"].add %($kind)
|
param["types"].add %($kind)
|
||||||
result.json["signature"]["genericParams"].add param
|
result.json["signature"]["genericParams"].add param
|
||||||
|
if optGenIndex in d.conf.globalOptions:
|
||||||
|
genItem(d, n, nameNode, k, kForceExport)
|
||||||
|
|
||||||
proc setDoctype(d: PDoc, n: PNode) =
|
proc setDoctype(d: PDoc, n: PNode) =
|
||||||
## Processes `{.doctype.}` pragma changing Markdown/RST parsing options.
|
## Processes `{.doctype.}` pragma changing Markdown/RST parsing options.
|
||||||
|
|
@ -1782,3 +1784,17 @@ proc commandBuildIndex*(conf: ConfigRef, dir: string, outFile = RelativeFile"")
|
||||||
writeFile(filename, code)
|
writeFile(filename, code)
|
||||||
except:
|
except:
|
||||||
rawMessage(conf, errCannotOpenFile, filename.string)
|
rawMessage(conf, errCannotOpenFile, filename.string)
|
||||||
|
|
||||||
|
proc commandBuildIndexJson*(conf: ConfigRef, dir: string, outFile = RelativeFile"") =
|
||||||
|
var (modules, symbols, docs) = readIndexDir(dir)
|
||||||
|
let documents = toSeq(keys(Table[IndexEntry, seq[IndexEntry]](docs)))
|
||||||
|
let body = %*({"documents": documents, "modules": modules, "symbols": symbols})
|
||||||
|
|
||||||
|
var outFile = outFile
|
||||||
|
if outFile.isEmpty: outFile = theindexFname.RelativeFile.changeFileExt("")
|
||||||
|
let filename = getOutFile(conf, outFile, JsonExt)
|
||||||
|
|
||||||
|
try:
|
||||||
|
writeFile(filename, $body)
|
||||||
|
except:
|
||||||
|
rawMessage(conf, errCannotOpenFile, filename.string)
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,11 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||||
else:
|
else:
|
||||||
docLikeCmd commandDoc2(graph, TexExt)
|
docLikeCmd commandDoc2(graph, TexExt)
|
||||||
of cmdJsondoc0: docLikeCmd commandJson(cache, conf)
|
of cmdJsondoc0: docLikeCmd commandJson(cache, conf)
|
||||||
of cmdJsondoc: docLikeCmd commandDoc2(graph, JsonExt)
|
of cmdJsondoc:
|
||||||
|
docLikeCmd():
|
||||||
|
commandDoc2(graph, JsonExt)
|
||||||
|
if optGenIndex in conf.globalOptions and optWholeProject in conf.globalOptions:
|
||||||
|
commandBuildIndexJson(conf, $conf.outDir)
|
||||||
of cmdCtags: docLikeCmd commandTags(cache, conf)
|
of cmdCtags: docLikeCmd commandTags(cache, conf)
|
||||||
of cmdBuildindex: docLikeCmd commandBuildIndex(conf, $conf.projectFull, conf.outFile)
|
of cmdBuildindex: docLikeCmd commandBuildIndex(conf, $conf.projectFull, conf.outFile)
|
||||||
of cmdGendepend: commandGenDepend(graph)
|
of cmdGendepend: commandGenDepend(graph)
|
||||||
|
|
|
||||||
|
|
@ -417,13 +417,13 @@ proc renderIndexTerm*(d: PDoc, n: PRstNode, result: var string) =
|
||||||
[id, term])
|
[id, term])
|
||||||
|
|
||||||
type
|
type
|
||||||
IndexEntry = object
|
IndexEntry* = object
|
||||||
keyword: string
|
keyword*: string
|
||||||
link: string
|
link*: string
|
||||||
linkTitle: string ## contains a prettier text for the href
|
linkTitle*: string ## contains a prettier text for the href
|
||||||
linkDesc: string ## the title attribute of the final href
|
linkDesc*: string ## the title attribute of the final href
|
||||||
|
|
||||||
IndexedDocs = Table[IndexEntry, seq[IndexEntry]] ## \
|
IndexedDocs* = Table[IndexEntry, seq[IndexEntry]] ## \
|
||||||
## Contains the index sequences for doc types.
|
## Contains the index sequences for doc types.
|
||||||
##
|
##
|
||||||
## The key is a *fake* IndexEntry which will contain the title of the
|
## The key is a *fake* IndexEntry which will contain the title of the
|
||||||
|
|
@ -625,7 +625,7 @@ proc generateModuleJumps(modules: seq[string]): string =
|
||||||
|
|
||||||
result.add(chunks.join(", ") & ".<br/>")
|
result.add(chunks.join(", ") & ".<br/>")
|
||||||
|
|
||||||
proc readIndexDir(dir: string):
|
proc readIndexDir*(dir: string):
|
||||||
tuple[modules: seq[string], symbols: seq[IndexEntry], docs: IndexedDocs] =
|
tuple[modules: seq[string], symbols: seq[IndexEntry], docs: IndexedDocs] =
|
||||||
## Walks `dir` reading ``.idx`` files converting them in IndexEntry items.
|
## Walks `dir` reading ``.idx`` files converting them in IndexEntry items.
|
||||||
##
|
##
|
||||||
|
|
@ -691,8 +691,6 @@ proc readIndexDir(dir: string):
|
||||||
title.linkTitle = "doc_toc_" & $result.docs.len
|
title.linkTitle = "doc_toc_" & $result.docs.len
|
||||||
result.docs[title] = fileEntries
|
result.docs[title] = fileEntries
|
||||||
|
|
||||||
sort(result.modules, system.cmp)
|
|
||||||
|
|
||||||
proc mergeIndexes*(dir: string): string =
|
proc mergeIndexes*(dir: string): string =
|
||||||
## Merges all index files in `dir` and returns the generated index as HTML.
|
## Merges all index files in `dir` and returns the generated index as HTML.
|
||||||
##
|
##
|
||||||
|
|
@ -722,6 +720,7 @@ proc mergeIndexes*(dir: string): string =
|
||||||
## Returns the merged and sorted indices into a single HTML block which can
|
## Returns the merged and sorted indices into a single HTML block which can
|
||||||
## be further embedded into nimdoc templates.
|
## be further embedded into nimdoc templates.
|
||||||
var (modules, symbols, docs) = readIndexDir(dir)
|
var (modules, symbols, docs) = readIndexDir(dir)
|
||||||
|
sort(modules, system.cmp)
|
||||||
|
|
||||||
result = ""
|
result = ""
|
||||||
# Generate a quick jump list of documents.
|
# Generate a quick jump list of documents.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue