Skip to content

Creating a new module

Giorgio Bianchini edited this page Mar 22, 2023 · 4 revisions

TreeViewer modules can be created easily using the Module creator function, which is accessible from the Edit menu of the main window.

When the Module creator menu item is clicked, the program will restart and open the Module creator window.

In this window, you can create a new module by selecting one of the Templates on the left side; if you have already created some modules, a list of recently created modules will also be present in the right half of the window, from which you can easily recover them and keep working on them.

After you select a template or open a recent module file, the window will update to feature a source code editor containing the template for the kind of module that you selected or the source code of the module.

You can then start editing the source code to create the module. A description of how the various kinds of modules should be authored is available in the page about module templates.

Opening the Manual tab shows a preview of the manual for the module, which is generated automatically based on the module and on documentation comments (see the page Documenting modules).

To finish coding the module and test it, click on the OK button at the bottom of the window. This will close the Module creator window and open TreeViewer, loading your newly created module.

If you are happy with how the module works, you can export it as a module.json.zip file from the Module manager window: select the Module manager... item from the Edit menu, then find your module among the list of loaded modules and export it using the Export... option from the Module menu.

If you would like to make some changes to the module code, you should use again the Module creator... option from the Edit menu. Again, this will cause the program to restart and open with the Module creator window. Here, instead of choosing a template to start creating a new module from scratch, you can select the module you were working with earlier from the Recent Files list.

Note that if you close TreeViewer without exporting your module, the module will not be loaded again when you re-open the program. To recover and re-load the module, you will have to open the Module creator window and locate it in the Recent Files section.

If you close the Module creator window by clicking on the "Cancel" button, the new module will be discarded (but autosaves and manual saves will be preserved in the Recent files) and TreeViewer will open as normal.

The typical workflow for creating a new module is as follows:

  1. If you wish to create a Further transformation or Plot action module, start by creating a Custom script that performs the action.

  2. Create the new module and debug it using fixed parameter values (note that you can set breakpoints in the Module creator window, and this may help immensely when tracking down bugs).

  3. Alter the module to allow users to change parameter values (if this is applicable).

  4. Inspect the automatically generated documentation and amend it where necessary.

  5. Export the module as a module.json.zip file.

  6. If you believe that your module could be of general interest to other people, contact the owners of this repository to inquire about including it in the module repository.

Furthermore, if you wish to develop a new module, it might be helpful to look at the source code for an existing module of the same type as the module you wish to create. The source code for the modules included in the Module repository is available here.

A description of the module templates can be found in the relevant page.

Clone this wiki locally