-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nim doc --backend:js
, nim doc --doccmd:-d:foo
, nim r --backend:js
, --doccmd:skip
+ other improvements
#14278
Conversation
nim doc --backend:js
, nim doc --doccmd:-dfoo
, nim r --backend:js
+ other improvementsnim doc --backend:js
, nim doc --doccmd:-d:foo
, nim r --backend:js
+ other improvements
@timotheecour Thank you! for working on this. I started looking into implementing it but didn't have time to dig further on how to add switches that affected "nim doc" and not the regular "nim". |
It's excellent work but some tests seem to be red and it's not the usual flaky tests. |
8ffc5bb
to
a126e0b
Compare
nim doc --backend:js
, nim doc --doccmd:-d:foo
, nim r --backend:js
+ other improvementsnim doc --backend:js
, nim doc --doccmd:-d:foo
, nim r --backend:js
, --doccmd:skip
+ other improvements
@Araq PTAL
fixed it, was a 1 liner fix
|
0f39b8d
to
ef3ca82
Compare
`nim doc --doccmd:'-d:foo --threads:on'` `nim r --backend:cpp...` (implies --run --usenimcache)
ef3ca82
to
c1ef738
Compare
Can we have this for nimsuggest too? :D |
IMO it's best as a separate PR, this PR is big enough already; my guess is this should be a simple followup, eg:
|
Continues 9502e39 Ref: - 9502e39#commitcomment-39087584 - #14278 Fixes #13129 .
…s`, `--doccmd:skip` + other improvements (nim-lang#14278) * `nim doc --backend:js|cpp...` `nim doc --doccmd:'-d:foo --threads:on'` `nim r --backend:cpp...` (implies --run --usenimcache) * --usenimcache works with all targets * --docCmd:skip now skips compiling snippets; 50X speedup for doc/manual.rst
flags introduced here are by design orthogonal so that they work as you'd expect when you combine them.
nim --backend:js|c|cpp|objc
(or -b:js etc)nim doc
#13129 (Allow specifying/forcing the compilation backend in Nim for `nim doc)nim doc --backend:js
to generate js specific docs. This opens door to showing docs specific to different backends, which would be more accurate than what we have now (often wrong since it assumes c target for nim js in system.nim for example)--backend
is then passed on to runnableExamples, which run the examples for the same backend backend by default. (--doccmd:--backend:cpp
would be able to override it should user want that, see below)--backend:js
to the command right before the $file argument, eg:nim c -b:cpp $file
=> will use cpp backendnim r -b:js (etc)
nim r
(introduced in new cmd:nim r main [args...]
to compile & run, saving binary under $nimcache/main #13382 just forc
backend) now works with other backends, eg:nim r -b:js main
nim r
should now be the de facto default to run tests, regardless of backend, since it avoids polluting your sources with generated js or binariesnim doc --doccmd:cmd
nim doc --doccmd:'-d:foo --threads:on --lib:lib' main
; this fixes Allow specifying/forcing the compilation backend in Nim for
nim doc
#13129 (comment)nim doc --doccmd:skip
,nim rst2html --doccmd:skip
--doccmd:skip
; very useful when you just want to see how the generated html file looks like without waiting for all the runnableExamples to run (or snippets to compile), during development.eg:
nim rst2html --outdir:doc/html doc/manual.rst
=> 50snim rst2html --outdir:doc/html --doccmd:skip doc/manual.rst
=> 0.9s--usenimcache
--usenimcache
and avoid polluting both $pwd and $projectdir--usenimcache
was implicitly introduced in new cmd:nim r main [args...]
to compile & run, saving binary under $nimcache/main #13382 just fornim r
; now it's explicitly a flag decoupled fromnim r
and works in combination with other commands, eg:nim doc --usenimcache
=> will output html under nimcache--usenimcache
by design uses whatever nimcache resolves to after each command was processed, eg:nim doc --nimcache:foo --usenimcache --nimcache:bar main
=> will output html unerbar
, notfoo
nim c --usenimcache main
ornim doc --usenimcache
note: setting
-d:js
(etc) manually is bad, hence the need for--backend:js
Note that simply setting
-d:js
is naive and won't work in many cases (eg importjs etc; or may end up with both defined(c) and defined(js) etc), likewise with -d:cpp; in fact future PR should probably issue warning when user code sets -d:js (+other backends) as it'd be error prone.tests
potential future directions
--usenimcache
default fornim doc
; IMO that's the best resolution for doc2 outputs in current work dir #6583; any -o or --outdir would override --usenimcache anywaynim r doc --port:1234 main
will save the html under nimcache (because-r
implies--usenimcache
), and setup (on 1st call) a livereload server (see https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei?hl=en) so that the html opens in the same tab and auto-refreshesnim r -b:js --port:1234 (-d:nimbrowser) main
will create a template html file that simply links against the generated js file so you can see it running in a browser, it will also use the livereload server to auto-refresh the same tab; this avoids setting up a server manually just to see hownim js
code runs in a browser