最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - JSDoc - specifying mandatory parameter syntax - Stack Overflow

programmeradmin7浏览0评论

I am using @JSDoc to create documentation for my javascript library. I know how to indicate optional parameter. like below

/*
 * @param {string} [somebody] - Somebody's name.
 */
function sayHello(somebody) {
    if (!somebody) {
        somebody = 'John Doe';
    }
    alert('Hello ' + somebody);
}

But I would like to indicate some parameters in my API are mandatory. How to indicate it using JSDOC. I don't find any from JSDoc tags-param

I am using @JSDoc to create documentation for my javascript library. I know how to indicate optional parameter. like below

/*
 * @param {string} [somebody] - Somebody's name.
 */
function sayHello(somebody) {
    if (!somebody) {
        somebody = 'John Doe';
    }
    alert('Hello ' + somebody);
}

But I would like to indicate some parameters in my API are mandatory. How to indicate it using JSDOC. I don't find any from JSDoc tags-param

Share Improve this question asked Aug 23, 2016 at 4:54 Ganesh KGanesh K 2,7039 gold badges54 silver badges81 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

Unless you mark a parameter as optional, then the parameter is considered mandatory. There's nothing additional you need to do. To make your somebody parameter mandatory you'd just remove the brackets:

@param {string} somebody - Somebody's name.
发布评论

评论列表(0)

  1. 暂无评论