sveld 0.15.2 → 0.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/lib/ComponentParser.js +17 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
10
10
|
- add isAccessor field to API
|
|
11
11
|
- update Markdown writer to generate a separate table for accessors -->
|
|
12
12
|
|
|
13
|
+
## [0.15.3](https://github.com/carbon-design-system/sveld/releases/tag/v0.15.3) - 2022-05-14
|
|
14
|
+
|
|
15
|
+
- preserve JSDoc tags in prop comments
|
|
16
|
+
|
|
13
17
|
## [0.15.2](https://github.com/carbon-design-system/sveld/releases/tag/v0.15.2) - 2022-05-13
|
|
14
18
|
|
|
15
19
|
- dispatched event type without detail should default to `null`, not `any`
|
package/lib/ComponentParser.js
CHANGED
|
@@ -302,7 +302,7 @@ var ComponentParser = /** @class */ (function () {
|
|
|
302
302
|
var callees = [];
|
|
303
303
|
(0, compiler_1.walk)({ html: this.parsed.html, instance: this.parsed.instance }, {
|
|
304
304
|
enter: function (node, parent, prop) {
|
|
305
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
305
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
306
306
|
if (node.type === "CallExpression") {
|
|
307
307
|
if (node.callee.name === "createEventDispatcher") {
|
|
308
308
|
dispatcher_name = parent === null || parent === void 0 ? void 0 : parent.id.name;
|
|
@@ -340,12 +340,12 @@ var ComponentParser = /** @class */ (function () {
|
|
|
340
340
|
node.declaration = declaration_1;
|
|
341
341
|
prop_name = exportedName;
|
|
342
342
|
}
|
|
343
|
-
var
|
|
343
|
+
var _p = node.declaration.declarations ? node.declaration.declarations[0] : node.declaration, declaration_type = _p.type, id = _p.id, init = _p.init, body = _p.body;
|
|
344
344
|
prop_name !== null && prop_name !== void 0 ? prop_name : (prop_name = id.name);
|
|
345
345
|
var value = undefined;
|
|
346
346
|
var type = undefined;
|
|
347
347
|
var kind = node.declaration.kind;
|
|
348
|
-
var
|
|
348
|
+
var description_1 = undefined;
|
|
349
349
|
var isFunction = false;
|
|
350
350
|
var isFunctionDeclaration = false;
|
|
351
351
|
if (init != null) {
|
|
@@ -388,15 +388,22 @@ var ComponentParser = /** @class */ (function () {
|
|
|
388
388
|
var tag = (_e = comment[0]) === null || _e === void 0 ? void 0 : _e.tags[((_f = comment[0]) === null || _f === void 0 ? void 0 : _f.tags.length) - 1];
|
|
389
389
|
if ((tag === null || tag === void 0 ? void 0 : tag.tag) === "type")
|
|
390
390
|
type = _this.aliasType(tag.type);
|
|
391
|
-
|
|
391
|
+
description_1 = ComponentParser.assignValue((_h = (_g = comment[0]) === null || _g === void 0 ? void 0 : _g.description) === null || _h === void 0 ? void 0 : _h.trim());
|
|
392
|
+
var additional_tags = (_j = comment[0]) === null || _j === void 0 ? void 0 : _j.tags.filter(function (tag) { return !["type", "extends", "restProps", "slot", "event", "typedef"].includes(tag.tag); });
|
|
393
|
+
if (additional_tags.length > 0 && description_1 === undefined) {
|
|
394
|
+
description_1 = "";
|
|
395
|
+
}
|
|
396
|
+
additional_tags.forEach(function (tag) {
|
|
397
|
+
description_1 += "".concat(description_1 ? "\n" : "", "@").concat(tag.tag, " ").concat(tag.name).concat(tag.description ? " ".concat(tag.description) : "");
|
|
398
|
+
});
|
|
392
399
|
}
|
|
393
|
-
if (!
|
|
394
|
-
|
|
400
|
+
if (!description_1 && _this.typedefs.has(type)) {
|
|
401
|
+
description_1 = _this.typedefs.get(type).description;
|
|
395
402
|
}
|
|
396
403
|
_this.addProp(prop_name, {
|
|
397
404
|
name: prop_name,
|
|
398
405
|
kind: kind,
|
|
399
|
-
description:
|
|
406
|
+
description: description_1,
|
|
400
407
|
type: type,
|
|
401
408
|
value: value,
|
|
402
409
|
isFunction: isFunction,
|
|
@@ -406,13 +413,13 @@ var ComponentParser = /** @class */ (function () {
|
|
|
406
413
|
});
|
|
407
414
|
}
|
|
408
415
|
if (node.type === "Comment") {
|
|
409
|
-
var data = (
|
|
416
|
+
var data = (_l = (_k = node === null || node === void 0 ? void 0 : node.data) === null || _k === void 0 ? void 0 : _k.trim()) !== null && _l !== void 0 ? _l : "";
|
|
410
417
|
if (/^@component/.test(data)) {
|
|
411
418
|
_this.componentComment = data.replace(/^@component/, "");
|
|
412
419
|
}
|
|
413
420
|
}
|
|
414
421
|
if (node.type === "Slot") {
|
|
415
|
-
var slot_name = (
|
|
422
|
+
var slot_name = (_m = node.attributes.find(function (attr) { return attr.name === "name"; })) === null || _m === void 0 ? void 0 : _m.value[0].data;
|
|
416
423
|
var slot_props = node.attributes
|
|
417
424
|
.filter(function (attr) { return attr.name !== "name"; })
|
|
418
425
|
.reduce(function (slot_props, _a) {
|
|
@@ -449,7 +456,7 @@ var ComponentParser = /** @class */ (function () {
|
|
|
449
456
|
}
|
|
450
457
|
return __assign(__assign({}, slot_props), (_b = {}, _b[name] = slot_prop_value, _b));
|
|
451
458
|
}, {});
|
|
452
|
-
var fallback = (
|
|
459
|
+
var fallback = (_o = node.children) === null || _o === void 0 ? void 0 : _o.map(function (_a) {
|
|
453
460
|
var start = _a.start, end = _a.end;
|
|
454
461
|
return _this.sourceAtPos(start, end);
|
|
455
462
|
}).join("").trim();
|