jsdoc

What is the proper/canonical formatting of long JSDoc lines?

空扰寡人 提交于 2019-12-08 14:26:16
问题 All of the official JSDoc examples have naively simple documentation strings, like the following: /** * @param {string} author - The author of the book. */ The problem is, in real-life documentation you often have longer documentation strings: /** * @param {string} author - The author of the book, presumably some person who writes well */ But since most companies (for legitimate readability reasons) have line length limits, the above often isn't acceptable. However, what I can't figure out is

Documenting complex JavaScript Objects with custom Inheritance System

…衆ロ難τιáo~ 提交于 2019-12-08 08:12:01
问题 I'm currently trying to migrate an existing server-side JavaScript API from its existing manually copy-and paste Inheritance System to a better and more reliable system. The pure prototyping cannot be used because state (variables) of the objects must also be inherited and must not be overriden in parent Objects. So i'm thinking about using a good solution from John Reisig described here: http://ejohn.org/blog/simple-javascript-inheritance/ which workrs great for my case. The only challenge i

JSDoc for reused Function interface

╄→尐↘猪︶ㄣ 提交于 2019-12-08 01:13:56
问题 I'm connecting to multiple email tools and abstracting their APIs to one common sendEmail function with the same params and same returns for each service. That means that for every email service (Mailchimp, SendGrid...), I have to write a function which has an identical JSDoc describing the same @params and same @returns ... Is there a valid JSDoc syntax to use @typedef or similar with a Function, where instead of declaring @params and @returns above each function, just describe the type? ..

Jshint / PhpStorm: “Unresolved variable” when using jquery .data()

独自空忆成欢 提交于 2019-12-07 20:11:21
问题 Phpstorm keeps telling me I have an undefined variable input.connectto Html: <div class="b-showColorinList" data-connectto="123456" data-othervalue="Lorem Ipsum">... JS: $(document).on('click', '.b-showColorinList', function() { cm.showColorInList( $(this) ); }); And: /** * Uses ajax to get other color in list view * @param {object} inputObj */ cm.showColorInList = function(inputObj) { "use strict"; var input = inputObj.data(), parent = $("#"+input.connectto), othervalue = input.othervalue; I

How to document a method with multiple aliases?

半腔热情 提交于 2019-12-07 19:23:17
问题 I'm trying to document the getName() method of The following Person constructor : Javascript code : /** * Creates a person instance. * @param {string} name The person's full name. * @constructor */ function Person( name ) { /** * Returns the person's full name. * @return {string} The current person's full name. */ function getName() { return name; } this.getName = getName; this.getN = getName; this.getFullName = getName; } As you can see, the getName() method has two aliases ( getN() and

Intellisense from JSDoc not working for imported types in VSCode

岁酱吖の 提交于 2019-12-07 13:50:58
问题 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.

How to get @borrows tag working in JSDoc

℡╲_俬逩灬. 提交于 2019-12-07 11:43:55
问题 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

jsdoc @typedef - how to declare function properly?

送分小仙女□ 提交于 2019-12-07 09:53:26
问题 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) {

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

不想你离开。 提交于 2019-12-07 08:23:40
问题 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:

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

穿精又带淫゛_ 提交于 2019-12-07 07:07:05
问题 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