From 5e8483d42c50b9ee86868849d5bf10928e9b5066 Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Tue, 3 Oct 2023 15:31:23 -0400 Subject: [PATCH 1/3] add a typedoc plugin script to inject a favicon, add favicon asset, update eslintrc and package.json --- .eslintrc.json | 3 ++- assets/docs-theme.js | 38 ++++++++++++++++++++++++++++++++++++++ assets/favicon-32x32.png | Bin 0 -> 530 bytes package.json | 2 +- 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 assets/docs-theme.js create mode 100644 assets/favicon-32x32.png diff --git a/.eslintrc.json b/.eslintrc.json index e16003fe..4a280aea 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,8 @@ { "env": { "browser": true, - "es2021": true + "es2021": true, + "node": true }, "ignorePatterns": ["dist", "src/pinecone-generated-ts-fetch", "src/v0"], "extends": [ diff --git a/assets/docs-theme.js b/assets/docs-theme.js new file mode 100644 index 00000000..7fc78a7e --- /dev/null +++ b/assets/docs-theme.js @@ -0,0 +1,38 @@ +import { copyFileSync } from 'fs'; +import { join } from 'path'; + +/** + * This script is passed into typedoc at build time, and is used to hook into their rendering + * pipeline allowing us to modify the output. + * + * example: typedoc --plugin ./assets/docs-theme.js + * TypeDoc documentation: https://github.com/TypeStrong/typedoc/blob/master/internal-docs/custom-themes.md#hooks-v0228 + */ + +export const load = (app) => { + // See PageEvent: https://github.com/TypeStrong/typedoc/blob/f2d2abe054feca91b89c00c33e1d726bbda85dcb/src/lib/output/events.ts#L134 + app.renderer.on('endPage', onPageRendered.bind(this)); + // See RendererEvent: https://github.com/TypeStrong/typedoc/blob/f2d2abe054feca91b89c00c33e1d726bbda85dcb/src/lib/output/events.ts#L47 + app.renderer.once('endRender', onRenderFinished.bind(this)); +}; + +function onPageRendered(page) { + // after the page is rendered we want to insert a favicon into head + if (page && page.contents) { + page.contents = page.contents.replace( + '', + `` + '\n' + '' + ); + } +} + +function onRenderFinished() { + // rendering complete, copy favicon asset into /docs folder + if (process) { + const workingDir = process.cwd(); + const startingFavIcon = join(workingDir, '/assets/favicon-32x32.png'); + const endingFavIcon = join(workingDir, './docs', '/favicon-32x32.png'); + + copyFileSync(startingFavIcon, endingFavIcon); + } +} diff --git a/assets/favicon-32x32.png b/assets/favicon-32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..4f9c615efe686f19d1fd7ef226e6b97c3e24c346 GIT binary patch literal 530 zcmV+t0`2{YP)Jb>hBd|djfepe2$p)blBpc8T(hcYa8G)ihIxEJcV4(fs-RTUHEj?MX z4eZ#l4ooK&|A3^EV<(SJ+P@}YRbUbNH`owH31xrfZwg#>(y%0089AOaZB>wz|1&02 zU;~_0;2h7jPS|dguI70LD}fw-V%ipyt%4(b!3rgz8kguZA_A$h<>r$4D6l4S#TI!YdEmM9$HvM>Q+)a@3oF^Ry{1%ts3{^~0=gW-N9c$lK?`?-Mn6&|+%ZZ#UCz!c9{r;#N7%o(W})I> zmK|A-T+82-X%-+rYYi6Q3b)O^vx4m!nF>z!#czOIwGBIe< src/version.json", - "docs:build": "typedoc", + "docs:build": "typedoc --plugin ./assets/docs-theme.mjs", "format": "prettier --write .", "lint": "eslint src/ --ext .ts", "repl": "npm run build && node utils/replInit.ts", From 780d0d40565fe93cdc82c7d3a4ff1af9b63d19ef Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Tue, 3 Oct 2023 16:15:18 -0400 Subject: [PATCH 2/3] swap to .mjs for the plugin script --- assets/{docs-theme.js => docs-theme.mjs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename assets/{docs-theme.js => docs-theme.mjs} (94%) diff --git a/assets/docs-theme.js b/assets/docs-theme.mjs similarity index 94% rename from assets/docs-theme.js rename to assets/docs-theme.mjs index 7fc78a7e..4b6d1b71 100644 --- a/assets/docs-theme.js +++ b/assets/docs-theme.mjs @@ -21,7 +21,7 @@ function onPageRendered(page) { if (page && page.contents) { page.contents = page.contents.replace( '', - `` + '\n' + '' + '' ); } } From 353a97fa74a7e1bbd059c4739a41fff2c7320e6f Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Mon, 9 Oct 2023 00:57:17 -0400 Subject: [PATCH 3/3] update comment, move docs css into assets folder --- docs-styles.css => assets/docs-styles.css | 0 assets/docs-theme.mjs | 2 +- typedoc.json | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename docs-styles.css => assets/docs-styles.css (100%) diff --git a/docs-styles.css b/assets/docs-styles.css similarity index 100% rename from docs-styles.css rename to assets/docs-styles.css diff --git a/assets/docs-theme.mjs b/assets/docs-theme.mjs index 4b6d1b71..d56637f8 100644 --- a/assets/docs-theme.mjs +++ b/assets/docs-theme.mjs @@ -5,7 +5,7 @@ import { join } from 'path'; * This script is passed into typedoc at build time, and is used to hook into their rendering * pipeline allowing us to modify the output. * - * example: typedoc --plugin ./assets/docs-theme.js + * example: typedoc --plugin ./assets/docs-theme.mjs * TypeDoc documentation: https://github.com/TypeStrong/typedoc/blob/master/internal-docs/custom-themes.md#hooks-v0228 */ diff --git a/typedoc.json b/typedoc.json index 6c4aa39e..4d4aa784 100644 --- a/typedoc.json +++ b/typedoc.json @@ -6,7 +6,7 @@ "includeVersion": true, "excludeInternal": true, "out": "docs", - "customCss": "./docs-styles.css", + "customCss": "./assets/docs-styles.css", "navigationLinks": { "Github Repo": "https://github.com/pinecone-io/pinecone-ts-client", "Pinecone Docs": "https://docs.pinecone.io"