diff options
author | Araq <rumpf_a@web.de> | 2017-11-26 02:51:11 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-11-26 02:51:11 +0100 |
commit | 8d1a5dc8e7b10d5980dc1ce06dce0739caaa7d06 (patch) | |
tree | d2e5a1626c0b16bdcc46af959279a7c8e24bdcea /lib/system.nim | |
parent | c1782fac2195bf9e82ee38d1e52ae981e2f78229 (diff) | |
download | Nim-8d1a5dc8e7b10d5980dc1ce06dce0739caaa7d06.tar.gz |
the documentation generator now supports system.runnableExamples
Diffstat (limited to 'lib/system.nim')
-rw-r--r-- | lib/system.nim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim index 1b53bf9f5..323ff00e6 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -3992,3 +3992,20 @@ when defined(windows) and appType == "console" and defined(nimSetUtf8CodePage): proc setConsoleOutputCP(codepage: cint): cint {.stdcall, dynlib: "kernel32", importc: "SetConsoleOutputCP".} discard setConsoleOutputCP(65001) # 65001 - utf-8 codepage + + +when defined(nimHasRunnableExamples): + proc runnableExamples*(body: untyped) {.magic: "RunnableExamples".} + ## A section you should use to mark `runnable example`:idx: code with. + ## + ## - In normal debug and release builds code within + ## a ``runnableExamples`` section is ignored. + ## - The documentation generator is aware of these examples and considers them + ## part of the ``##`` doc comment. As the last step of documentation + ## generation the examples are put into an ``$file_example.nim`` file, + ## compiled and tested. The collected examples are + ## put into their own module to ensure the examples do not refer to + ## non-exported symbols. +else: + template runnableExamples*(body: untyped) = + discard |