编辑:这在技术上是一个2部分问题.我选择了一般性问题的最佳答案,并与处理特定问题的答案相关联.
使用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) {
};
};
Run Code Online (Sandbox Code Playgroud)
无论是PageRequest
对象还是callback
存在于代码中.它们将getPage()
在运行时提供.但我希望能够定义对象和功能是什么.
我可以创建PageRequest
用于记录的对象:
/**
* @namespace {PageRequest} Object specification
* @property {String} pageId ID of the page you want.
* …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用JSDoc-toolkit记录我的代码.我的代码首先包含一个自执行的匿名函数.我怎么在世界上记录这个?我几乎整天都在这上面.JS Docs不会识别匿名函数闭包内部的任何内容,因为它不知道如何处理它.它打破了,我的评论都没有通过.
我的代码看起来像这样.
/**
* @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 = {
/** or here */
config: {
button: DOM Element,
property: blablabla
},
init: function () { ...some init code here}
};
share.init();
};
widgets.add("share", stlib);
}());
Run Code Online (Sandbox Code Playgroud)
谢谢!