@openpkg-ts/sdk 0.50.0 → 0.51.0
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/dist/index.js +27 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1329,6 +1329,19 @@ function withInlineTags(node, ...texts) {
|
|
|
1329
1329
|
const inlineTags = parseInlineTags(...texts);
|
|
1330
1330
|
return inlineTags ? { ...node, inlineTags } : node;
|
|
1331
1331
|
}
|
|
1332
|
+
var INLINE_TAGS_ONLY_RE = /^\s*(?:\{@[a-zA-Z][a-zA-Z0-9]*(?:[^}\\]|\\.)*\}\s*)+$/;
|
|
1333
|
+
function splitCommentLevelTags(text) {
|
|
1334
|
+
if (!text.includes("{@"))
|
|
1335
|
+
return { retained: text, hoisted: [] };
|
|
1336
|
+
const paragraphs = text.split(/\n\s*\n/);
|
|
1337
|
+
const hoisted = [];
|
|
1338
|
+
while (paragraphs.length > 1 && INLINE_TAGS_ONLY_RE.test(paragraphs[paragraphs.length - 1])) {
|
|
1339
|
+
hoisted.unshift(...parseInlineTags(paragraphs.pop()) ?? []);
|
|
1340
|
+
}
|
|
1341
|
+
return { retained: paragraphs.join(`
|
|
1342
|
+
|
|
1343
|
+
`), hoisted };
|
|
1344
|
+
}
|
|
1332
1345
|
function parseExamplesFromTags(tags) {
|
|
1333
1346
|
const examples = [];
|
|
1334
1347
|
for (const tag of tags) {
|
|
@@ -1353,10 +1366,8 @@ function parseExamplesFromTags(tags) {
|
|
|
1353
1366
|
function stripParamSeparator(text) {
|
|
1354
1367
|
if (!text)
|
|
1355
1368
|
return;
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
stripped = parts[0].trim();
|
|
1359
|
-
return stripped || undefined;
|
|
1369
|
+
const stripped = text.replace(/^-\s*/, "").trim();
|
|
1370
|
+
return splitCommentLevelTags(stripped).retained.trim() || undefined;
|
|
1360
1371
|
}
|
|
1361
1372
|
function stripTypeParamSeparator(text) {
|
|
1362
1373
|
if (!text)
|
|
@@ -1378,6 +1389,7 @@ function extractSeeTagText(tag) {
|
|
|
1378
1389
|
if (seeMatch) {
|
|
1379
1390
|
let text = seeMatch[1].trim();
|
|
1380
1391
|
text = text.replace(/\s*\*\s*$/gm, "").trim();
|
|
1392
|
+
text = text.replace(/^[ \t]*\*[ \t]?/gm, "").trim();
|
|
1381
1393
|
if (text)
|
|
1382
1394
|
return text;
|
|
1383
1395
|
}
|
|
@@ -1416,8 +1428,11 @@ function extractSeeTagText(tag) {
|
|
|
1416
1428
|
}
|
|
1417
1429
|
function getJSDocComment(node, symbol, checker) {
|
|
1418
1430
|
const jsDocTags = ts.getJSDocTags(node);
|
|
1431
|
+
const commentLevelTags = [];
|
|
1419
1432
|
const tags = jsDocTags.map((tag) => {
|
|
1420
1433
|
const rawText = typeof tag.comment === "string" ? tag.comment : ts.getTextOfJSDocComment(tag.comment) ?? "";
|
|
1434
|
+
const { retained, hoisted } = tag.tagName.text === "see" ? { retained: rawText, hoisted: [] } : splitCommentLevelTags(rawText);
|
|
1435
|
+
commentLevelTags.push(...hoisted);
|
|
1421
1436
|
if (tag.tagName.text === "param") {
|
|
1422
1437
|
const paramTag = tag;
|
|
1423
1438
|
let paramName = "";
|
|
@@ -1450,7 +1465,7 @@ function getJSDocComment(node, symbol, checker) {
|
|
|
1450
1465
|
const text = extractSeeTagText(tag);
|
|
1451
1466
|
return withInlineTags({ name: tag.tagName.text, text }, text);
|
|
1452
1467
|
}
|
|
1453
|
-
return withInlineTags({ name: tag.tagName.text, text: rawText },
|
|
1468
|
+
return withInlineTags({ name: tag.tagName.text, text: rawText }, retained);
|
|
1454
1469
|
});
|
|
1455
1470
|
const jsDocComments = ts.getJSDocCommentsAndTags(node).filter(ts.isJSDoc);
|
|
1456
1471
|
let description;
|
|
@@ -1468,7 +1483,13 @@ function getJSDocComment(node, symbol, checker) {
|
|
|
1468
1483
|
}
|
|
1469
1484
|
}
|
|
1470
1485
|
const examples = parseExamplesFromTags(tags);
|
|
1471
|
-
|
|
1486
|
+
const inlineTags = [...parseInlineTags(description) ?? [], ...commentLevelTags];
|
|
1487
|
+
return {
|
|
1488
|
+
description,
|
|
1489
|
+
tags,
|
|
1490
|
+
examples,
|
|
1491
|
+
inlineTags: inlineTags.length > 0 ? inlineTags : undefined
|
|
1492
|
+
};
|
|
1472
1493
|
}
|
|
1473
1494
|
function getSourceLocation(node, sourceFile) {
|
|
1474
1495
|
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|