diff options
Diffstat (limited to 'docs/extending.rst')
-rw-r--r-- | docs/extending.rst | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/docs/extending.rst b/docs/extending.rst index 74aa761..df751c2 100644 --- a/docs/extending.rst +++ b/docs/extending.rst @@ -1,10 +1,12 @@ -=============== +*************** Extending QFace -=============== +*************** -QFace is easy to use and easy to extend. Your generator is just a small python script using the qface library. +QFace is easy to use and easy to extend. Your generator is just a small python +script using the qface library. -The script iterates over the domain model and writes files using a template language. +The script iterates over the domain model and writes files using a template +language. See template engine documentation: @@ -20,15 +22,20 @@ See template engine documentation: # parse the interface files system = FileSystem.parse(input) # setup the generator - generator = Generator(searchpath='templates') + generator = Generator(search_path='templates') # create a context object ctx = {'output': output, 'system': system} # apply the context on the template and write the output to file generator.write('{{output}}/modules.csv', 'modules.csv', ctx) -This script reads the input directory returns a system object from the domain model. This is used as the root object for the code generation inside the template. +This script reads the input directory returns a system object from the domain +model. This is used as the root object for the code generation inside the +template. The context object is applied to the file path as also on the named +template document. The output of the template is then written to the given file +path. -Below is a simple template which geenrates a CSV document of all interfaces, structs and enums. +Below is a simple template which generates a CSV document of all interfaces, +structs and enums. .. code-block:: jinja @@ -44,4 +51,5 @@ Below is a simple template which geenrates a CSV document of all interfaces, str {% endfor -%} {% endfor %} -The template iterates over the domain objects and generates text which is written into a file. The file name is also adjustable using the same template language. +The template code iterates over the domain objects and generates text using a +mixture of output blocks ``{{}}`` and control blocks ``{%%}``. |