jsdoc

Documenting member functions with JSDoc

。_饼干妹妹 提交于 2019-12-06 03:35:55
问题 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 ? 回答1: JSDoc needs some additional information to recognize the function as member function: /** * Diese Klasse bla bla... * @constructor */ my

Intellisense from JSDoc not working for imported types in VSCode

三世轮回 提交于 2019-12-05 22:40:10
When using a, ES2015 class as a type in JSDoc it does not appear to work correctly in files that import that class via a require statement. While working within the same file that the class was defined in, everything works as expected (shown below). While working within a different file the class appears to import correctly and show its constructor typing (shown below). But when I try to use the class for typing (As done in the first image) it no longer considers my class as a valid type. Here is the jsconfig I was using for this example { "compilerOptions": { "target": "es6", "module":

JSDoc Comment Folding In VSCode

Deadly 提交于 2019-12-05 20:38:25
问题 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? 回答1: 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

jsdoc @typedef - how to declare function properly?

依然范特西╮ 提交于 2019-12-05 17:51:49
Here is my jsdoc declaration. How should I adjust it, so that MyNewType.logFirst property actually references logFirst function, which I've annotated below? // my-new-type.js /** * MyNewType definition * @typedef {Object} MyNewType * @property {function} logFirst * @property {function} logSecond */ /** * @param {number} first * @param {number} second * @returns MyNewType */ module.exports = (first, second) => { /** * logs first argument * @param {number} times */ function logFirst(times) { for (let i = 0; i < times; i++) { console.log(first); } } /** * logs second argument * @param {number}

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

元气小坏坏 提交于 2019-12-05 17:51:32
问题 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. 回答1: 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

Attribute on options parameter with JSDoc in WebStorm: “Unresolved variable”

我们两清 提交于 2019-12-05 17:21:08
I have a function with jsdoc comment that resembles the following in my code: /** * Foo function * @param {Object} [options] * @param {String} [options.foo] */ var foo = function (options) { if (!options) options = {}; var foo = options.foo || 'foo'; // ... }; My IDE, WebStorm, marks options.foo as an 'unresolved variable'. If I remove the jsdoc comment, the warning disappears. How do I document this function in a way that WebStorm gets the hint and no longer displays this warning? Things that I tried: Remove @param {String} [options.foo] @param {?String} [options.foo] @param {String} options

Adding sub-properties to an existing property-list in jsdoc

邮差的信 提交于 2019-12-05 14:54:47
I am trying to automate a particular module in our JS library and am stuck at a point where I want to define a set of properties (lets say an object that goes as construction parameter of a class). /** * This function initiates world peace! * @constructor * @param {object} defaults - The options to initiate peace. * @param {number} defaults.issues - The number of issues being taken up. * @param {string} defaults.source - The name of the location where process starts. */ var WorldPeace = function (defaults) { // code here }; It is well and good had all properties of the construction was defined

How to use prop-types as type definition for typescript?

梦想与她 提交于 2019-12-05 14:49:47
While having the myTypes constant written somewhere in a file called my-component.js , like below: import React from 'react' import { View } from 'react-native' import PropTypes from 'prop-types' export const myTypes = { activeColor: PropTypes.string, color: PropTypes.string, fontFamily: PropTypes.string, fontSize: PropTypes.number, fontWeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), height: PropTypes.number, icon: PropTypes.node, iconOverlay: PropTypes.node, marginBottom: PropTypes.number, marginLeft: PropTypes.number, marginRight: PropTypes.number, marginTop: PropTypes

How to get @borrows tag working in JSDoc

允我心安 提交于 2019-12-05 11:52:43
I have been having a hard time getting the @borrows tag working in JSDoc. I have been trying to get the documentation from one function and us it as documentation for a second function. But I don't seem to be able to even get a simple example working! /** * This is the description for funcA */ var funcA = function() {}; /** * @borrows funcA as funcB */ var funcB = function() {}; I was expecting this to output documentation for both functions with both exactly the same. However only funcA is only has a description. The @borrows tag doesn't seem to work directly on a symbol, but only indirectly.

How to add and use a tag on jsdoc?

左心房为你撑大大i 提交于 2019-12-05 11:41:46
I am trying to add a customTag to jsdoc. I have created a file in the plugins directory like this: method.js exports.defineTags = function(dictionary) { dictionary.defineTag("methodHttp", { mustHaveValue: true, canHaveType: false, canHaveName: true, onTagged: function(doclet, tag) { doclet.methodHttp = tag.value; } }); }; Then I added to my conf.json : { "tags": { "allowUnknownTags": true }, "source": { "includePattern": ".+\\.js(doc)?$", "excludePattern": "(^|\\/|\\\\)_" }, "plugins": [ "plugins/method" ], "templates": { "cleverLinks": false, "monospaceLinks": false, "default": {