Child pages
  • JSDoc Annotations
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

When writing  Servoy Developer IDE

The Script Editor in the Servoy Developer IDE supports annotating JavaScript code using JSDoc. Documenting the code is a good practise, as it makes it easier to understand the code after a while or if another programmer needs to have a look at it.

Within Servoy, there is  

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:

/**

*

*

*/

Auto generated tempaltes

Control-Shift-J

Code Completion

JSDoc Tags

Tag

Syntax & Examples

Comments

@AllowToRunInFind

@AllowToRunInFind

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}

 

@constructor

@constructor

 

@deprecated

@deprecated

 

@example

@example

 

@param

@param {Type} name parameterDescription

 

@private

@private

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

@protected

@protected

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

@return

@return {Type}

 

@returns

@returns {Type}

alias for @return

@see

@see seeDescription

 

@since

@since versionDescription

 

@SuppressWarnings

@SuppressWarnings (warning)

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

@throws

@throws {Type}

 

@type

@type {Type}

 

@version

@version versionDescription

 

Type Expressions

Type Expressions are used to describe the type and/or structure of data in the following cases:

 

 

 

function parameters

/**
 * @param {String} value Just some string value
 */
function demo(value)
{...}

 

function return type

/**
 * @param {String} value Just some string value
 * @return x:Number, y:Number  */
function demo(value) {
   ...
   return {x: 10, y: 20}
}

 

variables

/**
 * @type {XML}
 */
var html = <html>
   <head>
   </head>
   <body>
      Hello World!
   </body>
</html>

 

 

 

 

A Type Expression is to always be surrounded by curly braces: {typeExpression}. Note that when using the Object Type expression variation that start and stops with curly braces as well, this results in double opening and closing braces.

Expression name

Syntax example

Comments

Named type

{String}
{Boolean}
{Number}
{XML}
{XMLList}
{RuntimeForm}
{RuntimeLabel}
{JSButton}
{JSForm}

 

AnyType

{*}

 

OR Type

{String|Number}

 

REST Type

{...String}

 

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="415c7a4a-279a-4d76-be8c-1061b31cb738"><ac:plain-text-body><![CDATA[

Array Type

{String[]} 
]]></ac:plain-text-body></ac:structured-macro>
{Array<String>} 
{Array<Byte>}

 

Object Type

{Object<String>} 
{Object<Array<String>>} 
{name:String, age:Number}} 

 

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="5f37b665-ea05-4a42-bea1-4d4c05d65bed"><ac:plain-text-body><![CDATA[

Object Type with optional properties

{ {sDocID:String, [sTemplateID]:String}}
]]></ac:plain-text-body></ac:structured-macro>
{ {sDocID:String, sTemplateID:String=}}

 

JSFoundSet type

{JSFoundset<db:/udm/contacts>} 
{JSFoundset<{column1:String, column2:Number}>}

 

JSRecord type

{JSRecord<db:/udm/contacts>} 
{JSRecord<{column1:String, column2:Number}>}

 

JSDataSet type

{JSDataSet<{name:String, age:Number}>}

 

RuntimeForm Type

{RuntimeForm<superFormName>}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Adding whatever tag you like

Code completion

JSDoc Templates

Tip: Check out the JSDoc plugin for Servoy Developer on ServoyForge

Old 5.x style of annotating:

JSRecord:servername.tablename

JSFoundset :servername.tablename

Form:formname

  • No labels