- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
为了避免在我的 JavaScript 代码中使用 new
,我编写了工厂来创建对象。
我尝试了很多组合,给我最满意的结果如下:
/**
* Document module
* @module app/document
*/
(function () {
'use strict';
/**
* Factory that creates a document object.
* @alias module:app/document.factory
* @return {document}
*/
function document() {
/**
* Get document id
* @method id
* @return {String}
*/
var id = function id() {...},
api = {
id: id
};
return api;
}
/**
* This module exports the {@link module:app/document.factory|factory} function.
*/
module.exports = document;
}());
这些注释的问题是没有定义document
对象。因此,我无法在另一个对象中引用此对象,并且在扩展此对象时无法继承其文档。
记录这种对象的合适方法是什么?
如果我使用 @typedef
标签,我会得到静态的 factory
方法并且正确记录了 document
对象但是 JSDoc 没有生成 id
方法文档:
/**
* Document module.
* @module app/document
*/
(function () {
'use strict';
/**
* Factory that creates a document object.
* @function module:app/document.factory
* @return {document}
*/
function factory(agent) {
/**
* @callback document~id
* @returns {String}
*/
var id = function id() {...},
/**
* @typedef document
* @property {document~id} id
*/
document = {
id: id
};
return document;
}
module.exports = factory;
}());
最佳答案
我对您的建议是使用@typedef 定义类型并在模块上定义导出,然后使用@type {FactoryDefinition} 注释 module.exports = factory
/** @typedef {{ id: !string }} */
var DocumentDefinition;
/** @typedef {!function(!object):!DocumentDefinition} */
var FactoryDefinition;
/** @type {FactoryDefinition} */
module.exports = factory
关于javascript - 使用 JSDoc 记录工厂,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32548126/
短版: 如果我想从头开始开发一个全新的 jsDoc 模板,我需要阅读哪些内容才能了解 jsDoc 的功能、我的模板必须提供什么接口(interface)以及我可以使用哪些数据? 加长版: 我已经使用
给定一个将回调函数作为参数的 Javascript 函数: var myFunction = function(onSuccess, onFailure) {...} 我如何记录 onSuccess的
我一直看到以下格式的 JSDoc(和之前的 JavaDoc): /** * This is some JSDoc ... * ... and some more */ function
假设我有一个接受一个参数的函数: /** * @summary Some function. * * @since 1.0.0 * * etc. */ function func( a )
所有官方 JSDoc 示例都有简单的文档字符串,如下所示: /** * @param {string} author - The author of the book. */ 问题是,在现实生活中
jsDoc 似乎支持大部分 MD 语法,但是当涉及到突出显示单个保留字或文本时,我找不到可用的标签。 在 MD 语法中,我可以使用 `word`,它会设置灰色背景和不同的字体,这样您就可以清楚地看到它
我正在提供带有 JSDoc 注释的代码示例,其中也包含 JSDoc 注释,如何在不破坏外部注释的情况下转义嵌套的 JSDoc 注释? 我使用的是版本 3.3.0-beta3 例子: /** *
我正在使用 documentation package ,但无法弄清楚如何将它记录为类属性(不是通过 getter 和 setter 定义的)。 下面只为 SomeClass 生成类文档,但省略了 s
请向我解释描述此模块的最佳方式: /** * Common util methods * @module Utils */ var Utils = (/** @lends module:Util
我一直很难让 @borrows 标记在 JSDoc 中工作。我一直在尝试从一个函数中获取文档,并将其作为第二个函数的文档。但我似乎连一个简单的例子都做不到! /** * This is the de
我想设置一个 Grunt 任务来运行 JSDoc。我正在使用 grunt-jsdoc JSDoc npm 页面推荐的。它工作正常,但我不能使用我创建的 jsdoc.json 文件。 { "tags
我仍在学习 js 并试用 Webstorm IDE,它看起来不错(包括跳转到 var/函数声明)。 我可以看到如何让 jsdoc 评论出现的模板,但我没有这方面的经验,正在寻找一个例子来说明如何在评论
我仍在学习 js 并试用 Webstorm IDE,它看起来不错(包括跳转到 var/函数声明)。 我可以看到如何让 jsdoc 评论出现的模板,但我没有这方面的经验,正在寻找一个例子来说明如何在评论
我有两种类型的模块: Require.js 主文件: require.config({ baseUrl: "/another/path", paths: {
是否有任何自然方式或特殊标签将参数类型作为链接? /** * My js app * @module app */ /** * Namespace for MYAPP classes and func
我有一个包含大量选项的函数: /** * Show dialog in a blocking manner. * * @param {object} opts * @param {string
我只需要在包含 .js 文件的 ai 整个目录上运行 jsdoc,我通过发出命令 jsdoc abc.js 对 ubuntu 终端中的单个文件执行此操作,但我需要的是一次将此命令应用于目录中的所有文件
假设我有两个功能,其中一个扩展了另一个。 /** * @abstract * @param {Object} settings * @param {Number} settings.x * @para
/** * @param {String} foo * @param {Number} bar */ 或者 /** * @param {string} foo * @param {numbe
导致JsDoc忽略源链接的最简单方法是什么?我必须定义自己的模板吗? 最佳答案 如果使用默认模板,则使用templates.default.outputSourceFiles设置为false的配置文件
我是一名优秀的程序员,十分优秀!