JSDoc
JSDoc is a standard way to document your JavaScript code. You can find documentation online : https://devdocs.io/jsdoc/
We highly recommend to document these point to get autocompletion and generated JSDoc.
Business library
For autocompletion and documentation generation, business library need to be defined with a namespace
annotation.
This annotation need to be put on top of the file : /** @namespace Business_library_id */
Every function of the business library should be documented with @memberOf namespace
or @private
annotation like explain below.
Function
On function, you need to document :
@param {parameter_type} variable_name description
@return {result_type} description
TIP
For a better autocompletion, you need to use STEP package as parameter type and return type
/**
* Create a map of attribute id to attribute value from values
* @param {Array.<com.stibo.core.domain.Value>} values an array of attributes from a product
* @param {Array.<string>} variantAttributes array of variant attributes
* @return {Object.<string, string>} a map of attribute id to attribute value
*/
function valuesToMap(values, variantAttributes)
{
...
}
When function is inside a business library you need to document @memberOf namespace
or @private
. This documentation allow autocompletion of function inside business rule using business library or hiding function used only inside business library.
Business rule binding
In order to get autocompletion, create a file binding.js
in directory src/main
. This file will not be compiled by Companion for Delivery.
/**
* @type com.stibo.core.domain.Asset|com.stibo.core.domain.Product|com.stibo.core.domain.Entity|com.stibo.core.domain.Classification
*/
var node;
/**
* @type {com.stibo.core.domain.state.Workflow}
*/
var workflow;
/**
* @type com.stibo.core.domain.Manager
*/
var manager;
function Logger(){}
Logger.prototype.info = function(msg) {};
Logger.prototype.warning = function(msg) {};
/**
*
* @type {Logger}
*/
var logger;