jsdoc3

How to document an array of objects in JSDOC

孤者浪人 提交于 2020-12-29 05:15:42
问题 I have a function with an array of objects as parameter and would like to describe the parameter (including the properties of the objects in the array) using JSDOC like in this example: /** * @param {Array.<Object>} filter - array of filter objects * @param ... */ function doSomething(filter) { } where filter is something like this: filter = [ {id: 'session', value: 1}, {id: 'name', value: 'john'} ] How would I document the properties id and value in jsdoc3 ? 回答1: like this: /** * @param

How to document an array of objects in JSDOC

六眼飞鱼酱① 提交于 2020-12-29 05:14:49
问题 I have a function with an array of objects as parameter and would like to describe the parameter (including the properties of the objects in the array) using JSDOC like in this example: /** * @param {Array.<Object>} filter - array of filter objects * @param ... */ function doSomething(filter) { } where filter is something like this: filter = [ {id: 'session', value: 1}, {id: 'name', value: 'john'} ] How would I document the properties id and value in jsdoc3 ? 回答1: like this: /** * @param

JSDocs: Documenting Node.js express routes

坚强是说给别人听的谎言 提交于 2020-03-18 10:42:42
问题 I am struggling documenting router.get calls with JSDocs. I am unable to get the documentation to display correctly on the page if I try to append it to my router call itself. /** * Health check * @memberof health */ router.get('/happy', function(req, res) { res.json({ "status" : "OK" }); }); To resolve it, I made the functions have names. router.get('/happy', happy); /** * Health check * @memberof health */ function happy(req, res) { res.json({ "status" : "OK" }); } This works, but I would

Enum as @param type in JSDoc

自古美人都是妖i 提交于 2020-01-29 02:40:27
问题 Is it possible to use an enum for the JSDoc @param type declaration like in the following example? /** * @enum { Number } */ var TYPES = { TYPE_A: 1, TYPE_B: 2 } /** * @param { TYPES } type */ function useTypesEnum( type ) { } If I use an IDE like Eclipse etc. for JavaScript, there should no warning be raised? 回答1: JsDoc comments have no impact on JavaScript code. What it does influence is some tools designed to use that information. Two of the tools that work with JsDoc comments are the

Documenting the return of a javascript constructor with jsdoc

[亡魂溺海] 提交于 2020-01-14 12:52:35
问题 I have a javascript function that returns a constructor (see code sample below). How would I document this with the @returns tag of jsdoc. It doesnt seem correct to do @returns {MyConstructor} because that implies I am returning an instance of "MyConstructor" rather than the constructor itself, right? function MyConstructor() { var self = this; self.myFunction = function() { return true; }; self.getMyFunctionResult = function() { return self.myFunction(); }; } /** * @returns {?} A constructor

Comment nested module class with JSDoc3

断了今生、忘了曾经 提交于 2020-01-14 03:06:29
问题 I'm dealing with a module pattern in WebStorm's live inspection that I'm trying to comment. And I don't want to use AMD/CJS. ; My = (window.My || {}); My.Module = (My.Module || {}); My.Module.MyClass = (/** * * @param {My.Module.MyAnotherClass} MyAnotherClass */ function (MyAnotherClass) { 'use strict'; /** * @class */ var MyClass = function() { // constructor }; /** * My sexy method. * @param {string} s */ MyClass.prototype.myMethod= function(s) { var test = new MyAnotherClass(s); }; return

What is the canonical pattern for exporting enums in a JavaScript module?

元气小坏坏 提交于 2019-12-24 12:50:12
问题 I want to know the canonical pattern for exporting enums from a JavaScript module using require and jsdoc. Existing examples and questions seem to only consider local private enums. My goal is to have the best quality documentation and intellisense/code completion I can. Here is my current best attempt: var LawnMower = function () { }; /** * Enums for the valid heights to mow * @readonly * @enum {number} */ LawnMower.heights = { Low: 0, Medium: 1, High: 2 }; // Doing this separately from

JSDoc3 documentation of a function's argument being an array of objects?

对着背影说爱祢 提交于 2019-12-22 11:33:31
问题 UseJSDoc.org's page on @type explains how to document arrays and objects, but not arrays of objects. My function accepts an array of objects with a specific list of properties and it's these properties that I'd like to document. The function might look like function foo(people) and the people array might have been created by the caller of the function as arr = []; arr.push({name: "Alfred", profession: "Butler", hitpoints: 2}); arr.push({name: "Batman", profession: "Vigilante", hitpoints: 42})

What is the correct JSDoc syntax for a local variable?

妖精的绣舞 提交于 2019-12-22 03:43:08
问题 For a function like this... function example() { var X = 100; ... var Y = 'abc'; ... return Z; } I need to explain the purpose of some of the local variables. Adding a description like this... function example() { /** * @description - Need to explain the purpose of X here. */ var X = 100; ... /** * @description - Need to explain the purpose of Y here. */ var Y = 'abc'; ... return Z; } ...doesn't seem to be getting picked up by JS Doc v3.4.0 . What is the correct syntax? P.S. Some of my use

static class property not working with Babel

别等时光非礼了梦想. 提交于 2019-12-21 19:16:17
问题 I am using JSDOC and all it supported npm plugins to create nice documentation. Getting hard time when jsdoc is running and parsing JSX file it always throws error as below near = sign SyntaxError: unknown: Unexpected token export default class SaveDesign extends Component { static displayName = 'SaveDesign'; } conf.json file { "source": { "include": [ "src/app/test.js", "src/app/components/Modals/Template/SaveDesign.jsx"], "exclude": [ "src/fonts", "src/icons", "src/less", "src/vector-icon"