From 9ff2ec7ec52b1e29eebe7147f87fbc3048adb29c Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Sat, 2 May 2020 11:50:27 -0400 Subject: [PATCH] Document that proc named fooTask is created for every foo task [backport] (#14187) Ref: https://irclogs.nim-lang.org/01-05-2020.html#15:18:03 (cherry picked from commit 0880f118d377f05067ddcdcf7788d2706c5f0c3a) --- lib/system/nimscript.nim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/system/nimscript.nim b/lib/system/nimscript.nim index f2a843652e..ceaaef0135 100644 --- a/lib/system/nimscript.nim +++ b/lib/system/nimscript.nim @@ -384,11 +384,26 @@ when not defined(nimble): template `==?`(a, b: string): bool = cmpIgnoreStyle(a, b) == 0 template task*(name: untyped; description: string; body: untyped): untyped = ## Defines a task. Hidden tasks are supported via an empty description. + ## ## Example: ## ## .. code-block:: nim ## task build, "default build is via the C backend": ## setCommand "c" + ## + ## For a task named ``foo``, this template generates a ``proc`` named + ## ``fooTask``. This is useful if you need to call one task in + ## another in your Nimscript. + ## + ## Example: + ## + ## .. code-block:: nim + ## task foo, "foo": # > nim foo + ## echo "Running foo" # Running foo + ## + ## task bar, "bar": # > nim bar + ## echo "Running bar" # Running bar + ## fooTask() # Running foo proc `name Task`*() = setCommand "nop" body