Fixes #9364 and add moduleDescription to jsondoc (#9396)

This fixes `jsondoc0` so that it has comments in the output as described
by the documentation. It also fixes `jsondoc`/`jsondoc2` as it stored
it's output in a file with an html extension. Along with this it also
adds a new field `moduleDescription` to `jsondoc`/`jsondoc2` which
contains the module description.
This commit is contained in:
PMunch 2018-10-17 00:34:47 +02:00 • committed by Andreas Rumpf
commit db95fad6fa
4 changed files with 28 additions and 12 deletions

View file

@ -55,20 +55,26 @@ proc processNodeJson(c: PPassContext, n: PNode): PNode =
result = n
var g = PGen(c)
if shouldProcess(g):
generateJson(g.doc, n)
generateJson(g.doc, n, false)
proc myOpen(graph: ModuleGraph; module: PSym): PPassContext =
template myOpenImpl(ext: untyped) {.dirty.} =
var g: PGen
new(g)
g.module = module
var d = newDocumentor(AbsoluteFile toFullPath(graph.config, FileIndex module.position),
graph.cache, graph.config)
graph.cache, graph.config, ext)
d.hasToc = true
g.doc = d
result = g
proc myOpen(graph: ModuleGraph; module: PSym): PPassContext =
myOpenImpl(HtmlExt)
proc myOpenJson(graph: ModuleGraph; module: PSym): PPassContext =
myOpenImpl(JsonExt)
const docgen2Pass* = makePass(open = myOpen, process = processNode, close = close)
const docgen2JsonPass* = makePass(open = myOpen, process = processNodeJson,
const docgen2JsonPass* = makePass(open = myOpenJson, process = processNodeJson,
close = closeJson)
proc finishDoc2Pass*(project: string) =