CompanionCompanion
Companion for Delivery
Companion for Business
Companion for Integration
Contact us
Companion for Delivery
Companion for Business
Companion for Integration
Contact us
  • Companion for Delivery

    • Introduction
    • Installation
    • Project
  • Developer

    • Compiler
    • Decompiler
    • Diff
    • Incremental Build
    • Twirl
    • Companion Twirl Templates
    • Sheet to Xml
    • Tests
    • JSDoc
    • STEP API Autocomplete
    • Integrated Development Environment (IDE)
  • Devops

    • Continuous Integration (CI)
    • SonarQube
    • Maven configuration
  • STEPdoc
  • Example
  • FAQ

    • How to
    • Troubleshooting
  • Changelog

    • Changelog Companion for Delivery
    • Changelog Companion Twirl Templates
    • Changelog Companion Test Helpers

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

Tips

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;
Last Updated: 8/10/22, 2:19 PM
Prev
Tests
Next
STEP API Autocomplete