summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-05-20 00:45:34 -0700
committerGitHub <noreply@github.com>2020-05-20 09:45:34 +0200
commit3d20f141939b0cb76079a9b0ae7784f7877f1698 (patch)
treeff6c7b9943309b0df409be3c15143ffad56b0e9f /lib
parent4ae341353de5c58dc339e47b0eec2bbb4649dc10 (diff)
downloadNim-3d20f141939b0cb76079a9b0ae7784f7877f1698.tar.gz
fix #10731 ; `runnableExamples "-b:cpp --run:off": code` works (#14384)
* runnableExamples "-b:cpp -r:off": code
Diffstat (limited to 'lib')
-rw-r--r--lib/system.nim11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/system.nim b/lib/system.nim
index e5b359c70..85be43cba 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -117,7 +117,7 @@ else:
     Ordinal* = OrdinalImpl | uint | uint64
 
 when defined(nimHasRunnableExamples):
-  proc runnableExamples*(body: untyped) {.magic: "RunnableExamples".}
+  proc runnableExamples*(rdoccmd = "", body: untyped) {.magic: "RunnableExamples".}
     ## A section you should use to mark `runnable example`:idx: code with.
     ##
     ## - In normal debug and release builds code within
@@ -139,10 +139,15 @@ when defined(nimHasRunnableExamples):
     ##       assert double(5) == 10
     ##       block: ## at block scope
     ##         defer: echo "done"
-    ##
     ##     result = 2 * x
+    ##     runnableExamples "-d:foo -b:cpp":
+    ##       import std/compilesettings
+    ##       doAssert querySetting(backend) == "cpp"
+    ##     runnableExamples "-r:off": ## this one is only compiled
+    ##        import std/browsers
+    ##        openDefaultBrowser "https://forum.nim-lang.org/"
 else:
-  template runnableExamples*(body: untyped) =
+  template runnableExamples*(doccmd = "", body: untyped) =
     discard
 
 proc declared*(x: untyped): bool {.magic: "Defined", noSideEffect, compileTime.}