jsdoc

How to document a parameter that accepts a predefined set of values?

扶醉桌前 提交于 2019-12-10 15:35:32
问题 I have a parameter that could simply be described as: /** * @param {String} source */ source value can be only a set of predefined values, e.g. "youtube", "vimeo". How to document the accepted range of source values? 来源: https://stackoverflow.com/questions/32497467/how-to-document-a-parameter-that-accepts-a-predefined-set-of-values

JSDoc with and Immutable.js datastructures in annotations

99封情书 提交于 2019-12-10 14:43:10
问题 I am returning Immutable.js List data structure from function. PHPStorm is automatically attaching following @returns {*|List<T>|List<any>} . Eslint is giving me warning Unresolved variable of type 'T'. Where can I find documentation to annotations for Immutable.js? How can I describe in @returns annotation shape of the List that would pass in Eslint? /** * @param n * @returns {*|List<T>|List<any>} */ const getList = (n) => { let list = Immutable.List() for (let i = 0; i < n; i++) { for (let

How to make link of method parameter type in jsDoc

谁说胖子不能爱 提交于 2019-12-10 13:59:09
问题 Is there any natural way or special tag to make parameter type as link? /** * My js app * @module app */ /** * Namespace for MYAPP classes and functions. * @namespace HUMAN_RESOURCE */ var HUMAN_RESOURCE = HUMAN_RESOURCE || {}; /** * @class JustClass * @constructor */ HUMAN_RESOURCE.JustClass = function(){ } /** * Constructs Person objects * @class Person * @constructor * @param {String} First name * @param {String} Last name */ HUMAN_RESOURCE.Person = function (first, last) { /** * First

Type Checking Array Contents with Closure-Compiler

十年热恋 提交于 2019-12-10 13:14:18
问题 In Google Closure, if an Array of a specific @type {Array.<type>} is initialized, can I be sure that Google Closure will confirm the Array contents? Here is a small test case. It appears to me that an {Array.<string>} is sneaking past an {Array.<number>} check, although a {string} is correctly blocked by the same check. I am a little new to GC, is this an error on my part? I've pasted this to the Google Closure Service, and I'm showing only one of two expected errors (Sept 12 2013). I've

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

送分小仙女□ 提交于 2019-12-10 09:23:13
问题 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 =

Using Google Closure's @typedef tag

五迷三道 提交于 2019-12-10 04:22:51
问题 Google's Closure compiler has an "@typedef" tag, but is it OK to use them in your code? (I know it'll work, but is it frowned upon?) So here's my type /** * The plan object's typedef * @typedef {Object} */ Types.Plan = { "style": "bordersmall", "width": "50%", "height": "40%", "x": "20%", "y": "10%", "clickable": true, "moveable": true }; And then I can use that type in my JSDoc annotations. This allows my IDE to give me autocomplete on the passed parameter So the declared object isn't used

Are there any open source JSDoc parser written in Javascript?

风流意气都作罢 提交于 2019-12-10 03:11:05
问题 I am looking for a JSDoc parser that I can use in my project. I am looking for something where I can pass in a JSDoc comment and receive a structured description of what that comment means. Most of the tools I have seen seem to be able to transform JSDoc comments into HTML or some other format. I am looking for something that will provide the intermediate representation of a comment that can be used to feed into other tools. Are there any tools or libraries out there that I can use? 回答1: The

JSDoc and JavaScript singleton documentation

落爺英雄遲暮 提交于 2019-12-09 18:22:27
问题 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...

jsdoc : reference typedef-ed type from other module

假装没事ソ 提交于 2019-12-08 18:58:27
问题 Assuming I have a typedef type in a js module // somewhere/foo.js /** * @module */ /** * @typedef Foo * @type {object} * property {string} bar - some property */ Is it possible to reference this type in another module, so that in the HTML page generated by jsdoc, the type is displayed as a link to the typedef-ed module ? I tried variations of this, but nothing seems to work... // somewhere_else/bar.js /** * @module */ /** * @param {somewhere/foo/Foo} foo - some param */ export default

JSDoc inheriting parameter documentation

守給你的承諾、 提交于 2019-12-08 16:39:33
问题 Let's say I have two functions, where one extends the other. /** * @abstract * @param {Object} settings * @param {Number} settings.x * @param {Number} settings.y * */ function Base(settings) { this.x = settings.x; this.y = settings.y; } /** * @extends Base */ function Foo(settings) { Base.call(this, settings); } These two functions are in two separate files. Is there any way I can inherit the parameter documentation from the Base function in my Foo function, or do I have to write the