Files organization

Each resource directory can contain directories to organize files in categories (typically, a directory by language).

Then the files can be placed in a category directory or in directly in a resource directory, if the template/context/generator does not concern a specific language.

Configuring templates

For each template, 2 files should be created:

the template file itself, with the .tpl extension

a .rc configuration file

The file hierarchy may look like this:

codegeneration/

templates/

cpp/

class.tpl

class.rc

function.tpl

function.rc

php/

contexts/

cpp/

class.ui

php/

generators/

The template configuration file is handled as a KConfig file:

templates/cpp/class.rc

[Template]contexts=cpp/class.uiincludes=cpp/function.tpl
</code>
:The '''contexts''' value is a list of context names
:The '''includes''' values is a list of template names. It contains the templates included into the current template with the '''{% include %}''' directive. It seems repetitive but it is necessary to allow the plugin to load the contexts needed by the included templates (until Grantlee provide an API to parse template files).
=== Configuring generators ===
Creating a generator consists in creating a '''.rc''' config file.
:*codegeneration/
:**templates/
:***cpp/
:****''class.tpl''
:****''class.rc''
:****''function.tpl''
:****''function.rc''
:***php/
:**contexts/
:***cpp/
:****''class.ui''
:***php/
:**generators/
:***cpp/
:***'''''class.rc'''''
As the template configuration file, the generator configuration file is is handled as a '''KConfig''' file:
<div class="codebox">
<div class="codebarbg">generators/cpp/class.rc</div>
<code ini n>
[Generator]actionName=Create classdesciption=Create a simple C++ class with member functions.[Files]templates=cpp/class.tploutputs=<classname>.cpp
</code>
</div>
:The '''actionName''' value is the name of your generator like it appears in the Code Generation menu.
:The '''description''' value is a short description of your generator used to display a tooltip.
== See also =={{UserbaseLink|KDevelop4/Manual/Plugins:_Code_Generation}}