jsdoc

How to jsdoc annotate BackboneJS code?

雨燕双飞 提交于 2019-11-28 17:18:49
Has anyone ever documented BackboneJS code with JSDoc? I'm having problems annotating Backbone constructs such as: User = Backbone.Model.extend({ defaults: { a: 1 }, initialize: function () { // ... }, doSomething: function (p) { // ... } }); Any advice appreciated. Thanks. I think it works somehow like this, if you're talking about the JSDoc Toolkit: User = Backbone.Model.extend( /** @lends User.prototype */ { /** * @class User class description * * @augments Backbone.Model * @constructs * * Text for the initialize method */ initialize: function() {} }) The important bit is the position of

Best way to document anonymous objects and functions with jsdoc [closed]

折月煮酒 提交于 2019-11-28 16:10:32
Edit: This is technically a 2 part question. I've chosen the best answer that covers the question in general and linked to the answer that handles the specific question. What is the best way to document anonymous objects and functions with jsdoc? /** * @class {Page} Page Class specification */ var Page = function() { /** * Get a page from the server * @param {PageRequest} pageRequest Info on the page you want to request * @param {function} callback Function executed when page is retrieved */ this.getPage = function(pageRequest, callback) { }; }; Neither the PageRequest object or the callback

How do I JSDoc A Nested Object's Methods?

纵然是瞬间 提交于 2019-11-28 15:46:35
问题 I've been trying to use JSDoc3 to generate documentation on a file, but I'm having some difficulty. The file (which is a Require.js module) basically looks like this: define([], function() { /* * @exports mystuff/foo */ var foo = { /** * @member */ bar: { /** * @method */ baz: function() { /*...*/ } } }; return foo; } The problem is, I can't get baz to show up in the generated documentation. Instead I just get a documentation file for a foo/foo module, which lists a bar member, but bar has no

JSDoc with AngularJS

别说谁变了你拦得住时间么 提交于 2019-11-28 15:29:02
Currently within my Project we are using JSDoc, we have recently started to implement Angular and I want to continue using JSDoc to ensure that all the documentation is within the same place. I have taken a look at people mainly just saying to use ngDoc but this isn't really a viable option as we will always have separate JavaScript and I ideally would have everything together. /** * @author Example <jon.doe@example.com> * @copyright 2014 Example Ltd. All rights reserved. */ (function () { window.example = window.example || {}; /** * Example Namespace * @memberOf example * @namespace example

Document overloaded function in JSDoc

荒凉一梦 提交于 2019-11-28 14:35:51
I have an overloaded toggle function and want to document the behaviors w/ JSDoc. If the value is defined the window state is set to the boolean value of the truthy parameter, if undefined the window state toggles. I'm looking for something like this. /** * Set the map window in mobile * @param {undefined|*} on - toggle or set the window state * - {undefined} toggles window state * - {*} set window state */ toggleWindow(on) { if (on === undefined) { on = !this.state.window; } this.setState({ mapWindow: !!on }); } Taken from here : You need to nestle the start and end of each comment together

Document collection (array of type) return value and parameter in JSDoc

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 07:24:38
How to document Array return value (and parameters) in JSDoc when array elements can be either of the following: A type (e.g. String , Array ). An object literal. If you're looking for how to document the type of objects in an array, you want something like this: /** * @param {String[]} aliases */ http://code.google.com/p/jsdoc-toolkit/wiki/TagParam#Parameter_Type_Information Gajus Given a screenings parameter: screenings = [ { timestamp: 1440157537, url: 'https://stackoverflow.com/a/22787287/1269037', }, { timestamp: ..., url: ..., }, ]; You can document it one of the three ways: Using

How to document anonymous functions (closure) with jsdoc-toolkit

时光毁灭记忆、已成空白 提交于 2019-11-28 07:12:58
I am trying to document my code using JSDoc-toolkit. My code starts by being wrapped with a self-executing anonymous function. How in the world do I document this? I've spent nearly all day on this. JS Docs will not recognize anything inside of the anonymous function closure due to it not knowing what to do with it. It breaks and none of my comments come through. My code looks something like this. /** * @fileoverview BLA BLA BLA */ /** * This is where I don't know what to put. */ (function () { "use strict"; /** or here */ var stlib = function (param, param, param) { /** or here */ var share =

How to specify an array of objects as a parameter or return value in JSDoc?

眉间皱痕 提交于 2019-11-28 03:53:04
In JSDoc, the best documentation I can find shows to use the following if you have an array of a specific type (such as an array of strings) as: /** * @param {Array.<string>} myStrings All my awesome strings */ function blah(myStrings){ //stuff here... } How would you replace the below question marks specify an array of objects? /** * @param {???????} myObjects All of my equally awesome objects */ function blah(myObjects){ //stuff here... } Rene Saarsoo You should be more specific what you mean by JSDoc - this is a generic term covering pretty much all the JavaDoc-style documentation tools for

How to document a string type in jsdoc with limited possible values

流过昼夜 提交于 2019-11-27 18:55:29
I am having a function that accepts one string parameter. This parameter can have only one of a few defined possible values. What is the best way to document the same? Should shapeType be defined as enum or TypeDef or something else? Shape.prototype.create = function (shapeType) { // shapeType can be "rect", "circle" or "ellipse"... this.type = shapeType; }; Shape.prototype.getType = function (shapeType) { // shapeType can be "rect", "circle" or "ellipse"... return this.type; }; The second part of the problem is that the possible values of shapeType is not known in the file that defines

How to document a function returned by a function using JSDoc

断了今生、忘了曾经 提交于 2019-11-27 17:16:52
问题 I am using JSDoc for parameter documentation. It is clear how to document the parameter types for many_prompts , but what is the right way to document the function it returns? /** * @param {Number} - number of times to prompt * @return {Function(prompt{Number})} - the returned function */ function many_prompts(count) { return function(prompt) { for(var i=0; i < count; i++) alert(prompt); } } //Example of use: var y =many_prompts(3); y('Hello World'); 回答1: You can document the inner function