From abd570c54e6b77acb66ac0954768f8999c9b5f9d Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Fri, 28 Jan 2022 10:20:21 +0100 Subject: [PATCH 1/3] docs: use html tables instead of md tables to account for ::: v-pre requirements --- scripts/apidoc.ts | 63 +++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/scripts/apidoc.ts b/scripts/apidoc.ts index 62fc9ed5762..e2b0d36abce 100644 --- a/scripts/apidoc.ts +++ b/scripts/apidoc.ts @@ -20,8 +20,14 @@ function toBlock(comment?: TypeDoc.Comment): string { ); } -function escape(value: string): string { - return value.replace(/\|/g, '\\|').replace(//g, '\\>'); +// https://stackoverflow.com/a/6234804/6897682 +function escapeHtml(unsafe: string): string { + return unsafe + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); } function parameterRow( @@ -30,20 +36,22 @@ function parameterRow( def?: string, comment?: TypeDoc.Comment ): string { - def = def ? `\`${def}\`` : ''; - return ( - '| ' + - escape(name) + - ' | ' + - escape(type) + - ' | ' + - def + - ' | ' + - escape(toBlock(comment)) - .replace(/\n{2,}/, '
') - .replace(/\n/, '') + - '|\n' - ); + def = def ? `${def}` : ''; + return ` + ${escapeHtml(name)} + ${escapeHtml(type)} + ${def} + + +::: v-pre + +${toBlock(comment)} + +::: + + + +`; } async function build(): Promise { @@ -133,10 +141,19 @@ async function build(): Promise { const signatureParameters: string[] = []; let requiresArgs = false; if (typeParameters.length !== 0 || parameters.length !== 0) { - content += `**Parameters**\n\n`; - - content += '| Name | Type | Default | Description |\n'; - content += '| ---- | ---- | ------- | ----------- |\n'; + content += `**Parameters** + + + + + + + + + + + +`; // typeParameters typeParameters.forEach((parameter, index) => { @@ -176,7 +193,11 @@ async function build(): Promise { parameter.comment ); }); - content += '\n\n'; + + content += ` +
NameTypeDefaultDescription
+ +`; } content += '**Returns:** ' + signature.type.toString() + '\n\n'; From cf21b2d3f0402e7ffc4e0454573cedecf4912242 Mon Sep 17 00:00:00 2001 From: Jessica Sachs Date: Fri, 28 Jan 2022 14:24:14 -0500 Subject: [PATCH 2/3] fix: table styles for td tags with p inside --- docs/.vitepress/theme/index.css | 4 ++++ docs/.vitepress/theme/index.mjs | 1 + 2 files changed, 5 insertions(+) create mode 100644 docs/.vitepress/theme/index.css diff --git a/docs/.vitepress/theme/index.css b/docs/.vitepress/theme/index.css new file mode 100644 index 00000000000..a90e7f84575 --- /dev/null +++ b/docs/.vitepress/theme/index.css @@ -0,0 +1,4 @@ + +table td * { + display: inline; +} diff --git a/docs/.vitepress/theme/index.mjs b/docs/.vitepress/theme/index.mjs index 26a6b5caf75..774ebda6b9f 100644 --- a/docs/.vitepress/theme/index.mjs +++ b/docs/.vitepress/theme/index.mjs @@ -1,3 +1,4 @@ +import './index.css' import GlobalComponents from './components'; import DefaultTheme from 'vitepress/theme'; From 921c699db57a39d4893f03ecb9f9cd1679b6a6b4 Mon Sep 17 00:00:00 2001 From: Shinigami Date: Fri, 28 Jan 2022 20:29:35 +0100 Subject: [PATCH 3/3] Apply suggestions from code review --- docs/.vitepress/theme/index.css | 1 - docs/.vitepress/theme/index.mjs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/.vitepress/theme/index.css b/docs/.vitepress/theme/index.css index a90e7f84575..21bbf49454b 100644 --- a/docs/.vitepress/theme/index.css +++ b/docs/.vitepress/theme/index.css @@ -1,4 +1,3 @@ - table td * { display: inline; } diff --git a/docs/.vitepress/theme/index.mjs b/docs/.vitepress/theme/index.mjs index 774ebda6b9f..b6bfbb86097 100644 --- a/docs/.vitepress/theme/index.mjs +++ b/docs/.vitepress/theme/index.mjs @@ -1,4 +1,4 @@ -import './index.css' +import './index.css'; import GlobalComponents from './components'; import DefaultTheme from 'vitepress/theme';