nim doc --backend:js, nim doc --doccmd:-d:foo, nim r --backend:js, --doccmd:skip + other improvements (#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
This commit is contained in:
Timothee Cour 2020-05-11 03:01:18 -07:00 • committed by GitHub
commit 9502e39b63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 213 additions and 99 deletions

36
tests/nimdoc/m13129.nim Normal file
View file

@ -0,0 +1,36 @@
when defined(cpp):
{.push header: "<vector>".}
type
Vector[T] {.importcpp: "std::vector".} = object
elif defined(js):
proc endsWith*(s, suffix: cstring): bool {.noSideEffect,importjs: "#.endsWith(#)".}
elif defined(c):
proc c_printf*(frmt: cstring): cint {.
importc: "printf", header: "<stdio.h>", varargs, discardable.}
proc main*() =
runnableExamples:
import std/compilesettings
doAssert not defined(m13129Foo1)
doAssert defined(m13129Foo2)
doAssert not defined(nimdoc)
echo "ok2: backend: " & querySetting(backend)
# echo defined(c), defined(js),
import std/compilesettings
when defined nimdoc:
# import std/compilesettings
static:
doAssert defined(m13129Foo1)
doAssert not defined(m13129Foo2)
echo "ok1:" & querySetting(backend)
when isMainModule:
when not defined(js):
import std/os
let cache = querySetting(nimcacheDir)
doAssert cache.len > 0
let app = getAppFilename()
doAssert app.isRelativeTo(cache)
doAssert querySetting(projectFull) == currentSourcePath
echo "ok3"

2
tests/nimdoc/readme.md Normal file
View file

@ -0,0 +1,2 @@
the html validation is tested by nimdoc/tester.nim
the runnableExamples + nim doc logic (across backend) is tested here