-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreference.js
More file actions
57 lines (54 loc) · 1.97 KB
/
reference.js
File metadata and controls
57 lines (54 loc) · 1.97 KB
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
/**
*
* A JSdoc plugin that creates a linkable `reference` category (aliased to `definition` and `terminology`).
* Useful when you have something that isn't easily defined elsewhere, such as an options object that is used repeatedly or a return
* object that is returned by many different functions. Or you simply want to define something or use terminology that needs
* to be defined.
*
* Items in `reference` can be linked to per normal linking. All items are in the `global` scope, so they will not follow a namespace or
* module pattern, even if you try to make them one.
*
* Downloadable from https://github.com/bartmelton/jsdoc-plugins
*
* example:
* ```
* @reference {object} Options
* @property {number} property1 - some option property that is a number
* @property {array} property2 - some option property that is a number
* ```
*
* example 2:
* ```
* @definition confusingWord - some word you are using that needs clarification/context or in leiu of repeating a paragraph over and over.
* ```
*/
exports.defineTags = function(dictionary) {
dictionary.defineTag('reference', {
mustHaveValue: true,
canHaveType: true,
canHaveName: true,
onTagged: function(doclet, tag) {
doclet.addTag('kind', 'reference');
doclet.scope = 'global';
delete doclet.memberof;
if (tag.value && tag.value.name) {
doclet.addTag('name', tag.value.name);
}
else if (tag.value && tag.value.description) { // as in a long tag
doclet.addTag('name', tag.value.description);
}
else if (tag.text) { // or a short tag
doclet.addTag('name', tag.text);
}
if (tag.value && tag.value.type) {
// Add the type names and other type properties (such as `optional`).
// Don't overwrite existing properties.
Object.keys(tag.value).forEach(function(prop) {
if (!doclet.hasOwnProperty(prop) ) {
doclet[prop] = tag.value[prop];
}
});
}
},
}).synonym('definition').synonym('terminology');
};