Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bcherry committed Dec 18, 2024
1 parent 901b778 commit 78036a3
Showing 1 changed file with 27 additions and 32 deletions.
59 changes: 27 additions & 32 deletions tooling/api-documenter/src/documenters/MarkdownDocumenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1630,40 +1630,35 @@ export class MarkdownDocumenter {
}

private _getImportPath(apiItem: ApiDeclaredItem): string {
try {
// Check for custom import path from TSDoc first
if (apiItem instanceof ApiDocumentedItem && apiItem.tsdocComment) {
const packageTag: DocBlock | undefined = apiItem.tsdocComment.customBlocks.find(
(block) => block.blockTag.tagName === '@package',
);
// Check for custom import path from TSDoc first
if (apiItem instanceof ApiDocumentedItem && apiItem.tsdocComment) {
const packageTag: DocBlock | undefined = apiItem.tsdocComment.customBlocks.find(
(block) => block.blockTag.tagName === '@package',
);

if (packageTag) {
return packageTag.content.nodes
.map((node) => {
if (node.kind === DocNodeKind.Paragraph) {
return node
.getChildNodes()
.map((child) => {
if (child.kind === DocNodeKind.PlainText) {
return (child as DocPlainText).text;
}
return '';
})
.join('');
}
return '';
})
.join('')
.trim();
}
if (packageTag) {
return packageTag.content.nodes
.map((node) => {
if (node.kind === DocNodeKind.Paragraph) {
return node
.getChildNodes()
.map((child) => {
if (child.kind === DocNodeKind.PlainText) {
return (child as DocPlainText).text;
}
return '';
})
.join('');
}
return '';
})
.join('')
.trim();
}

// Fallback to canonical reference
// @ts-ignore
return apiItem.canonicalReference.source.escapedPath;
} catch (error) {
console.error(error);
return '';
}

// Fallback to canonical reference
// @ts-ignore
return apiItem.canonicalReference.source.escapedPath;
}
}

0 comments on commit 78036a3

Please sign in to comment.