我们使用JSDOC来记录我们面向客户的SDK,我们很难让它识别我们的‘enum’(即常量)。我们应该使用哪些标记来让JSDOC在文档中获取它?这是一个样本:
/**
* @module Enum
*/
export namespace {
/**
* @enum WidgetType {string}
*/
Enum.WidgetType = {
/** Dashboard */
Dashboard: 'dashboard',
/** Form */
Form: 'entityeditform',
/** Report */
Report: 'report'
};
}下面是代码中“enum”的用法:
app.widget({ id: 'account_entityform', type: Enum.WidgetType.Form }).add();我们如何用JSDOC记录这一点?
发布于 2016-04-08 14:02:49
在回顾了this article on StackOverflow之后,我能够使用以下方法来完成这项工作:
/**
* @typedef FieldType
* @property {string} Text "text"
* @property {string} Date "date"
* @property {string} DateTime "datetime"
* @property {string} Number "number"
* @property {string} Currency "currency"
* @property {string} CheckBox "checkbox"
* @property {string} ComboBox "combobox"
* @property {string} Dropdownlist "dropdownlist"
* @property {string} Label "label"
* @property {string} TextArea "textarea"
* @property {string} JsonEditor "jsoneditor"
* @property {string} NoteEditor "noteeditor"
* @property {string} ScriptEditor "scripteditor"
* @property {string} SqlEditor "sqleditor"
*/发布于 2020-02-12 22:31:59
我看到有人对这个旧帖子发表意见,要求作出更多澄清。我只是从上面找出了答案,作为一个例子,我可以分享我想出的结果。在这个页面上搜索相同东西的人可能会发现这是有用的。
/**
* The color of a piece or square.
* @readonly
* @enum {number}
* @property {number} WHITE color for a white square or piece.
* @property {number} BLACK color for a black square or piece.
*/
export const Color = { WHITE: 0, BLACK: 1 }
/**
* Each member is an enumeration of direction offsets used to index into the
* lists of horzontal, vertical, and diagonal squares radiating from a
* given Square object. Only useful internally for initialization or externally
* for test.
* @package
* @type {object}
* @readonly
* @property {enum} Cross an enumeration of vert and horiz directions.
* @property {number} Cross.NORTH north
* @property {number} Cross.EAST east
* @property {number} Cross.SOUTH south
* @property {number} Cross.WEST west
* @property {enum} Diagonal an enumeration of diagonal directions.
* @property {number} Diagonal.NORTHEAST northeast
* @property {number} Diagonal.SOUTHEAST southeast
* @property {number} Diagonal.SOUTHWEST southwest
* @property {number} Diagonal.NORTHWEST northwest
*/
const Direction = {
Cross: {
NORTH: 0, EAST: 1, SOUTH: 2, WEST: 3
},
Diagonal: {
NORTHEAST: 0, SOUTHEAST: 1, SOUTHWEST: 2, NORTHWEST: 3
},
}https://stackoverflow.com/questions/36488644
复制相似问题