Skip to content

Commit a1d2a10

Browse files
committed
successX now correctly shows html output for nim doc
1 parent a33b72a commit a1d2a10

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

compiler/docgen.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type
3939
exampleCounter: int
4040
emitted: IntSet # we need to track which symbols have been emitted
4141
# already. See bug #3655
42-
destFile*: AbsoluteFile
42+
destFile*: AbsoluteFile # that's a lie...
4343
thisDir*: AbsoluteDir
4444
examples: string
4545

@@ -1060,6 +1060,8 @@ proc writeOutput*(d: PDoc, useWarning = false) =
10601060
if not writeRope(content, outfile):
10611061
rawMessage(d.conf, if useWarning: warnCannotOpenFile else: errCannotOpenFile,
10621062
outfile.string)
1063+
# for some reason, outfile is relative, violating its type contract
1064+
d.conf.outFileAlt = outfile.`$`.absolutePath.AbsoluteFile
10631065

10641066
proc writeOutputJson*(d: PDoc, useWarning = false) =
10651067
runAllExamples(d)
@@ -1077,6 +1079,7 @@ proc writeOutputJson*(d: PDoc, useWarning = false) =
10771079
if open(f, d.destFile.string, fmWrite):
10781080
write(f, $content)
10791081
close(f)
1082+
d.conf.outFileAlt = d.destFile
10801083
else:
10811084
localError(d.conf, newLineInfo(d.conf, AbsoluteFile d.filename, -1, -1),
10821085
warnUser, "unable to open file \"" & d.destFile.string &

compiler/main.nim

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import
1919
cgen, json, nversion,
2020
platform, nimconf, passaux, depends, vm, idgen,
2121
modules,
22-
modulegraphs, tables, rod, lineinfos, pathutils
22+
modulegraphs, tables, rod, lineinfos, pathutils, os
2323

2424
when not defined(leanCompiler):
2525
import jsgen, docgen, docgen2
@@ -363,8 +363,11 @@ proc mainCommand*(graph: ModuleGraph) =
363363
elif isDefined(conf, "release"): "Release"
364364
else: "Debug"
365365
let sec = formatFloat(epochTime() - conf.lastCmdTime, ffDecimal, 3)
366-
let project = if optListFullPaths in conf.globalOptions: $conf.projectFull else: $conf.projectName
367-
let output = if optListFullPaths in conf.globalOptions: $conf.getOutFileFull else: $conf.outFile
366+
template postprocess(path): untyped =
367+
if optListFullPaths in conf.globalOptions: $path
368+
else: path.`$`.lastPathPart
369+
let project = conf.projectFull.postprocess
370+
let output = conf.getOutFileFull.postprocess
368371
rawMessage(conf, hintSuccessX, [
369372
"loc", loc,
370373
"sec", sec,

compiler/options.nim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ type
244244
searchPaths*: seq[AbsoluteDir]
245245
lazyPaths*: seq[AbsoluteDir]
246246
outFile*: RelativeFile
247+
outFileAlt*: AbsoluteFile ## eg html produced by `nim doc`
247248
outDir*: AbsoluteDir
248249
prefixDir*, libpath*, nimcacheDir*: AbsoluteDir
249250
dllOverrides, moduleOverrides*, cfileSpecificOptions*: StringTableRef
@@ -284,7 +285,11 @@ type
284285
severity: Severity) {.closure, gcsafe.}
285286
cppCustomNamespace*: string
286287

287-
proc getOutFileFull*(a: ConfigRef): AbsoluteFile = a.outDir / a.outFile
288+
proc getOutFileFull*(a: ConfigRef): AbsoluteFile =
289+
if a.outFile.`$`.len > 0:
290+
result = a.outDir / a.outFile
291+
else:
292+
result = a.outFileAlt
288293

289294
proc hcrOn*(conf: ConfigRef): bool = return optHotCodeReloading in conf.globalOptions
290295

0 commit comments

Comments
 (0)