@tsdoctor/model 0.8.1 → 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.
@@ -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+/, "").replace(/;+\s*$/, "").trim();
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 || "").replace(/\n+$/, "")}\n\`\`\``;
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.1",
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": [
@@ -39,8 +39,8 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@effected/yaml": "^0.17.0",
42
- "@microsoft/api-extractor-model": "^7.33.13",
43
- "@microsoft/tsdoc": "~0.17.0",
42
+ "@microsoft/api-extractor-model": "7.33.12",
43
+ "@microsoft/tsdoc": "~0.16.0",
44
44
  "@tsdoctor/vfs": "0.4.0"
45
45
  },
46
46
  "peerDependencies": {
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.59.2"
8
+ "packageVersion": "7.59.1"
9
9
  }
10
10
  ]
11
11
  }