如何使用JSDoc记录对象? [英] How do I document an object with JSDoc?
本文介绍了如何使用JSDoc记录对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用JSDoc记录简单JavaScript对象(及其导出)的源代码的最佳方法是什么?
What's the best way to document the source code of a simple JavaScript object (and its export) using JSDoc?
例如,我要记录以下对象:
For example, I want to document the following object:
/** how do I JSDocument object baseAdder? */
const baseAdder = {
/** how do I JSDocument property base? */
base: 1,
/**
* Add a number to base
* @param {number} a the number to be added to base
* @returns {number} the sum of the number plus base
*/
f: function(a) {
return this.base + a;
}
};
/** how do I JSDocument this export? Should I? */
module.exports = baseAdder;
推荐答案
基本的JS Doc文档就是这样.
A basic JS Doc documentation is like.
/*
* {Object} baseAdder - Base Adder object
* {Number} baseAdder.base - Base value
* {function} baseAdder.f - A function f on the Base Adder
*/
const baseAdder = {
base: 1,
/**
* Add a number to base
* @param {Number} - a the number to be added to base
* @returns {Number} - the sum of the number plus base
*/
f: function(a) {
return this.base + a;
}
};
/**
* A module of base adder!
* @module baseAdder
*/
module.exports = baseAdder;
有关更多参考,请遵循官方文档- http://usejsdoc.org/index.html
For more reference follow the official documentation - http://usejsdoc.org/index.html
这篇关于如何使用JSDoc记录对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文