Difference between revisions of "Projects/KDevelop4/Plugins: Code Generation"

Jump to: navigation, search
m
Line 6: Line 6:
 
* Generator
 
* Generator
  
== Template ==
+
== Resources ==
 +
=== Template ===
 
The template define the body of the generated code.
 
The template define the body of the generated code.
  
 
Templates syntax is the same as the [http://www.grantlee.org/apidox/for_themers.html Grantlee templates syntax]. All features provided by its engine are available.
 
Templates syntax is the same as the [http://www.grantlee.org/apidox/for_themers.html Grantlee templates syntax]. All features provided by its engine are available.
  
== Context ==
+
=== Context ===
 
{{Note|The context handles both the user interface and the data available to the template.}}
 
{{Note|The context handles both the user interface and the data available to the template.}}
  
Line 20: Line 21:
 
For convenience, all variables defined in a context are included in a namespace. It enables the use of several contexts into a single template without variables names conflict.
 
For convenience, all variables defined in a context are included in a namespace. It enables the use of several contexts into a single template without variables names conflict.
  
=== Global contexts ===
+
==== Global contexts ====
 
Many global contexts are always available in any template. They give data which does not need to be configurable by the end-user.
 
Many global contexts are always available in any template. They give data which does not need to be configurable by the end-user.
  
 
Currently available global contexts are :
 
Currently available global contexts are :
==== environment ====
+
===== environment =====
==== file ====
+
===== file =====
==== class ====
+
===== class =====
==== function ====
+
===== function =====
  
 
=== Generator ===
 
=== Generator ===
Line 34: Line 35:
 
The generator also define outputs. Each template is associated to one output where generated code will be put.
 
The generator also define outputs. Each template is associated to one output where generated code will be put.
 
{{Note|A generator will result as a new entry in the Code Generation menu.}}
 
{{Note|A generator will result as a new entry in the Code Generation menu.}}
 +
 +
== Files organization ==
  
 
== See also ==
 
== See also ==
{{UserbaseLink}}
+
{{UserbaseLink|KDevelop4/Manual/Plugins:_Code_Generation}}

Revision as of 20:10, 3 March 2011

KDevelop Code Generation plugin uses Grantlee template engine to generate code (like classes, functions, code documentation etc.).

The goal of KDevelop's Grantlee implementation is to provide a very flexible template system. The architecture is based on 3 main concepts which results as resources for the plugin:

  • Template
  • Context
  • Generator

Contents

Resources

Template

The template define the body of the generated code.

Templates syntax is the same as the Grantlee templates syntax. All features provided by its engine are available.

Context

noframe
 
Note
The context handles both the user interface and the data available to the template.

The user interface is what the end-user uses to configure the template. You should use Qt UIs files created with Qt Designer to define your own context.

Code Generation plugin uses form fields to generate data. Typically, binary valued fields (checkboxs) will result as booleans, single valued fields (text fields, text areas, single selection lists, radio buttons) as strings and multi valued fields (multiple selection lists) as lists of strings.

For convenience, all variables defined in a context are included in a namespace. It enables the use of several contexts into a single template without variables names conflict.

Global contexts

Many global contexts are always available in any template. They give data which does not need to be configurable by the end-user.

Currently available global contexts are :

environment
file
class
function

Generator

The generator contains the templates and contexts used to generate a coherent object (a class, a function, the documentation for an item in the code etc.).

The generator also define outputs. Each template is associated to one output where generated code will be put.

noframe
 
Note
A generator will result as a new entry in the Code Generation menu.

Files organization

See also

The KDevelop4/Manual/Plugins:_Code_Generation page on Userbase.


KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal