jsdoc

Seeking: Example of how to use jsDoc with the Webstorm IDE (v 4)

喜你入骨 提交于 2019-12-04 17:35:57
I'm still learning js and trying out the Webstorm IDE, which seems sweet (including jumping to var/function declarations). I can see how to get the template for a jsdoc comment to appear but I'm not experienced with it and looking for an example of how to provide more detail in the comment and how to view that detail. WebStorm 4.0 supports most of JSDoc tags. For example, when you specify @type for variable, completion will work better and assignments of expressions with wrong types will be highlighted as warnings. Element documentation popup appears when Ctrl+Q is pressed on some reference.

How to describe destructured object arguments in JSDoc

我是研究僧i 提交于 2019-12-04 12:10:06
问题 If I have a JavaScript function taking an object as a parameter, I can describe expected properties of the object with JSDoc like this: /** * @param bar * @param bar.baz {number} * @param bar.qux {number} */ function foo(bar) { return bar.baz + bar.qux; } How do I describe these properties if I define my function with ECMAScript 6 destructuring, not giving the real parameter object a name at all? const foo = ({ baz, qux }) => baz + qux; 回答1: It turns out JSDoc does support destructing via

How to indicate param is optional using inline JSDoc?

我们两清 提交于 2019-12-04 07:35:44
问题 According to the JSDoc wiki for @param you can indicate a @param is optional using /** @param {String} [name] */ function getPerson(name) { } and you can indicate a param inline using function getPerson(/**String*/ name) { } And I can combine them like the following, which works ok. /** @param [name] */ function getPerson(/**String*/name) { } But I would like to know if there is a way to do it all inline if possible. 回答1: From official documentation: Optional parameter An optional parameter

How to doc a variable number of parameters

白昼怎懂夜的黑 提交于 2019-12-04 07:29:56
How do I doc a variable number of parameters? I am writing an application in PHP and JavaScript. Currently I have (in JavaScript): /** * Description * @param {String} description */ function fn() { // arguments holds all strings. } So, how do I doc n-number of string params? E.g. PhpDocumentor suggests using an ellipsis /** * Example of unlimited parameters. * Returns a formatted var_dump for debugging purposes * (since the recurrences of $v are not listed in the actual function signature in the code, * you may wish to highlight they are "optional" in their description) * @param string $s

How To Use JSDOC3 To Document Enum Constants

☆樱花仙子☆ 提交于 2019-12-04 07:27:39
We're using JSDOC to document our client-facing SDK and we're having difficult getting it to recognize our 'enums' (i.e. constants). Which tags should we use to get JSDOC to pick it up in the documentation? Here's a sample: /** * @module Enum */ export namespace { /** * @enum WidgetType {string} */ Enum.WidgetType = { /** Dashboard */ Dashboard: 'dashboard', /** Form */ Form: 'entityeditform', /** Report */ Report: 'report' }; } Here's how the 'enums' are used in code: app.widget({ id: 'account_entityform', type: Enum.WidgetType.Form }).add(); How can we document this with JSDOC? ASA2 After

Documenting member functions with JSDoc

醉酒当歌 提交于 2019-12-04 07:07:53
I have something like this: /** Diese Klasse bla bla... @constructor **/ my.namespace.ClassA = function(type) { /** This function does something **/ this.doSomething = function(param){ } } The class will get listed in the generated documentation. The function won't. Is there a way to tell JSDoc (3) that this is a member function of the class ClassA ? JSDoc needs some additional information to recognize the function as member function: /** * Diese Klasse bla bla... * @constructor */ my.namespace.ClassA = function(type) { /** * This function does something * @function * @memberOf my.namespace

JSDoc and JavaScript singleton documentation

為{幸葍}努か 提交于 2019-12-04 06:58:33
I have a JavaScript singleton defined as: /** * A description here * @class */ com.mydomain.ClassName = (function(){ /** * @constructor * @lends com.mydomain.ClassName */ var ClassName = function(){}; /** * method description * @public * @lends com.mydomain.ClassName */ ClassName.prototype.method1 = function(){}; return new ClassName(); })(); No warnings are printed in verbose mode (-v), but the documentation reports only "com.mydomain.ClassName()" with "A description here" as description... how can I generate documentation for ClassName's methods too? I solved! :) /** * A description here *

JSDoc Comment Folding In VSCode

橙三吉。 提交于 2019-12-04 04:54:05
Is there a way to fold JSDoc-style comment blocks in VSCode v1.25 for JavaScript files? I get normal code collapse offered, but comment blocks seem excluded. Is there a keyboard shortcut that would collapse code even without the GUI handlebars showing? locofierro I had the same issue, and fixed it by doing this: Go to File -> Preferences -> Settings and change the following entry from auto to indentation "editor.foldingStrategy": "indentation" Now JSDoc comments are folding as expected, hope this works for you as well! { "key": "ctrl+k ctrl+/", "command": "editor.foldAllBlockComments", "when":

How to make WebStorm resolve modules which are functions?

旧城冷巷雨未停 提交于 2019-12-04 02:56:08
WebStorm does a very good job of resolving functions which are returned from CommonJS modules as methods (and reads JsDoc associated with them), like for instance: // utils/valid.js /** * Returns true no matter what. * @param {HTMLElement} element * @return {boolean} */ function isValid(element) { return true; } module.exports.isValid = isValid; // exports property Such a function is then correctly provided in code completion and inline documentation mechanisms when such a module is required in another file. // main.js var isValid = require('./utils/isValid').isValid; // works well However,

How to get VS Code to understand JSDOC's @typedef across multiple files

♀尐吖头ヾ 提交于 2019-12-04 00:41:34
I want to specify a type in one file, and be able to reuse it in another one. I tried modules but it didn't work in VS Code. Is there any other solution? Just wanna have all types for my project to be reusable so I can reference them in different functions across files. This is the closest question I have found. I've had some success with using jsconfig.json and its include property in a plain JavaScript project in Visual Studio Code 1.33.1 { "include": [ "src/**/*.js" ] } Given the following JavaScript project: src/ ├── types/ | ├── person.js | ├── question.js | ├── answer.js ├── jsconfig