summary refs log tree commit diff stats
diff options
context:
space:
mode:
authortechnicallyagd <43739261+technicallyagd@users.noreply.github.com>2018-10-17 18:51:51 +0800
committerAndreas Rumpf <rumpf_a@web.de>2018-10-17 12:51:51 +0200
commit88adf775691411a526c18d82b1e6bd83b653f343 (patch)
treea6d7900bf6cf8fb3cb05dd4e12bc45a7a4c70929
parentdc72cf7564a66236559e53f10f6acc153d15aa40 (diff)
downloadNim-88adf775691411a526c18d82b1e6bd83b653f343.tar.gz
Elaborate on source code filter usage in the documentation. (#9407)
* Elaborate on source code filter usage.
Also gives it an abbreviation, SCF.

* Fix the code block formatting

* Trim off the unintended usage with import.
-rw-r--r--doc/filters.rst21
1 files changed, 17 insertions, 4 deletions
diff --git a/doc/filters.rst b/doc/filters.rst
index 1937b187c..e8106749e 100644
--- a/doc/filters.rst
+++ b/doc/filters.rst
@@ -4,7 +4,7 @@ Source Code Filters
 
 .. contents::
 
-A `Source Code Filter` transforms the input character stream to an in-memory
+A `Source Code Filter (SCF)`  transforms the input character stream to an in-memory
 output stream before parsing. A filter can be used to provide templating
 systems or preprocessors.
 
@@ -23,10 +23,23 @@ just like an ordinary procedure call with named or positional arguments. The
 available parameters depend on the invoked filter. Before version 0.12.0 of
 the language ``#!`` was used instead of ``#?``.
 
-**Hint:** With ``--hint[codeBegin]:on```or ``--verbosity:2``
-(or higher) Nim lists the processed code after each filter
-application.
+**Hint:** With ``--hint[codeBegin]:on`` or ``--verbosity:2``
+(or higher) while compiling or `nim check`, Nim lists the processed code after
+each filter application.
 
+Usage
+=====
+
+First, put your SCF code in a separate file with filters specified in the first line. 
+**Note:** You can name your SCF file with any file extension you want, but the conventional extension is ``.tmpl``.
+
+If we use `generateXML` code shown above and call the SCF file `xmlGen.tmpl`
+In your `main.nim`:
+
+.. code-block:: nim
+  include "xmlGen.tmpl"
+  
+  echo generateXML("John Smith","42")
 
 Pipe operator
 =============