@tsdoctor/model 0.8.2 → 0.8.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/ApiExtractedPackage.js +12 -2
- package/package.json +1 -1
package/ApiExtractedPackage.js
CHANGED
|
@@ -318,7 +318,7 @@ var ApiExtractedPackage = class ApiExtractedPackage extends VirtualPackage {
|
|
|
318
318
|
* Clean an excerpt text: strip export/declare keywords and trailing semicolons/whitespace.
|
|
319
319
|
*/
|
|
320
320
|
cleanExcerpt(text) {
|
|
321
|
-
return text.replace(/^export\s+/, "").replace(/^declare\s+/, "").
|
|
321
|
+
return trimTrailing(text.replace(/^export\s+/, "").replace(/^declare\s+/, "").trimEnd(), ";").trim();
|
|
322
322
|
}
|
|
323
323
|
formatTypeParameters(typeParameters) {
|
|
324
324
|
if (!typeParameters.length) return "";
|
|
@@ -437,7 +437,7 @@ var ApiExtractedPackage = class ApiExtractedPackage extends VirtualPackage {
|
|
|
437
437
|
if (n.kind === "CodeSpan") return `\`${n.code || ""}\``;
|
|
438
438
|
if (n.kind === "EscapedText") return n.encodedText || n.decodedText || "";
|
|
439
439
|
if (n.kind === "ErrorText") return n.text || "";
|
|
440
|
-
if (n.kind === "FencedCode") return `\`\`\`${n.language || ""}\n${(n.code || ""
|
|
440
|
+
if (n.kind === "FencedCode") return `\`\`\`${n.language || ""}\n${trimTrailing(n.code || "", "\n")}\n\`\`\``;
|
|
441
441
|
if (n.kind === "LinkTag") {
|
|
442
442
|
let target = "";
|
|
443
443
|
if (n.codeDestination?.memberReferences) {
|
|
@@ -472,6 +472,16 @@ var ApiExtractedPackage = class ApiExtractedPackage extends VirtualPackage {
|
|
|
472
472
|
return entryPoint.displayName;
|
|
473
473
|
}
|
|
474
474
|
};
|
|
475
|
+
/**
|
|
476
|
+
* Strip every trailing occurrence of `char` from `text`. A linear scan, where
|
|
477
|
+
* the equivalent `/char+$/` regex backtracks quadratically on a long run of
|
|
478
|
+
* `char` that is not at the end of the string.
|
|
479
|
+
*/
|
|
480
|
+
function trimTrailing(text, char) {
|
|
481
|
+
let end = text.length;
|
|
482
|
+
while (end > 0 && text[end - 1] === char) end--;
|
|
483
|
+
return text.slice(0, end);
|
|
484
|
+
}
|
|
475
485
|
|
|
476
486
|
//#endregion
|
|
477
487
|
export { ApiExtractedPackage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsdoctor/model",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Render Microsoft API Extractor models into LLM-lean markdown. Pure model loading, TSDoc extraction, type-signature formatting, and per-item markdown rendering.",
|
|
6
6
|
"keywords": [
|