aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorJuergen Ryannel <juergen.bocklage-ryannel@pelagicore.com>2016-11-30 16:52:33 +0100
committerJuergen Ryannel <juergen.bocklage-ryannel@pelagicore.com>2016-11-30 16:52:33 +0100
commit1836bbdcaef92bcba30b0abbba45fcd734bb7421 (patch)
tree3f15fd99d33dee4c79a7fed7f5df33b4c50948c2 /docs
parent0ebb0bfc808aab1d2dff5a97b04ea73b242a1d03 (diff)
updated usage docs
Diffstat (limited to 'docs')
-rw-r--r--docs/usage.md (renamed from docs/usage.rst)71
1 files changed, 33 insertions, 38 deletions
diff --git a/docs/usage.rst b/docs/usage.md
index b3262a8..d45669d 100644
--- a/docs/usage.rst
+++ b/docs/usage.md
@@ -1,5 +1,4 @@
-Usage
-=====
+# Usage
QFace requires one or more IDL files as input file and a generator to produce output files. The IDL files are named QDL (Qt definition language).
@@ -7,42 +6,40 @@ There is a central client to interface the commands for generation, called cli.
To use an existing generator just provide the path to the generator script.
-.. image:: qface_concept.png
+![concept](qface_concept.png)
-.. code-block:: sh
-
- ./cli.py generator --generator generator/csv --input input --output output
+```sh
+./cli.py generator --generator generator/csv --input input --output output
+```
You can also create a YAML configuration file (e.g csv.yaml):
-.. code-block:: yaml
-
- generator: generator/csv
- input: input
- output: output
+```yaml
+generator: generator/csv
+input: input
+output: output
+```
And then call the client with:
-.. code-block:: sh
-
- ./cli.py generate --runner csv.yaml
+```sh
+./cli.py generate --runner csv.yaml
+```
To enable auto-live reloading just use the monitor target:
-.. code-block:: sh
-
- ./cli.py generator_monitor --runner csv.yaml
+```sh
+./cli.py generator_monitor --runner csv.yaml
+```
This will observe the generator folder and the input folder for changes and re-run the generator.
-Grammar
-=======
+## Grammar
The IDL grammar is described in the grammar file (see qface/parser/idl/T.g4)
-.. code-block:: html
-
+```html
module <identifier> <version>;
[import <identifier> <version>];
@@ -66,15 +63,13 @@ The IDL grammar is described in the grammar file (see qface/parser/idl/T.g4)
struct <identifier> {
<type> <name>;
}
+```
-
-Domain Model
-============
+## Domain Model
The IDL is converted into an in memory domain model (see qface/idl/domain.py).
-.. code-block:: yaml
-
+```yaml
- System
- Module
- Import
@@ -85,28 +80,27 @@ The IDL is converted into an in memory domain model (see qface/idl/domain.py).
- Enum
- Flag
- Struct
+```
The domain model is the base for the code generation.
-Code Generation
-===============
+## Code Generation
The code generation is driven by a small script which iterates over the domain model and writes files using a template language (see http://jinja.pocoo.org) and espcially the template designer documentation (http://jinja.pocoo.org/docs/dev/templates/).
-.. code-block:: python
+```python
+from qface.generator import FileSystem, Generator
- from qface.generator import FileSystem, Generator
-
- def generate(input, output):
- system = FileSystem.parse_dir(input)
- generator = Generator(searchpath='templates')
- ctx = {'output': output, 'system': system}
- generator.write('{{output}}/modules.csv', 'modules.csv', ctx)
+def generate(input, output):
+ system = FileSystem.parse_dir(input)
+ generator = Generator(searchpath='templates')
+ ctx = {'output': output, 'system': system}
+ generator.write('{{output}}/modules.csv', 'modules.csv', ctx)
+```
This script reads the input directory returns a system object form the domain model. This is used as the root object for the code generation inside the template language.
-.. code-block:: jinja
-
+```jinja
{% for module in system.modules %}
{%- for interface in module.interfaces -%}
SERVICE, {{module}}.{{interface}}
@@ -118,5 +112,6 @@ This script reads the input directory returns a system object form the domain mo
ENUM , {{module}}.{{enum}}
{% 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.