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