@openpkg-ts/sdk 0.50.0 → 0.50.1
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 +24 -2
- 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) {
|
|
@@ -1416,8 +1429,11 @@ function extractSeeTagText(tag) {
|
|
|
1416
1429
|
}
|
|
1417
1430
|
function getJSDocComment(node, symbol, checker) {
|
|
1418
1431
|
const jsDocTags = ts.getJSDocTags(node);
|
|
1432
|
+
const commentLevelTags = [];
|
|
1419
1433
|
const tags = jsDocTags.map((tag) => {
|
|
1420
1434
|
const rawText = typeof tag.comment === "string" ? tag.comment : ts.getTextOfJSDocComment(tag.comment) ?? "";
|
|
1435
|
+
const { retained, hoisted } = tag.tagName.text === "see" ? { retained: rawText, hoisted: [] } : splitCommentLevelTags(rawText);
|
|
1436
|
+
commentLevelTags.push(...hoisted);
|
|
1421
1437
|
if (tag.tagName.text === "param") {
|
|
1422
1438
|
const paramTag = tag;
|
|
1423
1439
|
let paramName = "";
|
|
@@ -1450,7 +1466,7 @@ function getJSDocComment(node, symbol, checker) {
|
|
|
1450
1466
|
const text = extractSeeTagText(tag);
|
|
1451
1467
|
return withInlineTags({ name: tag.tagName.text, text }, text);
|
|
1452
1468
|
}
|
|
1453
|
-
return withInlineTags({ name: tag.tagName.text, text: rawText },
|
|
1469
|
+
return withInlineTags({ name: tag.tagName.text, text: rawText }, retained);
|
|
1454
1470
|
});
|
|
1455
1471
|
const jsDocComments = ts.getJSDocCommentsAndTags(node).filter(ts.isJSDoc);
|
|
1456
1472
|
let description;
|
|
@@ -1468,7 +1484,13 @@ function getJSDocComment(node, symbol, checker) {
|
|
|
1468
1484
|
}
|
|
1469
1485
|
}
|
|
1470
1486
|
const examples = parseExamplesFromTags(tags);
|
|
1471
|
-
|
|
1487
|
+
const inlineTags = [...parseInlineTags(description) ?? [], ...commentLevelTags];
|
|
1488
|
+
return {
|
|
1489
|
+
description,
|
|
1490
|
+
tags,
|
|
1491
|
+
examples,
|
|
1492
|
+
inlineTags: inlineTags.length > 0 ? inlineTags : undefined
|
|
1493
|
+
};
|
|
1472
1494
|
}
|
|
1473
1495
|
function getSourceLocation(node, sourceFile) {
|
|
1474
1496
|
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|