JSDoc - specifying mandatory parameter syntax
Asked Answered
T

1

6

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

Tabular answered 23/8, 2016 at 4:54 Comment(0)
V
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.
Valora answered 23/8, 2016 at 16:50 Comment(1)
@Luis how do we mark one of the parameters as mandatory. Let's say there are opt1 and opt2. One of them is must.Arioso

© 2022 - 2024 — McMap. All rights reserved.