Child pages
  • Replaced the IScriptObject with IScriptable, making it possible to document the API of plugins through JavaDocs

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A plugin must annotate itself so that the Document Generator Tool knows what to get. Servoy has a special annotation called @ServoyDocumented. The annotation can have additional attributes to specify the public and scripting names. Below a sample of the FilePlugin:

Code Block

@ServoyDocumented(publicName = FilePlugin.PLUGIN_NAME, scriptingName = "plugins." + FilePlugin.PLUGIN_NAME)
public class FileProvider implements IReturnedTypesProvider, IScriptable

For returnTypes like JSFile the @ServoyDocumented annotation marks a class for documentation:

Code Block

@ServoyDocumented
public class JSFile implements IScriptable, IJavaScriptType

...

If a method is annotated with the special annotation @JSReadOnlyProperty, it will bee considered a readonly property of the plugin.

Code Block

/**
 * This is a readonly property
 */
@JSReadOnlyProperty
public String myPropertyVersion()
{
     return "version 1.0";
}

Two methods using the @JSGetter and @JSSetter properties can be used to create a property of the plugin, as follows:

Code Block

@JSGetter
public String getSomeProperty()
{
     //...
}

@JSSetter
public void setSomeProperty(String someProperty)
{
     //...
}

...

If a method is annotated with the @JSFunction property it will be considered a JavaScript function:

Code Block

@JSFunction
public String myFunction(String myParameter)
{
     //...
}

...

If a method should be marked as deprecated, the new documentation generator tool also takes into consideration the @Deprecated annotation:

Code Block

@Deprecated
public void neverRetire()
{
     //...
}

...

Methods can be documented according to the sample below:

Code Block

/**
 * This is the method description.
 *
 * @sample
 * var message = someMethod('someParameter');
 *
 * @param simpleParameterName this is a simple parameter name
 *
 * @return what the method returns
 */
public String js_someMethod(String simpleParameterName)
{
     //...
}

...

The @param tag supports so-called rest parameters by using  '...' prefix. It also supports marking parameters as optional. The following example is the button a optional and variable arguments parameter

Code Block
  @param ...button optional

If you want to use a JSDoc notation in your sample code for example to type a specific variable, so /** @type {JSFile} */. Then the last / must be escaped by using the ascii notation:

Code Block
  /** @type {JSFile} */

...

In order to have the method documentation available, in JavaScript, you must the documentation generation tool installed, in the Eclipse in which you are developing the plugin code (along with its documentation). The documentation generation tool must be installed via Eclipse update sites. From the Servoy Developer, via Help->Install New Software, add the http://wwwdownload.servoy.com/documentbuilder url as an update site and install the documentation generator (Servoy Documentation Generator Feature). It will show up under installed software as the Servoy Documentation Generator Feature.

...