diff options
author | Jacek Sieka <arnetheduck@gmail.com> | 2016-08-25 22:59:51 +0800 |
---|---|---|
committer | Jacek Sieka <arnetheduck@gmail.com> | 2016-08-25 22:59:51 +0800 |
commit | db2f96daba9c04db2f24cb783c79fb37799cd9ea (patch) | |
tree | 567beb43c7e4549abfcae1ea66e5232d7525e001 /compiler/docgen2.nim | |
parent | 3116744c86f37ac4e4e5fec3d6d1635304ed717f (diff) | |
parent | 84a09d2f5b0866491e55fef0fef541e8cc548852 (diff) | |
download | Nim-db2f96daba9c04db2f24cb783c79fb37799cd9ea.tar.gz |
Merge remote-tracking branch 'origin/devel' into initallocator-fix
Diffstat (limited to 'compiler/docgen2.nim')
-rw-r--r-- | compiler/docgen2.nim | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/compiler/docgen2.nim b/compiler/docgen2.nim index 27de06811..d70d5406c 100644 --- a/compiler/docgen2.nim +++ b/compiler/docgen2.nim @@ -19,21 +19,36 @@ type module: PSym PGen = ref TGen -proc close(p: PPassContext, n: PNode): PNode = +template closeImpl(body: untyped) {.dirty.} = var g = PGen(p) let useWarning = sfMainModule notin g.module.flags - if gWholeProject or sfMainModule in g.module.flags: - writeOutput(g.doc, g.module.filename, HtmlExt, useWarning) + #echo g.module.name.s, " ", g.module.owner.id, " ", gMainPackageId + if (g.module.owner.id == gMainPackageId and gWholeProject) or + sfMainModule in g.module.flags: + body try: generateIndex(g.doc) except IOError: discard +proc close(p: PPassContext, n: PNode): PNode = + closeImpl: + writeOutput(g.doc, g.module.filename, HtmlExt, useWarning) + +proc closeJson(p: PPassContext, n: PNode): PNode = + closeImpl: + writeOutputJson(g.doc, g.module.filename, ".json", useWarning) + proc processNode(c: PPassContext, n: PNode): PNode = result = n var g = PGen(c) generateDoc(g.doc, n) +proc processNodeJson(c: PPassContext, n: PNode): PNode = + result = n + var g = PGen(c) + generateJson(g.doc, n) + proc myOpen(module: PSym): PPassContext = var g: PGen new(g) @@ -44,6 +59,8 @@ proc myOpen(module: PSym): PPassContext = result = g const docgen2Pass* = makePass(open = myOpen, process = processNode, close = close) +const docgen2JsonPass* = makePass(open = myOpen, process = processNodeJson, + close = closeJson) proc finishDoc2Pass*(project: string) = discard |