Skip to content

Commit 5d20c61

Browse files
authored
Merge pull request #281 from ditrit/feature/add_properties
Feature: update documentation
2 parents 3b900ac + 521c2bc commit 5d20c61

File tree

7 files changed

+475
-238
lines changed

7 files changed

+475
-238
lines changed

changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
77

8+
## [Unreleased]
9+
10+
## Added
11+
12+
- Translation for plugin display name.
13+
14+
## Changed
15+
16+
- Use default file name `logo.svg` for plugin icon.
17+
818
## [0.27.3] - 2024/08/08
919

1020
## Fixed

guides/documentations/configuration.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ In this part, you will see how you can:
5757
- `keysBinding`: Define key binding for actions.
5858
- `i18n`: Define all specific translations of your plugin.
5959

60+
## Logo of your plugin
61+
62+
If you want a specific icon for your plugin, you have to add `logo.svg` inside folder `public/icons`.
63+
6064
## Tag your plugin
6165

6266
To help users understand the usage of your plugin, you can tag it using two types of tags:
@@ -180,15 +184,20 @@ new DefaultConfiguration({
180184
})
181185
```
182186

183-
Currently, Leto-Modelizer utilizes only the parser error translations from the i18n object.
184-
Here is an example of how to add a specific translation key for parser errors:
187+
Currently, Leto-Modelizer uses :
188+
- A display name from the i18n object.
189+
- the parser error translations from the i18n object.
190+
191+
Here is an example of default i18n object:
185192

186193
```js
187194
new DefaultConfiguration({
188195
i18n: {
189196
'en-us': {
197+
displayName: 'Your plugin name.',
190198
parser: {
191199
error: {
200+
// Add translations for parser here.
192201
test: 'test',
193202
},
194203
},

guides/documentations/essentials.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ ComponentAttributeDefinition.js, // Class that defines Component Attributes' dat
2727
ComponentDrawOption.js, // Class that represents option for the Component drawing.
2828
ComponentLink.js, // Class that links Components together.
2929
ComponentLinkDefinition.js, // Class that defines of the link between Components.
30+
ComponentRenderer.js // Class that render each components to draw the diagram.
31+
LinkRenderer.js // Class that render each links to draw the diagram.
3032
ParserLog.js, // Class that represents a parsing log. Used by the DefaultParser as default log.
3133
FileInformation.js, // Class that represents the object to store all file information.
3234
FileInput.js, // Class that represents the object to store the file content.
3335
Tag.js, // Class that represents a tag in Leto-modelizer. Used by the DefaultConfiguration class.
34-
Variable.js, // Class that represents a variable in a file of a diagram. Used by the DefaultData class.
36+
Variable.js // Class that represents a variable in a file of a diagram. Used by the DefaultData class.
3537
```
3638

3739
| Plugin lifecycle |
@@ -41,7 +43,7 @@ Variable.js, // Class that represents a variable in a file o
4143
This is the default lifecycle of plugin usage in Leto Modelizer.
4244

4345
As you can see, plugin-core can be divided in 5 distinct parts:
44-
- Metadata managment
46+
- Metadata management
4547
- Generate components from source files (Parser)
4648
- Generate source files from components (Renderer)
4749
- Draw diagrams
@@ -161,7 +163,11 @@ By default, the DefaultDrawer is using [D3 library](https://d3js.org/) to draw t
161163

162164
### Custom Layout
163165

164-
We use the [Elk library](https://eclipse.dev/elk/) to automatically arrange all components with optimal position. Check out the ElkLayout Class to learn how Elk is used for generating a layout. We structured the code to be able to implement another way of managing the layout. Check out the DefaultLayout Class with `arrangeComponentsPosition` and `repositionComponent` methods that can be overridden to implement your own algorithm for automatic components layout.
166+
We use a custom algorithm to automatically arrange all components with optimal position.
167+
168+
We structured the code to be able to implement another way of managing the layout.
169+
170+
Check out the DefaultLayout Class with `generateComponentsLayout` and `resize` methods that can be overridden to implement your own algorithm for automatic components layout.
165171

166172
### Custom component template
167173

@@ -222,10 +228,9 @@ Here you will find a diagram summarizing the key steps in the plugin-core proces
222228
## Going further
223229

224230
Components have the (internal) id and the external id.
225-
These two differs in their usage, the id is mostly used internally (drawing, links, etc...) and should never be changed once the component is created.
231+
These two differ in their usage, the id is mostly used internally (drawing, links, etc...) and should never be changed once the component is created.
226232
Whereas the external id (defaulted to the id's value), is used for all other purposes and this one is to be seen by the user of Leto-Modelizer.
227-
As the id is used for all internal matters, several components can have the same external id and it won't affect any links or anything else
228-
(for an example see terrator-plugin).
233+
As the id is used for all internal matters, several components can have the same external id, and it won't affect any links or anything else (for an example see terrator-plugin).
229234

230235
Here is a sum up:
231236

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Migrate from version 0.27.2 to 0.X.X
2+
3+
## Add translation for your plugin display name
4+
5+
```js
6+
// Before:
7+
new DefaultConfiguration({
8+
// (...)
9+
i18n: {
10+
'en-US': {
11+
parser: {
12+
error: {
13+
// (...)
14+
},
15+
},
16+
},
17+
}
18+
})
19+
20+
// After:
21+
new DefaultConfiguration({
22+
// (...)
23+
i18n: {
24+
'en-US': {
25+
displayName: 'Your plugin name',
26+
parser: {
27+
error: {
28+
// (...)
29+
},
30+
},
31+
},
32+
}
33+
})
34+
```
35+
36+
## Rename you plugin icon
37+
38+
Before, you certainly have an `public/icons/plugin-name.svg` like `public/icons/terrator-plugin.svg` in terrator-plugin.
39+
40+
Now, you have to rename it in `public/icons/logo.svg`.

guides/svg/template.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,48 @@ This function will return the svg string of the specified icon name from resourc
110110

111111
You have to add ` | safe ` in the templating, **otherwise the image won't be added to the final output**.
112112

113+
### Add custom variable/function
114+
115+
If you want to add custom variable or function, you can override these methods in `DefaultDrawer`:
116+
- `initComponentRenderer`: to customize component rendering.
117+
- `initLinkRenderer`: to customize link rendering.
118+
119+
Here is an example of `DefaultDrawer` overriding:
120+
121+
```js
122+
class CustomComponentRenderer extends ComponentRenderer {
123+
getTemplateData(component) {
124+
return {
125+
...super.getTemplateData(component),
126+
// Your custom variable/function here
127+
toto: 'toto',
128+
};
129+
}
130+
}
131+
132+
class CustomLinkRenderer extends LinkRenderer {
133+
getTemplateData(link) {
134+
return {
135+
...super.getTemplateData(link),
136+
// Your custom variable/function here
137+
toto: 'toto',
138+
};
139+
}
140+
}
141+
142+
class CustomDrawer extends DefaultDrawer {
143+
initComponentRenderer(readOnly) {
144+
return new CustomComponentRenderer(this.pluginData, this.viewport, readOnly);
145+
}
146+
147+
initLinkRenderer(readOnly) {
148+
return new CustomLinkRenderer(this.pluginData, this.viewport, readOnly);
149+
}
150+
}
151+
```
152+
153+
And then you can use `{{ toto }}` in your component/link template.
154+
113155
## Step by step
114156

115157
### 1. Create a valid definition for a component

0 commit comments

Comments
 (0)