summary refs log tree commit diff stats
path: root/compiler/docgen.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-04-30 19:32:03 +0200
committerGitHub <noreply@github.com>2020-04-30 19:32:03 +0200
commitcf3e0008b9725b5cc0b51b2605bc8ecb36fa449e (patch)
treed5cf97ac36d04f99f1a97230ca64351997e1180a /compiler/docgen.nim
parent0aefebb728622dfda05db68e2d04ba7c47405444 (diff)
downloadNim-cf3e0008b9725b5cc0b51b2605bc8ecb36fa449e.tar.gz
fixes #13986 [backport:1.2] (#14173)
Diffstat (limited to 'compiler/docgen.nim')
-rw-r--r--compiler/docgen.nim8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/docgen.nim b/compiler/docgen.nim
index fbdfbc884..a42be9a9c 100644
--- a/compiler/docgen.nim
+++ b/compiler/docgen.nim
@@ -86,11 +86,14 @@ proc presentationPath*(conf: ConfigRef, file: AbsoluteFile, isTitle = false): Re
     result = relativeTo(file, conf.docRoot.AbsoluteDir)
   else:
     bail()
+  if isAbsolute(result.string):
+    result = file.string.splitPath()[1].RelativeFile
   if isTitle:
     result = result.string.nativeToUnix.RelativeFile
   else:
     result = result.string.replace("..", "@@").RelativeFile ## refs #13223
   doAssert not result.isEmpty
+  doAssert not isAbsolute(result.string)
 
 proc whichType(d: PDoc; n: PNode): PSym =
   if n.kind == nkSym:
@@ -1140,7 +1143,10 @@ proc generateIndex*(d: PDoc) =
 proc updateOutfile(d: PDoc, outfile: AbsoluteFile) =
   if d.module == nil or sfMainModule in d.module.flags: # nil for eg for commandRst2Html
     if d.conf.outDir.isEmpty: d.conf.outDir = d.conf.docOutDir
-    if d.conf.outFile.isEmpty: d.conf.outFile = outfile.relativeTo(d.conf.outDir)
+    if d.conf.outFile.isEmpty:
+      d.conf.outFile = outfile.relativeTo(d.conf.outDir)
+      if isAbsolute(d.conf.outFile.string):
+        d.conf.outFile = splitPath(d.conf.outFile.string)[1].RelativeFile
 
 proc writeOutput*(d: PDoc, useWarning = false) =
   runAllExamples(d)