Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 20 additions & 23 deletions scripts/Converter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,33 +155,30 @@ const _indent = (

// All the parse functions are to be used internally (its used to get sub content)
class TypeDocInternalParser {
static convertToItalic = (name: string | undefined) =>
name ? `_${name}_` : '';
static convertToItalic = (name: string | undefined) => (name ? `_${name}_` : '');

static convertNameToLink: (
node: string | undefined,
includeParent?: boolean,
) => string;
static convertNameToLink: (node: string | undefined, includeParent?: boolean) => string;

static GITHUB_LINK =
'https://github.com/thoughtspot/visual-embed-sdk/blob/main/src';
static GITHUB_LINK = 'https://github.com/thoughtspot/visual-embed-sdk/blob/main/src';

static covertTypeDocText = (text: string) => {
// convert all {@link Name.hash}
// to xref:Name.adoc#hash[Name]
const matches = text.match(/{@link\s[^{]+}/g);
if (!matches) return text;
const updatedText = matches?.reduce((prevUpdatedText, curLinkText) => {
const linkTo = curLinkText.split(/\s/)[1].replace('}', '');
const newLinkText = this.convertNameToLink(linkTo, true);

if (!newLinkText) return prevUpdatedText;
static covertTypeDocText = (text: string) => {
// 1) Convert Markdown links -> AsciiDoc links
const updated = text.replace(
/\[([^\]]+)\]\((https?:\/\/[^)]+)\)/g,
'link:$2[$1]',
);

return prevUpdatedText.replace(curLinkText, newLinkText);
}, text);
// 2) Existing logic: convert {@link Name.hash} -> xref:...
const matches = updated.match(/{@link\s[^{]+}/g);
if (!matches) return updated;

return updatedText;
};
return matches.reduce((prevUpdatedText, curLinkText) => {
const linkTo = curLinkText.split(/\s/)[1].replace(/}/g, '');
const newLinkText = this.convertNameToLink(linkTo, true);
if (!newLinkText) return prevUpdatedText;
return prevUpdatedText.replace(curLinkText, newLinkText);
}, updated);
};

// function to parse a tag
static parseTag(tag: TypeDocCommentTag): string {
Expand All @@ -195,7 +192,7 @@ class TypeDocInternalParser {
if (tag.tag === 'example') return `${tag.text}\n`;

if (tag.tag === 'param') {
return `\nParameter::\n${tag.text}\n`;
return `\nParameter::\n${this.covertTypeDocText(tag.text)}\n`;
}
if (tag.tag === 'deprecated') {
return `[deprecated]#Deprecated : ${tag.text.replace(
Expand Down
4 changes: 2 additions & 2 deletions typedocConverter.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"branch": "main",
"typeDocFilePath": "https://raw.githubusercontent.com/thoughtspot/visual-embed-sdk/{branch}/static/typedoc/typedoc.json"
"branch": "version-fix",
"typeDocFilePath": "https://raw.githubusercontent.com/thoughtspot/visual-embed-sdk/refs/heads/SCAL-288312/static/typedoc/typedoc.json"
}
Loading