Skip to main content

JavaScript

Work In Progress
This page is a work in progress, accuracy of the content is not guaranteed and is subject to change at any time.

This section guides the documentation of JavaScript APIs. This includes best practices and formatting niches for writing JSDoc 'doc comments' above components, with the goal of generating API documentation.

The markup language JSDoc is used to document JavaScript components. JSDoc’s tags are designed to handle JavaScript’s dynamic behaviour, such as event firing.

tip

Writing JSDoc comments in Visual Studio Code (VSC) need not be assisted with a library nor extension, as VSC's built-in JavaScript support includes support for JSDoc.

Below is an example of a JSDoc doc comment:

/**
* Retrieves an item value for a given item name.
* @param {string} name - The name of the item to retrieve.
* @returns {Promise<string>} A promise that resolves to the item value.
*/
export async function getItem(name) {
// TODO: get item
}

If doc comments are formatted as required by the open-source library jsdoc-to-markdown, API documentation in the Markdown language can be generated via the command line.