use*_*695 5 javascript documentation jsdoc meteor
在流星应用程序中使用JSDoc的正确方法是什么?下面是我记录代码的方法,但所有部分之间没有"连接".一切都属于示例模板,因此jsdoc的输出应该正确构造.
如何改进此文档?
Template.example.helpers({
/**
* Get all categories
* @name categories
* @return {Cursor}
* @summary Cursor categories
*/
categories() {
return Categories.find({});
},
});
Template.example.onCreated(
/**
* If template is created (still not rendered), ReactiveDict variable is initialized
* @function
* @name onCreated
* @summary Set ReactiveDict
*/
function() {
this.something = new ReactiveDict();
}
);
Template.example.events({
/**
* Clicking on category will show a console message
* @event
* @summary Console message
*/
'click #category': (event, template) => {
console.log('nice')
}
});
Run Code Online (Sandbox Code Playgroud)
在我工作的地方,几个月前我们遇到了同样的情况,我们得出的结论是,这jsdoc只是不适应 auto-doc withMeteor的实现。我们最终使用了https://github.com/fabienb4/meteor-jsdoc这让我们非常满意。它基本上jsdoc使用meteor特定关键字扩展了语法,因此您可以指定什么是a Meteor.call,什么是集合帮助器等等。配置并运行后,输出基本上就是 Meteor 1.3 之前的文档的样子(正如作者所说,它是“基于 Meteor 自己文档的模板”)。
编辑:由于我们不使用 Meteor 的模板系统,所以我没有现有的示例,但我根据您的情况改编了一个集合助手,请告诉我是否有任何不清楚的地方。诀窍是根据您希望文档的显示方式来使用@memberOf、等。@isMethod
/**
* @memberOf Foo Template
* @summary Returns Bar conversation attached to stuff
* @param {String} fooId
* @param {Boolean} forced # Use to create foo when it's not found
* @returns {Object} Bar
*/
getStuff: function(fooId, forced=false) {
'use strict';
/** your code **/
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
442 次 |
| 最近记录: |