Skip to content

Commit

Permalink
successX now correctly shows html output for nim doc
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Jan 11, 2020
1 parent a33b72a commit a1d2a10
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion compiler/docgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type
exampleCounter: int
emitted: IntSet # we need to track which symbols have been emitted
# already. See bug #3655
destFile*: AbsoluteFile
destFile*: AbsoluteFile # that's a lie...
thisDir*: AbsoluteDir
examples: string

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

proc writeOutputJson*(d: PDoc, useWarning = false) =
runAllExamples(d)
Expand All @@ -1077,6 +1079,7 @@ proc writeOutputJson*(d: PDoc, useWarning = false) =
if open(f, d.destFile.string, fmWrite):
write(f, $content)
close(f)
d.conf.outFileAlt = d.destFile
else:
localError(d.conf, newLineInfo(d.conf, AbsoluteFile d.filename, -1, -1),
warnUser, "unable to open file \"" & d.destFile.string &
Expand Down
9 changes: 6 additions & 3 deletions compiler/main.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import
cgen, json, nversion,
platform, nimconf, passaux, depends, vm, idgen,
modules,
modulegraphs, tables, rod, lineinfos, pathutils
modulegraphs, tables, rod, lineinfos, pathutils, os

when not defined(leanCompiler):
import jsgen, docgen, docgen2
Expand Down Expand Up @@ -363,8 +363,11 @@ proc mainCommand*(graph: ModuleGraph) =
elif isDefined(conf, "release"): "Release"
else: "Debug"
let sec = formatFloat(epochTime() - conf.lastCmdTime, ffDecimal, 3)
let project = if optListFullPaths in conf.globalOptions: $conf.projectFull else: $conf.projectName
let output = if optListFullPaths in conf.globalOptions: $conf.getOutFileFull else: $conf.outFile
template postprocess(path): untyped =
if optListFullPaths in conf.globalOptions: $path
else: path.`$`.lastPathPart
let project = conf.projectFull.postprocess
let output = conf.getOutFileFull.postprocess
rawMessage(conf, hintSuccessX, [
"loc", loc,
"sec", sec,
Expand Down
7 changes: 6 additions & 1 deletion compiler/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ type
searchPaths*: seq[AbsoluteDir]
lazyPaths*: seq[AbsoluteDir]
outFile*: RelativeFile
outFileAlt*: AbsoluteFile ## eg html produced by `nim doc`
outDir*: AbsoluteDir
prefixDir*, libpath*, nimcacheDir*: AbsoluteDir
dllOverrides, moduleOverrides*, cfileSpecificOptions*: StringTableRef
Expand Down Expand Up @@ -284,7 +285,11 @@ type
severity: Severity) {.closure, gcsafe.}
cppCustomNamespace*: string

proc getOutFileFull*(a: ConfigRef): AbsoluteFile = a.outDir / a.outFile
proc getOutFileFull*(a: ConfigRef): AbsoluteFile =
if a.outFile.`$`.len > 0:
result = a.outDir / a.outFile
else:
result = a.outFileAlt

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

Expand Down

0 comments on commit a1d2a10

Please sign in to comment.