Search code examples
google-apps-scriptjsdoc

What do comments with @param and @return mean in Google App Scripts?


I keep seeing this kind of thing in the library I'm currently working with:

/**
 * Builds a pie chart from data in a specific column.
 *
 * @param  {Object[][]} data a JavaScript 2d array
 * @param  {int} columnIndex the index of the column from which the chart should be created
 * @param  {int} optfilter the index of the column used to add a filter to the chart
 * @return {ChartPanel} a panel containing chart & filter. 
 */

I saw something along the lines that it was helping with autocomplete in the code that the library is being used. What does it do and how does it work?


Solution

  • There are tools that can build documentation from comments if you follow a specified syntax.

    @param begins a line that documents parameters to the function, @return documents the expected return value with type and description.