From 8dac148f32209dd3fa4abb1832da847d197591bc Mon Sep 17 00:00:00 2001 From: Ben Cherry Date: Wed, 18 Dec 2024 14:57:34 -0800 Subject: [PATCH] package --- packages/core/tsdoc.json | 4 ++ .../hooks/cloud/krisp/useKrispNoiseFilter.ts | 1 + packages/react/tsdoc.json | 4 ++ .../src/documenters/MarkdownDocumenter.ts | 48 ++++++++++++++++--- tsdoc.json | 9 ++++ 5 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 packages/core/tsdoc.json create mode 100644 packages/react/tsdoc.json create mode 100644 tsdoc.json diff --git a/packages/core/tsdoc.json b/packages/core/tsdoc.json new file mode 100644 index 000000000..ab7d7f2f1 --- /dev/null +++ b/packages/core/tsdoc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "extends": [ "../../tsdoc.json" ] +} diff --git a/packages/react/src/hooks/cloud/krisp/useKrispNoiseFilter.ts b/packages/react/src/hooks/cloud/krisp/useKrispNoiseFilter.ts index e80c62717..a8a196ba7 100644 --- a/packages/react/src/hooks/cloud/krisp/useKrispNoiseFilter.ts +++ b/packages/react/src/hooks/cloud/krisp/useKrispNoiseFilter.ts @@ -21,6 +21,7 @@ export interface useKrispNoiseFilterOptions { * This hook is a convenience helper for enabling Krisp Enhanced Audio Noise Cancellation on LiveKit audio tracks. * It returns a `setNoiseFilterEnabled` method to conveniently toggle between enabled and disabled states. * + * @package @livekit/components-react/krisp * @remarks Krisp noise filter is a feature that's only supported on LiveKit cloud plans * @alpha * @example diff --git a/packages/react/tsdoc.json b/packages/react/tsdoc.json new file mode 100644 index 000000000..ab7d7f2f1 --- /dev/null +++ b/packages/react/tsdoc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "extends": [ "../../tsdoc.json" ] +} diff --git a/tooling/api-documenter/src/documenters/MarkdownDocumenter.ts b/tooling/api-documenter/src/documenters/MarkdownDocumenter.ts index 75e3c01cf..a1c61bac6 100644 --- a/tooling/api-documenter/src/documenters/MarkdownDocumenter.ts +++ b/tooling/api-documenter/src/documenters/MarkdownDocumenter.ts @@ -49,7 +49,6 @@ import { IFindApiItemsResult, Parameter, ApiPropertySignature, - ApiVariable, } from '@microsoft/api-extractor-model'; import { CustomDocNodes } from '../nodes/CustomDocNodeKind'; @@ -58,7 +57,6 @@ import { DocTable } from '../nodes/DocTable'; import { DocEmphasisSpan } from '../nodes/DocEmphasisSpan'; import { DocTableRow } from '../nodes/DocTableRow'; import { DocTableCell } from '../nodes/DocTableCell'; -import { DocNoteBox } from '../nodes/DocNoteBox'; import { Utilities } from '../utils/Utilities'; import { CustomMarkdownEmitter } from '../markdown/CustomMarkdownEmitter'; import { PluginLoader } from '../plugin/PluginLoader'; @@ -272,8 +270,7 @@ export class MarkdownDocumenter { if (category !== undefined) { let importPath: string = ''; try { - // @ts-ignore - importPath = apiItem.canonicalReference.source.escapedPath; + importPath = this._getImportPath(apiItem); } catch (error) { console.error(error); } @@ -751,7 +748,6 @@ export class MarkdownDocumenter { // if (classesTable.rows.length > 0) { // output.appendNode(new DocHeading({ configuration, title: 'Classes' })); // output.appendNode(classesTable); - // } // if (abstractClassesTable.rows.length > 0) { // output.appendNode(new DocHeading({ configuration, title: 'Abstract Classes' })); @@ -1504,7 +1500,7 @@ export class MarkdownDocumenter { private _writeBetaWarning(output: DocSection): void { const configuration: TSDocConfiguration = this._tsdocConfiguration; const betaWarning: string = - "This feature is under active development and may change based on developer feedback and real-world usage." + 'This feature is under active development and may change based on developer feedback and real-world usage.'; output.appendNode( new Callout({ configuration }, [ new DocParagraph({ configuration }, [ @@ -1517,7 +1513,7 @@ export class MarkdownDocumenter { private _writeAlphaWarning(output: DocSection): void { const configuration: TSDocConfiguration = this._tsdocConfiguration; const alphaWarning: string = - "This feature is experimental and may change or be removed based on developer feedback and real-world usage." + 'This feature is experimental and may change or be removed based on developer feedback and real-world usage.'; output.appendNode( new Callout({ configuration }, [ new DocParagraph({ configuration }, [ @@ -1631,4 +1627,42 @@ export class MarkdownDocumenter { console.log('Deleting old output from ' + this._outputFolder); FileSystem.ensureEmptyFolder(this._outputFolder); } + + 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', + ); + + 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 ''; + } + } } diff --git a/tsdoc.json b/tsdoc.json new file mode 100644 index 000000000..bf943edec --- /dev/null +++ b/tsdoc.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "tagDefinitions": [ + { + "tagName": "@package", + "syntaxKind": "block" + } + ] +} \ No newline at end of file