A doclet is a JSDoc entity exposed to plugins and templates. Most people deal with JSDoc annotations instead e.g.,
so.js
/**
* This is a JSDoc comment
*/
Dumping the doclets:
# npx jsdoc -X so.js
[
{
"kind": "package",
"longname": "package:undefined",
"files": [
"/workspace/dev/tmp/so.js"
]
}
]
Another example:
/**
* @return {boolean}
*/
function foo() {
return true;
}
Doclets:
# npx jsdoc -X so.js
[
{
"comment": "/**\n * @return {boolean}\n */",
"meta": {
"range": [
29,
62
],
"filename": "so.js",
"lineno": 4,
"columnno": 0,
"path": "/workspace/dev/tmp",
"code": {
"id": "astnode100000002",
"name": "foo",
"type": "FunctionDeclaration",
"paramnames": []
}
},
"returns": [
{
"type": {
"names": [
"boolean"
]
}
}
],
"name": "foo",
"longname": "foo",
"kind": "function",
"scope": "global",
"params": []
},
{
"kind": "package",
"longname": "package:undefined",
"files": [
"/workspace/dev/tmp/so.js"
]
}
]
As you can see JSDoc didn't need you to say that foo is a function. There's a lot of information that can be inferred from the source code and that information is captured in a doclet.
There are a few places in the JSDoc documentation mentioning "virtual JSDoc comment". These are standalone JSDoc blocks i.e. not immediately followed by JS code. In fact you could generate an entire API documentation with just virtual JSDoc comments and no actual code at all.