forked from shaka-project/shaka-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsdoc-plugin.js
73 lines (62 loc) · 2.01 KB
/
jsdoc-plugin.js
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/** @license
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
// JSDoc plugin to customize jsdoc for Shaka Player
'use strict';
// Define custom tags.
exports.defineTags = (dictionary) => {
const exportOpts = {
mustNotHaveValue: true,
onTagged: (doclet, tag) => {
doclet.access = 'export';
},
};
// Truly exported by the compiler.
dictionary.defineTag('export', exportOpts);
// Interface exported in the generated externs only.
dictionary.defineTag('exportInterface', exportOpts);
// A namespace, event, etc. exported only in the docs.
dictionary.defineTag('exportDoc', exportOpts);
// For us, @namespace should be treated like @class, except that we don't
// want to show the non-existent constructor.
const classOpts = dictionary.lookUp('class');
dictionary.defineTag('namespace', {
onTagged: (doclet, tag) => {
classOpts.onTagged(doclet, tag);
doclet.hideconstructor = true;
},
});
};
exports.handlers = {
processingComplete: (e) => {
// Fill out the "implementations" field so that interface implementations
// can be listed on the interface docs.
const doclets = e.doclets;
const map = {};
for (const doc of doclets) {
map[doc.longname] = doc;
}
for (const doc of doclets) {
// Skip things that do not implement an interface.
if (!doc.implements) {
continue;
}
// Skip things which are not classes (such as methods).
if (doc.kind != 'class') {
continue;
}
for (let interfaceName of doc.implements) {
// If the interface is a template, strip the template type.
interfaceName = interfaceName.split('.<')[0];
const interfaceDoc = map[interfaceName];
// Skip unknown interfaces, which occurs for externs like MediaKeys.
if (!interfaceDoc) {
continue;
}
interfaceDoc.implementations = interfaceDoc.implementations || [];
interfaceDoc.implementations.push(doc.longname);
}
}
},
};