Creating Variables for Imported Templates with M2Doc

Hello everyone,

I’m trying to implement an already exiting template into Capella to modify it with M2Doc.
I’ve successfully imported the template, but I’m facing an issue with setting the initial variable, known as ‘self’ in the documentation.

When clicking on the implemented template and initializing the documentation configurations, I can create a genconf file, but I can’t select a variable.

grafik
As shown in the window above, I’ve tried loading a resource to set the variable. Therefore, I clicked on Browse Workspace, selected the file ‘my_project_name.capella’, but after clicking on ‘OK’, nothing happens and the Variables tabel remains empty (selecting ‘my_project_name.aird’ crashes capella).

To register the tempalte, I’ve created a plug-in project and added the necessary extension at the end of the plugin.xml file as in this example: plugin.xml. After installing the plug-in, the import process (Import → M2Doc → Import Template) works.

Did I miss something while creating the plug-in or is there another reason why I cannot select a variable?

Thank you for your help!

Falk

In the option tab you should check is you have the ‘SiriusSession’ option defined to reference the .aird file of your Capella project (relative path from the .genconf file). This will load the Capella model and you should be able to edit your variable after.

Your plugin.xml is fine if you can either reference your template in a .genconf file or import the template in the workspace.

Thank you for the reply!

Unfortunately, the ‘SiriusSession’ is defined to reference the .aird file, and the problem still persists.
( I created a new project and plug-in to see if the problem still occurs…which it does :frowning: )

I am able to locate the ‘.capella’ file when trying to set a variable in the .genconf file:


However, after selecting the file and attempting to load the resourse: ‘platform:/resource/SampleProject/SampleProject.capella’ and pressing ‘OK’, nothing appears in the table.

As for the plug-in, I created a new plug-in project using the custom plug-in wizard template and added ‘Project Builder and Nature’ as well as ‘template.commonNavigator.name’ (I’m not sure if these are necessary).
Then, I added dependencies for ‘org.obeonetwork.m2doc.ide (3.1.1)’, copied the template into the plug-in folder, and added the following extension in the plugin.xml (changed the URI to the path of the template):

point=“org.obeonetwork.m2doc.ide.templates.register”>
template
name=“Sample template”
uri=“platform:/plugin/sample-template-plugin/sampleTemplate.docx”>

(The formatting is not 100% correct otherwise html will not print the code)

In my MANIFEST.MF file I checked that singelton:=true

Finally, I exported the plug-in project as a ‘Deployable plug-ins and fregments’ and installed it directly into the host. After restarting capella, I can import the template, (M2Doc-> Import Template):

While importing the template, I just select the Capella project folder as the ‘parent folder’. In the template properties, I added the ‘Capella’ packages, nothing else. Are there any other nsURIs requiered?
After initzialising the ‘.genconf’ file and confirming that the SiriusSession is referencing to the ‘.aird’ file, unfortunately, I still cannot select the variable.

Do you know if/ where I made a mistake in this process of building the plug-in or importing the template?

Thank you for any help :slight_smile:!

Falk

I just noticed you don’t have any variable in the list. You need to write a first expression in your template (use CTRL+F9 in word to create the field), for instance:

{m:myVariable}

Then you need to define the type of this variable in the template properties wizard you might need to add nsURIs for your metamodels in this wizard so the needed type is listed.

The variable is then listed for initialization be the genconf wizard.

Note: the plugin packaging is not required to create the genconf file

Thank you very much, now it is working!
I spent quite much time looking for the possible cause…all the better that it was so easy to fix :slight_smile: .
Have a nice day and a good weekend!

1 Like