summary refs log tree commit diff stats
path: root/compiler/docgen2.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/docgen2.nim')
-rw-r--r--compiler/docgen2.nim20
1 files changed, 12 insertions, 8 deletions
diff --git a/compiler/docgen2.nim b/compiler/docgen2.nim
index aa61dbd27..22fef0d47 100644
--- a/compiler/docgen2.nim
+++ b/compiler/docgen2.nim
@@ -21,42 +21,46 @@ type
     module: PSym
   PGen = ref TGen
 
+template shouldProcess(g): bool =
+  (g.module.owner.id == g.doc.conf.mainPackageId and optWholeProject in g.doc.conf.globalOptions) or
+      sfMainModule in g.module.flags
+
 template closeImpl(body: untyped) {.dirty.} =
   var g = PGen(p)
   let useWarning = sfMainModule notin g.module.flags
   #echo g.module.name.s, " ", g.module.owner.id, " ", gMainPackageId
-  if (g.module.owner.id == g.doc.conf.mainPackageId and optWholeProject in g.doc.conf.globalOptions) or
-      sfMainModule in g.module.flags:
+  if shouldProcess(g):
     body
     try:
       generateIndex(g.doc)
-      testExamples(g.doc)
     except IOError:
       discard
 
 proc close(graph: ModuleGraph; p: PPassContext, n: PNode): PNode =
   closeImpl:
-    writeOutput(g.doc, toFilename(graph.config, FileIndex g.module.position), HtmlExt, useWarning)
+    writeOutput(g.doc, toFullPath(graph.config, FileIndex g.module.position), HtmlExt, useWarning)
 
 proc closeJson(graph: ModuleGraph; p: PPassContext, n: PNode): PNode =
   closeImpl:
-    writeOutputJson(g.doc, toFilename(graph.config, FileIndex g.module.position), ".json", useWarning)
+    writeOutputJson(g.doc, toFullPath(graph.config, FileIndex g.module.position), ".json", useWarning)
 
 proc processNode(c: PPassContext, n: PNode): PNode =
   result = n
   var g = PGen(c)
-  generateDoc(g.doc, n)
+  if shouldProcess(g):
+    generateDoc(g.doc, n)
 
 proc processNodeJson(c: PPassContext, n: PNode): PNode =
   result = n
   var g = PGen(c)
-  generateJson(g.doc, n)
+  if shouldProcess(g):
+    generateJson(g.doc, n)
 
 proc myOpen(graph: ModuleGraph; module: PSym): PPassContext =
   var g: PGen
   new(g)
   g.module = module
-  var d = newDocumentor(toFilename(graph.config, FileIndex module.position), graph.cache, graph.config)
+  var d = newDocumentor(toFullPath(graph.config, FileIndex module.position), graph.cache, graph.config)
   d.hasToc = true
   g.doc = d
   result = g