From 8d1a5dc8e7b10d5980dc1ce06dce0739caaa7d06 Mon Sep 17 00:00:00 2001 From: Araq Date: Sun, 26 Nov 2017 02:51:11 +0100 Subject: the documentation generator now supports system.runnableExamples --- lib/system.nim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/system.nim') 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 -- cgit 1.4.1-2-gfad0