我正在使用 Meteor,与普通 JavaScript 相比,它有一些奇怪的警告。我想添加一些标签以使文档更加明确。
Meteor.methods({
/**
* Upgrade a user's role
*
* @where Anywhere
* @rolerequired 'admin'
*
* @module Meteor.methods
* @method Roles.upgrade
* @param {String|Object} user the userId or the user document to update
* @param {String} role the role to add the user to
* @throws Meteor.Error 401 if the user trying to upgrade was not authorized to do so
*
* @example
* Meteor.call('Roles.upgrade', Meteor.users.findOne(), function (err) {
if (!err) {
console.log('User successfully added to role');
} else {
Router.error(401);
}
})
*/
'Roles.upgrade': function (user, role) {
if (Roles.userIsInRole(this.userId, 'admin')) {
return Roles.addUserToRoles(user, role);
} else {
throw new Meteor.Error(401, "Not authorized to upgrade roles")
}
}
});
@where
和@rolerequired
更具体到这个基于 Meteor 的应用程序。@where
可以在 devdocs.io 之类的文件中看到。
如何给 JSDoc 添加标签?