jsdoc

Documenting callback parameters using Google Closure Compiler

左心房为你撑大大i 提交于 2019-12-11 10:33:25
问题 How can you document names and descriptions of callback parameters using the Google Closure Compiler? After reading this answer on documenting callbacks with JSDoc, I tried using @callback and @typedef and @name tags, but ran into issues with each one. With @callback , Closure gives an "illegal use of unknown JSDoc tag" warning: /** * @callback EndDrawCallback * @param {string} action - either "keep", "discard", or "cancel" * @param {boolean} saveChanges - whether to mark changes as saved **/

JSDoc comments for destructuring parameters not working in VSCode

大憨熊 提交于 2019-12-11 07:27:23
问题 According to the doc, JSDoc supports destructuring parameters: /** * Assign the project to an employee. * @param {Object} employee - The employee who is responsible for the project. * @param {string} employee.name - The name of the employee. * @param {string} employee.department - The employee's department. */ Project.prototype.assign = function({ name, department }) { // ... }; However, it doesn't work for me in VSCode (v1.23.1). Has anyone successfully tried this? VSCode and TypeScript

Create a TypeScript Library and use it from Node.js with ES6 and TypeScript

坚强是说给别人听的谎言 提交于 2019-12-11 06:44:54
问题 I want to create a TypeScript library as private npm package which can be used in Node.js (including 6.x) using ES6 with @types support and TypeScript. The goal of the library is to extend the Request type from express and provide additional properties. I created a new Node.js project and add this tsconfig.json : { "compilerOptions": { "target": "es2015", "module": "commonjs", "sourceMap": true, "declaration": true, "outDir": "./dist", "strict": true, "types": ["mocha"] } } These are the

JSDoc document object method extending other class

淺唱寂寞╮ 提交于 2019-12-11 06:37:28
问题 Document Extending jest.Matchers using JSDoc I wrote a simple extension of jest.Matchers but I can not get the typescript type checker to recognise my extension. I'm using plain JavaScript. // @ts-check const getFunctorValue = F => { let x F.fmap(v => x = v) return x } expect.extend({ /** * @extends jest.Matchers * @param {*} actual The functor you want to test. * @param {*} expected The functor you expect. */ functorToBe(actual, expected) { const actualValue = getFunctorValue(actual) const

How to annotate core Node.js modules with JSDoc to have code hinting in IntelliJ?

人走茶凉 提交于 2019-12-11 05:58:18
问题 So far I have a need for two of them, util and fs . Given a code like this: var fs = require('fs'); var contents = fs.readFileSync('path/to/file', 'utf8'); Not only IntelliJ marks readFileSync as Unresolved function or method , but I am also devoid of, in my opinion, on of the best function given by IDEs - code hinting. How can I annotate core Node.js functions with JSDoc to have code hinting and not have correct code erroneously marked as invalid? 回答1: Why core libraries are not resolved?

How do I set a JSDoc tutorial title?

廉价感情. 提交于 2019-12-11 03:39:43
问题 I'm using JSDoc tutorials, as described in http://usejsdoc.org/about-tutorials.html I can't get the configuration options to work, and I haven't yet found any examples or discussion of the topic online. In my trivial example, I pass a tutorials parameter to JSDoc, and it builds a tutorial file for tutorial1.md. I would like to give this tutorial a display name of "First Tutorial". Following this from the online docs: Each tutorial file can have additional .js/.json file (with same name, just

How to document variable number of parameters in certain situations with JSDoc

☆樱花仙子☆ 提交于 2019-12-11 03:14:10
问题 I have something like this where my function only takes in the second and third parameters when the first one is != 3 . How can I document this behaviour with JSDoc? getTimeframe: function(timeframe, since, until) { /* * @param {Number} timeframe Can be 0, 1, 2 or 3 * @param {Number} since Optional when timeframe !== 3 * @param {Number} until Optional when timeframe !== 3 */ ... } 回答1: As far as I know the following is the best you can currently do with jsdoc 3. The key is to use @also to

RequireJS import documentation

China☆狼群 提交于 2019-12-10 23:14:24
问题 Im using in WebStorm editor. My project is using RequireJS with AMD. There is an example of code: dep.js define([], function () { var exports = { helloWorld: function() { console.log("Hello world"); } }; return exports; }); primary.js define(['dep'], function (dep) { var exports = { sayHello: function() { dep.helloWorld(); } }; return exports; }); How to document properly exports (this mainly described in other answers) and (important!) imports of such AMD modules, so WebStorm can have proper

JSDoc for special singleton pattern

旧城冷巷雨未停 提交于 2019-12-10 22:19:44
问题 I have a special JS singleton prototype function. Pattern looks more or less like example below. Work fine and do the job, but sadly PhpStorm is totally blind regarding to auto-completion and other useful things. How to tell the IDE using JSDoc that new Item will result in the end in new object build with ItemPrototype, so new Item(1).getId() will point to the right place in the code? Thanks in advance for your time. var Item = (function(){ var singletonCollection = {}; var ItemPrototype =

Generate jsdoc documentation

末鹿安然 提交于 2019-12-10 17:15:07
问题 I search to understand how operate jsdoc, the generator of javascript documentation. When I use it, I have always all my documentation files on index.js and never the navigation (in the documentation web site) in my files, classes or modules. Furthermore, I have also some tags which do not appear in the documentation. However, I use just the tags given by usejsdoc web site (documentation of jsdoc). Version : Node.js : 6.9.1 jsdoc : 3.4.2 Server.js "use strict"; /** * @module server * @file *