Skip to content

Commit

Permalink
remove markdown links
Browse files Browse the repository at this point in the history
  • Loading branch information
bcherry committed Dec 19, 2024
1 parent 074e4ed commit ae92d3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface useKrispNoiseFilterOptions {
* Defaults to the localParticipant's microphone track publication, but you can override this behavior by passing in a different track reference.
*
* @package \@livekit/components-react/krisp
* @remarks This filter requires that you install the `@livekit/krisp-noise-filter` package and is supported only on [LiveKit Cloud](https://cloud.livekit.io).
* @remarks This filter requires that you install the `@livekit/krisp-noise-filter` package and is supported only on {@link https://cloud.livekit.io | LiveKit Cloud}.
* @beta
* @example
* ```tsx
Expand Down
100 changes: 8 additions & 92 deletions tooling/api-documenter/src/documenters/MarkdownDocumenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export class MarkdownDocumenter {
);
}

this._appendSection(output, this._processMarkdownContent(tsdocComment.summarySection));
this._appendSection(output, tsdocComment.summarySection);
}
}

Expand Down Expand Up @@ -501,10 +501,7 @@ export class MarkdownDocumenter {
// Write the @remarks block
if (tsdocComment.remarksBlock) {
output.appendNode(new DocHeading({ configuration, title: 'Remarks', level: 2 }));
this._appendSection(
output,
this._processMarkdownContent(tsdocComment.remarksBlock.content),
);
this._appendSection(output, tsdocComment.remarksBlock.content);
}

// Write the @example blocks
Expand Down Expand Up @@ -583,85 +580,15 @@ export class MarkdownDocumenter {
newContent.appendNode(exampleBlock.content.nodes[i]);
}

this._appendSection(output, this._processMarkdownContent(newContent));
this._appendSection(output, newContent);
} else {
this._appendSection(output, this._processMarkdownContent(exampleBlock.content));
this._appendSection(output, exampleBlock.content);
}
}
}
}
}

private _processMarkdownContent(content: DocSection): DocSection {
const configuration: TSDocConfiguration = this._tsdocConfiguration;
const processedSection: DocSection = new DocSection({ configuration });

// Process each node in the content
for (const node of content.nodes) {
if (node.kind === DocNodeKind.Paragraph) {
const paragraph: DocParagraph = node as DocParagraph;
const processedParagraph: DocParagraph = new DocParagraph({ configuration });

// Process each child node in the paragraph
for (const child of paragraph.getChildNodes()) {
if (child.kind === DocNodeKind.PlainText || child.kind === DocNodeKind.EscapedText) {
const text: string =
child.kind === DocNodeKind.PlainText
? (child as DocPlainText).text
: (child as DocEscapedText).decodedText;

// Look for markdown links [text](url)
const linkRegex: RegExp = /\[([^\]]+)\]\(([^)]+)\)/g;
let lastIndex: number = 0;
let match: RegExpExecArray | null;

while ((match = linkRegex.exec(text)) !== null) {
// Add any text before the link
if (match.index > lastIndex) {
processedParagraph.appendNode(
new DocPlainText({
configuration,
text: text.substring(lastIndex, match.index),
}),
);
}

// Add the link
processedParagraph.appendNode(
new DocLinkTag({
configuration,
tagName: '@link',
linkText: match[1],
urlDestination: match[2],
}),
);

lastIndex = match.index + match[0].length;
}

// Add any remaining text
if (lastIndex < text.length) {
processedParagraph.appendNode(
new DocPlainText({
configuration,
text: text.substring(lastIndex),
}),
);
}
} else {
processedParagraph.appendNode(child);
}
}

processedSection.appendNode(processedParagraph);
} else {
processedSection.appendNode(node);
}
}

return processedSection;
}

private _writeThrowsSection(output: DocSection, apiItem: ApiItem): void {
const configuration: TSDocConfiguration = this._tsdocConfiguration;

Expand All @@ -679,9 +606,7 @@ export class MarkdownDocumenter {
output.appendNode(new DocHeading({ configuration, title: heading }));

for (const throwsBlock of throwsBlocks) {
// Process throws blocks for markdown links
const processedContent = this._processMarkdownContent(throwsBlock.content);
this._appendSection(output, processedContent);
this._appendSection(output, throwsBlock.content);
}
}
}
Expand Down Expand Up @@ -1283,10 +1208,7 @@ export class MarkdownDocumenter {

if (apiParameterListMixin instanceof ApiDocumentedItem) {
if (apiParameterListMixin.tsdocComment?.returnsBlock) {
this._appendSection(
output,
this._processMarkdownContent(apiParameterListMixin.tsdocComment.returnsBlock.content),
);
this._appendSection(output, apiParameterListMixin.tsdocComment.returnsBlock.content);
}
}

Expand Down Expand Up @@ -1498,9 +1420,7 @@ export class MarkdownDocumenter {

if (apiItem instanceof ApiDocumentedItem) {
if (apiItem.tsdocComment !== undefined) {
// Process summary section for markdown links
const processedSummary = this._processMarkdownContent(apiItem.tsdocComment.summarySection);
this._appendAndMergeSection(section, processedSummary);
this._appendAndMergeSection(section, apiItem.tsdocComment.summarySection);
}
}

Expand Down Expand Up @@ -1674,11 +1594,7 @@ export class MarkdownDocumenter {
for (const node of docSection.nodes) {
if (firstNode) {
if (node.kind === DocNodeKind.Paragraph) {
// Process paragraph nodes for markdown links
const processedParagraph = this._processMarkdownContent(
new DocSection({ configuration: this._tsdocConfiguration }, [node]),
);
output.appendNodesInParagraph(processedParagraph.nodes[0].getChildNodes());
output.appendNodesInParagraph(node.getChildNodes());
firstNode = false;
continue;
}
Expand Down

0 comments on commit ae92d3a

Please sign in to comment.