Child pages
  • JSDoc Annotations

Versions Compared

Key

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

...

Within Servoy, there is  

The Script Editor in Servoy Developer supports annotating the JavaScript code with JSDoc. 

Annotating JavaScript using JSDoc allows the build process to generate more precise builder markers that, based on the configuration produce either markers of the level ERROR, WARNING or INFO.

As JavaScript is a weaktyped, dynamic language, by default it is not possible to automatically analyse the code to check it's correctness

The JSDoc syntax supported by the Servoy Developer IDE is derived from the JSDoc Toolkit and Google Closure Compiler's support for JavaScript annotation, plus some custom Servoy extensions.

The JSDoc syntax consists of a set of JSDoc tags. Some of these tags require a Type Expression as one of the parameters.

JSDoc:

Code Block

/**

...

*

*

...


 * A simple demo function that outputs some text
 * @author pbakker
 * @private
 *
 * @param {String} text The text that will be written to the output
 * @throws (String)
 * returns Boolean
 *
 * @example
 *
 *
 */
function saySomething(text) {
  if (text == null || text.length == 0) {
    throw "Invalid input!"
  }
  application.output(text);
  return true;
}

Auto generated tempaltes

Control-Shift-J

...

Tag

Syntax & Examples

Context

Comments Impact

Description

@AllowToRunInFind

@AllowToRunInFind

function

Determines if the function will be executes in FindMode when used as an event handler

Custom Servoy JSDoc tag to annotate a function that it can be run if the Form on which the function is ran is in FindMode

@author

@author { userName }

function, variable

 

Tag indicating Indicates the author of the code

@constructor

@constructor

function

 

...

@deprecated

@deprecated

function, variable

Accessing a deprecated variable or calling a deprecated function will produce a builder marker in Servoy Developer

Indicates that the function or variable is obsolete or has been replaced and should be used anymore. Accessing a deprecated variable or calling a deprecated function will produce a builder marker in Servoy Developer

@example

@example

function

 

Tag allowing to provide some sample code how to use the function or variable. Multiline content is possible my including "<br>" as line-breaks behind each line of content

@param

@param {Type} name parameterDescription

function

Builder markers will be generated in Servoy Developer if the function is called with values for the parameters that do no

Describe function parameters. The "name" must match the name of one of the parameters in the function declaration.

@private

@private

function, variable

Accessing a private variable/function from outside the scope in which it is declared will generate a builder marker in Servoy Developer

Annotates a variable or function as accessible only from within the scope1 in scope in which it is declared

@protected

@protected

function, variable

Accessing a protected variable/function from outside the scope in which it is declared or a child scope will generate a builder marker in Servoy Developer

Annotates a variable or function as accessible from within the scope1 in scope in which it is declared and all scopes that extend this scope

@return

@return {Type}

function

The specified type is used by the build process to determine the correctness of the code that uses the returned value

Annotates the type of the returned value

@returns

@returns {Type}

function

see @return

alias for @return

@see

@see seeDescription

function, variable

 

Tag to provide pointers to other parts of the code that are related

@since

@since versionDescription

function, variable

 

Tag to provide information about in which version of the code the variable or function was introduced

@SuppressWarnings

@SuppressWarnings (warnings)

function

Stop the generation of builder markers in Servoy Developer for the specified warnings

Custom Servoy JSDoc tag to suppress builder markers of a certain type within a function

@throws

@throws {Type}

function

 

Tag to describe the type of Exceptions that can be raised when the function is called. Multiple @throws tags are allowed

@type

@type {Type}

variable, inline variable

The specified type is used by the build process to determine the correctness of the code that uses the variable

Tag to specify the type of the value that a variable can hold

@version

@version versionDescription

function, variable

 

Tag to provide information about the version of the code

1 (info) A scope can be either a Form or the globals scope. Only Form can be extended, thus the @protected tag is not relevant for annotating variables and functions within the globals scope

...