Skip to content

Commit

Permalink
nim doc -r main and nim rst2html -r main now call openDefaultBrow…
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour authored May 10, 2020
1 parent 8e93105 commit dda6f3f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
- `--hint:processing` is now supported and means `--hint:processing:on`
(likewise with other hints and warnings), which is consistent with all other bool flags.
(since 1.3.3).
- `nim doc -r main` and `nim rst2html -r main` now call openDefaultBrowser

## Tool changes

19 changes: 15 additions & 4 deletions compiler/nim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import
idents, lineinfos, cmdlinehelper,
pathutils

include nodejs
from browsers import openDefaultBrowser
from nodejs import findNodeJs

when hasTinyCBackend:
import tccgen
Expand Down Expand Up @@ -86,11 +87,21 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) =
if conf.cmd == cmdRun:
tccgen.run(conf, conf.arguments)
if optRun in conf.globalOptions:
var ex = quoteShell conf.absOutFile
if conf.cmd == cmdCompileToJS:
let output = conf.absOutFile
let ex = quoteShell output
case conf.cmd
of cmdCompileToJS:
execExternalProgram(conf, findNodeJs() & " " & ex & ' ' & conf.arguments)
else:
of cmdDoc, cmdRst2html:
if conf.arguments.len > 0:
# reserved for future use
rawMessage(conf, errGenerated, "'$1 cannot handle arguments" % [$conf.cmd])
openDefaultBrowser($output)
of cmdCompileToC, cmdCompileToCpp, cmdCompileToOC:
execExternalProgram(conf, ex & ' ' & conf.arguments)
else:
# support as needed
rawMessage(conf, errGenerated, "'$1 cannot handle --run" % [$conf.cmd])

when declared(GC_setMaxPause):
GC_setMaxPause 2_000
Expand Down

0 comments on commit dda6f3f

Please sign in to comment.