Skip to content

Commit

Permalink
package
Browse files Browse the repository at this point in the history
  • Loading branch information
bcherry committed Dec 18, 2024
1 parent 3987aef commit 8dac148
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 7 deletions.
4 changes: 4 additions & 0 deletions packages/core/tsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"extends": [ "../../tsdoc.json" ]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions packages/react/tsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"extends": [ "../../tsdoc.json" ]
}
48 changes: 41 additions & 7 deletions tooling/api-documenter/src/documenters/MarkdownDocumenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import {
IFindApiItemsResult,
Parameter,
ApiPropertySignature,
ApiVariable,
} from '@microsoft/api-extractor-model';

import { CustomDocNodes } from '../nodes/CustomDocNodeKind';
Expand All @@ -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';
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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' }));
Expand Down Expand Up @@ -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 }, [
Expand All @@ -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 }, [
Expand Down Expand Up @@ -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 '';
}
}
}
9 changes: 9 additions & 0 deletions tsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"tagDefinitions": [
{
"tagName": "@package",
"syntaxKind": "block"
}
]
}

0 comments on commit 8dac148

Please sign in to comment.