Skip to content

Commit

Permalink
--docCmd:skip now skips compiling snippets; 50X speedup for doc/manua…
Browse files Browse the repository at this point in the history
…l.rst
  • Loading branch information
timotheecour committed May 10, 2020
1 parent 9bbf838 commit ef3ca82
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion compiler/docgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import
const
exportSection = skField
htmldocsDir = RelativeDir"htmldocs"
docCmdSkip = "skip"

type
TSections = array[TSymKind, Rope]
Expand Down Expand Up @@ -196,6 +197,7 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
initStrTable result.types
result.onTestSnippet =
proc (gen: var RstGenerator; filename, cmd: string; status: int; content: string) =
if conf.docCmd == docCmdSkip: return
inc(gen.id)
var d = TDocumentor(gen)
var outp: AbsoluteFile
Expand Down Expand Up @@ -449,7 +451,7 @@ proc runAllExamples(d: PDoc) =
# This used to be: `let backend = if isDefined(d.conf, "js"): "js"` (etc), however
# using `-d:js` (etc) cannot work properly, eg would fail with `importjs`
# since semantics are affected by `config.backend`, not by isDefined(d.conf, "js")
if d.examples.len == 0 or docCmd == "skip": return
if d.examples.len == 0 or docCmd == docCmdSkip: return
let outputDir = d.conf.getNimcacheDir / RelativeDir"runnableExamples"
let outp = outputDir / RelativeFile(extractFilename(d.filename.changeFileExt"" &
"_examples.nim"))
Expand Down
8 changes: 4 additions & 4 deletions compiler/nim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
let output = conf.absOutFile
case conf.cmd
of cmdCompileToBackend:
var runcmd = output.quoteShell & ' ' & conf.arguments
var cmdPrefix = ""
case conf.backend
of backendC, backendCpp, backendOC: discard
of backendJS: runcmd = findNodeJs() & " " & runcmd
of backendC, backendCpp, backendObjc: discard
of backendJs: cmdPrefix = findNodeJs() & " "
else: doAssert false, $conf.backend
execExternalProgram(conf, runcmd)
execExternalProgram(conf, cmdPrefix & output.quoteShell & ' ' & conf.arguments)
of cmdDoc, cmdRst2html:
if conf.arguments.len > 0:
# reserved for future use
Expand Down
1 change: 1 addition & 0 deletions doc/advopt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Advanced commands:
//js compile project to Javascript
//e run a Nimscript file
//rst2html convert a reStructuredText file to HTML
use `--docCmd:skip` to skip compiling snippets
//rst2tex convert a reStructuredText file to TeX
//jsondoc extract the documentation to a json file
//ctags create a tags file
Expand Down

0 comments on commit ef3ca82

Please sign in to comment.