-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCOMMENT_PARSER_OPTIONS.mjs
57 lines (51 loc) · 1.7 KB
/
COMMENT_PARSER_OPTIONS.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import getCommentParserTokenizerDescription from "comment-parser/parser/tokenizers/description";
import getCommentParserTokenizerName from "comment-parser/parser/tokenizers/name";
import getCommentParserTokenizerTag from "comment-parser/parser/tokenizers/tag";
import getCommentParserTokenizerType from "comment-parser/parser/tokenizers/type";
const JSDOC_SPACING_STRATEGY = "preserve";
/**
* [`comment-parser`](https://npm.im/comment-parser) parser options for parsing
* JSDoc comment block tags relevant to `jsdoc-md`.
* @kind constant
* @name COMMENT_PARSER_OPTIONS
* @ignore
*/
export default {
// Used for parsing the main description (before block tags).
spacing: JSDOC_SPACING_STRATEGY,
// Configure what parts (tag, type, name, description) are expected for
// jsdoc-md supported JSDoc tags.
tokenizers: [
// Tag tokenizer.
getCommentParserTokenizerTag(),
// Type tokenizer.
(spec) =>
// JSDoc tags without a type.
["desc", "description", "fires", "ignore", "kind", "see"].includes(
spec.tag
)
? spec
: getCommentParserTokenizerType(JSDOC_SPACING_STRATEGY)(spec),
// Name tokenizer.
(spec) =>
// JSDoc tags without a name.
[
"desc",
"description",
"example",
"ignore",
"return",
"returns",
"see",
"type",
].includes(spec.tag)
? spec
: getCommentParserTokenizerName()(spec),
// Description tokenizer.
(spec) =>
// JSDoc tags without a description.
["fires", "ignore", "kind", "name", "type", "typedef"].includes(spec.tag)
? spec
: getCommentParserTokenizerDescription(JSDOC_SPACING_STRATEGY)(spec),
],
};