1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
16 | const doctrine = require("doctrine");
|
17 | const jsdoc = require("../javascript/jsdoc");
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | if (Math.random() > 1000) {
|
24 | annotateProperty.name;
|
25 | }
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | function annotate(feature) {
|
37 | if (!feature || feature.jsdoc) {
|
38 | return;
|
39 | }
|
40 | if (typeof feature.description === 'string') {
|
41 | feature.jsdoc = jsdoc.parseJsdoc(feature.description);
|
42 |
|
43 | feature.description = feature.jsdoc.description;
|
44 | }
|
45 | return;
|
46 | }
|
47 | exports.annotate = annotate;
|
48 |
|
49 |
|
50 |
|
51 | function annotateElementHeader(scannedElement) {
|
52 | scannedElement.demos = [];
|
53 | if (scannedElement.jsdoc && scannedElement.jsdoc.tags) {
|
54 | scannedElement.jsdoc.tags.forEach((tag) => {
|
55 | switch (tag.title) {
|
56 | case 'demo':
|
57 | scannedElement.demos.push({
|
58 | desc: 'demo',
|
59 | path: (tag.description || 'demo/index.html')
|
60 | });
|
61 | break;
|
62 | }
|
63 | });
|
64 | }
|
65 | }
|
66 | exports.annotateElementHeader = annotateElementHeader;
|
67 |
|
68 |
|
69 |
|
70 | function annotateEvent(annotation) {
|
71 | const eventTag = jsdoc.getTag(annotation, 'event');
|
72 | let name;
|
73 | if (eventTag && eventTag.description) {
|
74 | name = (eventTag.description || '').match(/^\S*/)[0];
|
75 | }
|
76 | else {
|
77 | name = 'N/A';
|
78 | }
|
79 | const scannedEvent = {
|
80 | name: name,
|
81 | description: annotation.description || (eventTag && eventTag.description) ||
|
82 | undefined,
|
83 | jsdoc: annotation,
|
84 | sourceRange: undefined,
|
85 | astNode: undefined,
|
86 | warnings: [],
|
87 | params: []
|
88 | };
|
89 | const tags = (annotation && annotation.tags || []);
|
90 |
|
91 | scannedEvent.params.push(...tags.filter((tag) => tag.title === 'param').map((param) => {
|
92 | return {
|
93 | type: param.type ? doctrine.type.stringify(param.type) : 'N/A',
|
94 | desc: param.description || '',
|
95 | name: param.name || 'N/A'
|
96 | };
|
97 | }));
|
98 |
|
99 | return scannedEvent;
|
100 | }
|
101 | exports.annotateEvent = annotateEvent;
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 | function annotateProperty(feature) {
|
110 | annotate(feature);
|
111 |
|
112 | const typeTag = jsdoc.getTag(feature.jsdoc, 'type');
|
113 | if (typeTag !== undefined && typeTag.type != null) {
|
114 | feature.type = doctrine.type.stringify(typeTag.type);
|
115 | }
|
116 |
|
117 | const defaultTag = jsdoc.getTag(feature.jsdoc, 'default');
|
118 | if (defaultTag !== undefined) {
|
119 | const newDefault = (defaultTag.name || '') + (defaultTag.description || '');
|
120 | if (newDefault !== '') {
|
121 | feature.default = newDefault;
|
122 | }
|
123 | }
|
124 | return feature;
|
125 | }
|
126 |
|
\ | No newline at end of file |