1 | import { StandardTags } from '../details/StandardTags';
|
2 | import { TSDocValidationConfiguration } from './TSDocValidationConfiguration';
|
3 | import { DocNodeManager } from './DocNodeManager';
|
4 | import { BuiltInDocNodes } from '../nodes/BuiltInDocNodes';
|
5 | import { allTsdocMessageIds, allTsdocMessageIdsSet } from '../parser/TSDocMessageId';
|
6 |
|
7 |
|
8 |
|
9 | var TSDocConfiguration = (function () {
|
10 | function TSDocConfiguration() {
|
11 | this._tagDefinitions = [];
|
12 | this._tagDefinitionsByName = new Map();
|
13 | this._supportedTagDefinitions = new Set();
|
14 | this._validation = new TSDocValidationConfiguration();
|
15 | this._docNodeManager = new DocNodeManager();
|
16 | this._supportedHtmlElements = new Set();
|
17 | this.clear(false);
|
18 |
|
19 | BuiltInDocNodes.register(this);
|
20 | }
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 | TSDocConfiguration.prototype.clear = function (noStandardTags) {
|
27 | if (noStandardTags === void 0) { noStandardTags = false; }
|
28 | this._tagDefinitions.length = 0;
|
29 | this._tagDefinitionsByName.clear();
|
30 | this._supportedTagDefinitions.clear();
|
31 | this._validation.ignoreUndefinedTags = false;
|
32 | this._validation.reportUnsupportedTags = false;
|
33 | this._validation.reportUnsupportedHtmlElements = false;
|
34 | this._supportedHtmlElements.clear();
|
35 | if (!noStandardTags) {
|
36 |
|
37 | this.addTagDefinitions(StandardTags.allDefinitions);
|
38 | }
|
39 | };
|
40 | Object.defineProperty(TSDocConfiguration.prototype, "tagDefinitions", {
|
41 | |
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | get: function () {
|
48 | return this._tagDefinitions;
|
49 | },
|
50 | enumerable: false,
|
51 | configurable: true
|
52 | });
|
53 | Object.defineProperty(TSDocConfiguration.prototype, "supportedTagDefinitions", {
|
54 | |
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 | get: function () {
|
63 | var _this = this;
|
64 | return this.tagDefinitions.filter(function (x) { return _this.isTagSupported(x); });
|
65 | },
|
66 | enumerable: false,
|
67 | configurable: true
|
68 | });
|
69 | Object.defineProperty(TSDocConfiguration.prototype, "validation", {
|
70 | |
71 |
|
72 |
|
73 | get: function () {
|
74 | return this._validation;
|
75 | },
|
76 | enumerable: false,
|
77 | configurable: true
|
78 | });
|
79 | Object.defineProperty(TSDocConfiguration.prototype, "supportedHtmlElements", {
|
80 | |
81 |
|
82 |
|
83 | get: function () {
|
84 | return Array.from(this._supportedHtmlElements.values());
|
85 | },
|
86 | enumerable: false,
|
87 | configurable: true
|
88 | });
|
89 | Object.defineProperty(TSDocConfiguration.prototype, "docNodeManager", {
|
90 | |
91 |
|
92 |
|
93 | get: function () {
|
94 | return this._docNodeManager;
|
95 | },
|
96 | enumerable: false,
|
97 | configurable: true
|
98 | });
|
99 | |
100 |
|
101 |
|
102 |
|
103 | TSDocConfiguration.prototype.tryGetTagDefinition = function (tagName) {
|
104 | return this._tagDefinitionsByName.get(tagName.toUpperCase());
|
105 | };
|
106 | |
107 |
|
108 |
|
109 |
|
110 | TSDocConfiguration.prototype.tryGetTagDefinitionWithUpperCase = function (alreadyUpperCaseTagName) {
|
111 | return this._tagDefinitionsByName.get(alreadyUpperCaseTagName);
|
112 | };
|
113 | |
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 | TSDocConfiguration.prototype.addTagDefinition = function (tagDefinition) {
|
122 | var existingDefinition = this._tagDefinitionsByName.get(tagDefinition.tagNameWithUpperCase);
|
123 | if (existingDefinition === tagDefinition) {
|
124 | return;
|
125 | }
|
126 | if (existingDefinition) {
|
127 | throw new Error("A tag is already defined using the name " + existingDefinition.tagName);
|
128 | }
|
129 | this._tagDefinitions.push(tagDefinition);
|
130 | this._tagDefinitionsByName.set(tagDefinition.tagNameWithUpperCase, tagDefinition);
|
131 | };
|
132 | |
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 | TSDocConfiguration.prototype.addTagDefinitions = function (tagDefinitions, supported) {
|
140 | for (var _i = 0, tagDefinitions_1 = tagDefinitions; _i < tagDefinitions_1.length; _i++) {
|
141 | var tagDefinition = tagDefinitions_1[_i];
|
142 | this.addTagDefinition(tagDefinition);
|
143 | if (supported !== undefined) {
|
144 | this.setSupportForTag(tagDefinition, supported);
|
145 | }
|
146 | }
|
147 | };
|
148 | |
149 |
|
150 |
|
151 | TSDocConfiguration.prototype.isTagSupported = function (tagDefinition) {
|
152 | this._requireTagToBeDefined(tagDefinition);
|
153 | return this._supportedTagDefinitions.has(tagDefinition);
|
154 | };
|
155 | |
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 | TSDocConfiguration.prototype.setSupportForTag = function (tagDefinition, supported) {
|
167 | this._requireTagToBeDefined(tagDefinition);
|
168 | if (supported) {
|
169 | this._supportedTagDefinitions.add(tagDefinition);
|
170 | }
|
171 | else {
|
172 | this._supportedTagDefinitions.delete(tagDefinition);
|
173 | }
|
174 | this.validation.reportUnsupportedTags = true;
|
175 | };
|
176 | |
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 | TSDocConfiguration.prototype.setSupportForTags = function (tagDefinitions, supported) {
|
186 | for (var _i = 0, tagDefinitions_2 = tagDefinitions; _i < tagDefinitions_2.length; _i++) {
|
187 | var tagDefinition = tagDefinitions_2[_i];
|
188 | this.setSupportForTag(tagDefinition, supported);
|
189 | }
|
190 | };
|
191 | |
192 |
|
193 |
|
194 |
|
195 | TSDocConfiguration.prototype.setSupportedHtmlElements = function (htmlTags) {
|
196 | this._supportedHtmlElements.clear();
|
197 | this._validation.reportUnsupportedHtmlElements = true;
|
198 | for (var _i = 0, htmlTags_1 = htmlTags; _i < htmlTags_1.length; _i++) {
|
199 | var htmlTag = htmlTags_1[_i];
|
200 | this._supportedHtmlElements.add(htmlTag);
|
201 | }
|
202 | };
|
203 | |
204 |
|
205 |
|
206 | TSDocConfiguration.prototype.isHtmlElementSupported = function (htmlTag) {
|
207 | return this._supportedHtmlElements.has(htmlTag);
|
208 | };
|
209 | |
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 | TSDocConfiguration.prototype.isKnownMessageId = function (messageId) {
|
219 | return allTsdocMessageIdsSet.has(messageId);
|
220 | };
|
221 | Object.defineProperty(TSDocConfiguration.prototype, "allTsdocMessageIds", {
|
222 | |
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 | get: function () {
|
231 | return allTsdocMessageIds;
|
232 | },
|
233 | enumerable: false,
|
234 | configurable: true
|
235 | });
|
236 | TSDocConfiguration.prototype._requireTagToBeDefined = function (tagDefinition) {
|
237 | var matching = this._tagDefinitionsByName.get(tagDefinition.tagNameWithUpperCase);
|
238 | if (matching) {
|
239 | if (matching === tagDefinition) {
|
240 | return;
|
241 | }
|
242 | }
|
243 | throw new Error('The specified TSDocTagDefinition is not defined for this TSDocConfiguration');
|
244 | };
|
245 | return TSDocConfiguration;
|
246 | }());
|
247 | export { TSDocConfiguration };
|
248 |
|
\ | No newline at end of file |