-
Notifications
You must be signed in to change notification settings - Fork 3
Template configuration
Thomas Rößl edited this page Oct 15, 2023
·
6 revisions
The flowchart nodes are configured with JSON files. Each node type has a corresponding configuration.
These configurations are found in the flowtutor directory under templates, each available language has its own directory.
- label: The name of the node shown to the user (e.g. on button labels).
- node_label (optional): The text that is displayed on the drawn node in the flowchart. Can be a Jinja template string (see also the body property).
- shape_id: The shape of the node. Can be one of the following:
- data
- data_internal
- process
- predefined_process
- preparation
- decision
- terminator
- data
- control_flow (optional):
- loop
- post-loop
- decision
- loop
- color (optional): The color of the node, defined by its RGB values
- parameters: The user-facing parameters, that can be changed when using the node. A parameter has the following properties:
- name: The name that is referenced in the template body, to insert the argument.
- label: The user-facing label of the parameter.
- default (optional): The default value of the parameter.
- options (optional): A predefined list of values, that the parameter is constrained to. The user is presented with a dropdown.
- visible: An expression in Python syntax, that can reference other parameters, to conditionally hide this parameter.
- body (optional): A string that is inserted in the source code. If this value is omitted, a Jinja template file of the same name as the configuration must be present (e.g. for
while-loop.template.jsonthere has to be a file calledwhile-loop.jinja). Documentation for the Jinja template syntax can be found here.
{
"label": "Open file",
"node_label": "Open file: {{FILE}} as {{VAR_NAME}}",
"shape_id": "data",
"color": "(147, 171, 255)",
"parameters": [
{
"name": "VAR_NAME",
"label": "Name"
},
{
"name": "FILE",
"label": "File Path"
},
{
"name": "MODE",
"label": "Mode",
"default": "r",
"options": [
"r",
"r+",
"w",
"w+",
"a",
"a+"
]
}
]
}FILE *{{VAR_NAME}};
{{VAR_NAME}} = fopen({{FILE}}, "{{MODE}}");{
"label": "Declaration",
"node_label": "{% if IS_STATIC %}static {% endif %}{{VAR_TYPE}} {% if IS_POINTER %}*{% endif %}{{VAR_NAME}}{% if IS_ARRAY %}[{{ARRAY_SIZE}}]{% endif %}{% if VAR_VALUE %} = {{VAR_VALUE}}{% endif %}",
"shape_id": "data_internal",
"parameters": [
{
"name": "VAR_NAME",
"label": "Name"
},
{
"name": "VAR_TYPE",
"label": "Type",
"default": "int",
"options": [
"char",
"unsigned char",
"short",
"unsigned short",
"int",
"unsigned int",
"long",
"unsigned long",
"float",
"double",
"long double"
]
},
{
"name": "IS_POINTER",
"label": "Pointer",
"type": "checkbox"
},
{
"name": "IS_ARRAY",
"label": "Array",
"type": "checkbox"
},
{
"name": "ARRAY_SIZE",
"label": "Size",
"visible": "IS_ARRAY"
},
{
"name": "IS_STATIC",
"label": "Static",
"type": "checkbox"
},
{
"name": "VAR_VALUE",
"label": "Value"
}
],
"body": "{% if IS_STATIC %}static {% endif %}{{VAR_TYPE}} {% if IS_POINTER %}*{% endif %}{{VAR_NAME}}{% if IS_ARRAY %}[{{ARRAY_SIZE}}]{% endif %}{% if VAR_VALUE %} = {{VAR_VALUE}}{% endif %};"
}