From f6d00fdb3c641cc828c5db0907c7541a4431dc08 Mon Sep 17 00:00:00 2001 From: dhai Date: Sat, 7 Dec 2024 00:07:46 +0530 Subject: [PATCH] chore: remove validation for ts api docs (#485) * chore: remove validation for ts api docs * update ts sdk * chore: fixing build error (#523) * update * Revert "update" This reverts commit aa8c6e016b1ef109e036071ce30dc94dd21247c9. * reverse * revert * lint * removed api docs commit ts sdk * remove line --------- Co-authored-by: Matt <54373384+matt-user@users.noreply.github.com> Co-authored-by: Daniel Bate Co-authored-by: Peter Smith Co-authored-by: Call Delegation <106365423+calldelegation@users.noreply.github.com> --- docs/fuels-ts | 2 +- docs/nightly/fuels-ts | 2 +- package.json | 2 +- scripts/generate-links/processVPConfig.mjs | 42 +------------ scripts/update-nightly/updateSubmodules.mjs | 3 +- src/components/AskCookbook.tsx | 9 ++- src/components/VersionDropdown.tsx | 3 +- src/config/docs.json | 2 +- src/config/versions.json | 2 +- src/lib/md-parser.ts | 2 +- src/lib/plugins/links.ts | 66 +++++++++++---------- src/lib/plugins/mdbook-example-import.ts | 10 +++- src/pages/_app.tsx | 2 +- tests/utils/fixtures/index.ts | 7 ++- tests/utils/runCommand.ts | 4 +- 15 files changed, 68 insertions(+), 90 deletions(-) diff --git a/docs/fuels-ts b/docs/fuels-ts index f2953bf35..d29e88426 160000 --- a/docs/fuels-ts +++ b/docs/fuels-ts @@ -1 +1 @@ -Subproject commit f2953bf359bc022766351ae57419b59dc5bddddc +Subproject commit d29e884268bc43b70c4cd69a64a066943b116807 diff --git a/docs/nightly/fuels-ts b/docs/nightly/fuels-ts index f2953bf35..d29e88426 160000 --- a/docs/nightly/fuels-ts +++ b/docs/nightly/fuels-ts @@ -1 +1 @@ -Subproject commit f2953bf359bc022766351ae57419b59dc5bddddc +Subproject commit d29e884268bc43b70c4cd69a64a066943b116807 diff --git a/package.json b/package.json index d41ca19c1..d9ca82683 100644 --- a/package.json +++ b/package.json @@ -133,4 +133,4 @@ "shiki@>0.14.4": "0.14.4" } } -} \ No newline at end of file +} diff --git a/scripts/generate-links/processVPConfig.mjs b/scripts/generate-links/processVPConfig.mjs index eadcd2958..4ab10cf85 100644 --- a/scripts/generate-links/processVPConfig.mjs +++ b/scripts/generate-links/processVPConfig.mjs @@ -1,20 +1,4 @@ -import { EOL } from 'os'; - -import { getFile } from './getFile.mjs'; - -const tsAPIOrderFile = getFile( - './fuels-ts/apps/docs/.typedoc/api-links.json', - 'default', - true -); -const nightlyTsAPIOrderFile = getFile( - './fuels-ts/apps/docs/.typedoc/api-links.json', - 'nightly', - true -); - function extractData(inputString) { - // used for api.json order const regex = /"([^"]+)":\s*"([^"]+)"/g; const match = regex.exec(inputString); if (match !== null) { @@ -29,11 +13,10 @@ function handleVPLine( index, thisOrder, thisCat, - isNightly ) { const regex = /'([^']+)'/; // Create a shallow copy - let newVPOrder = JSON.parse(JSON.stringify(thisOrder)); + const newVPOrder = JSON.parse(JSON.stringify(thisOrder)); let category = thisCat; if ( trimmedLine.includes('collapsed:') || @@ -79,29 +62,6 @@ function handleVPLine( newVPOrder.menu.push(linkName); } } - } else if (trimmedLine.startsWith('apiLinks')) { - // handle API order - newVPOrder.menu.push('API'); - let apiJSON; - if (isNightly) { - apiJSON = nightlyTsAPIOrderFile; - } else { - apiJSON = tsAPIOrderFile; - } - const apiLines = JSON.stringify(apiJSON, null, 2).split(EOL); - apiLines.forEach((apiLine, apiIndex) => { - const trimmedAPILine = apiLine.trimStart(); - const results = handleVPLine( - trimmedAPILine, - apiLines, - apiIndex, - newVPOrder, - category, - isNightly - ); - category = results.category; - newVPOrder = results.newVPOrder; - }); } return { newVPOrder, category }; diff --git a/scripts/update-nightly/updateSubmodules.mjs b/scripts/update-nightly/updateSubmodules.mjs index 04be8c0cd..5bc47a06a 100644 --- a/scripts/update-nightly/updateSubmodules.mjs +++ b/scripts/update-nightly/updateSubmodules.mjs @@ -34,7 +34,7 @@ export async function updateSubmodules(newDefaultVersions, newNightlyVersions) { const updateRegardless = [ 'docs/nightly/fuel-specs', 'docs/nightly/fuel-graphql-docs', - 'docs/nightly/migrations-and-disclosures' + 'docs/nightly/migrations-and-disclosures', ]; await Promise.all( updateRegardless.map(async (sub) => { @@ -74,7 +74,6 @@ async function updateDocs(versions, isNightly) { break; case 'ts': submoduleName = `docs${isNightly ? '/nightly' : ''}/fuels-ts`; - branch = 'docs'; break; case 'wallet': submoduleName = `docs${isNightly ? '/nightly' : ''}/fuels-wallet`; diff --git a/src/components/AskCookbook.tsx b/src/components/AskCookbook.tsx index bed2e2dce..8fcd5c37e 100644 --- a/src/components/AskCookbook.tsx +++ b/src/components/AskCookbook.tsx @@ -1,9 +1,12 @@ import dynamic from 'next/dynamic'; -const BaseAskCookbook = dynamic(() => import('@cookbookdev/docsbot/react'), { ssr: false }); +const BaseAskCookbook = dynamic(() => import('@cookbookdev/docsbot/react'), { + ssr: false, +}); /** It's a public API key, so it's safe to expose it here */ -const PUBLIC_API_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI2NWYwZGRiNTc0YWNiMmU0NWFmOThiYjYiLCJpYXQiOjE3MTAyODQyMTMsImV4cCI6MjAyNTg2MDIxM30.WxJO7NrRekz6OCWb2wa8gZeFEfRfUM48Ks0GKqScVXo"; +const PUBLIC_API_KEY = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI2NWYwZGRiNTc0YWNiMmU0NWFmOThiYjYiLCJpYXQiOjE3MTAyODQyMTMsImV4cCI6MjAyNTg2MDIxM30.WxJO7NrRekz6OCWb2wa8gZeFEfRfUM48Ks0GKqScVXo'; export const AskCookbook = () => { return ; -} +}; diff --git a/src/components/VersionDropdown.tsx b/src/components/VersionDropdown.tsx index 6e60314d8..2c7fab5df 100644 --- a/src/components/VersionDropdown.tsx +++ b/src/components/VersionDropdown.tsx @@ -41,7 +41,8 @@ export default function VersionDropdown({ opened ? { ...styles.trigger, ...styles.triggerOpen } : styles.trigger } > - Version: {activeVersion === FUEL_TESTNET_UPPER_CASE ? 'Stable' : activeVersion} + Version:{' '} + {activeVersion === FUEL_TESTNET_UPPER_CASE ? 'Stable' : activeVersion} 1) exampleName = filePath.split(':').pop(); } else if (node.type === 'text') { // handle ts-sdk docs example format - const relativePath = dirname.replace('docs/fuels-ts/', '') - filePath = filePath.replace('<<< @./', `${relativePath}/`).replace(/<<< @\/?/, ''); + filePath = filePath.replace(/<<< @\/?/, ''); const pathData = filePath.split('{'); filePath = pathData[0]; @@ -132,6 +131,13 @@ export function handleExampleImports( ) .replace('fuels-ts/docs', 'fuels-ts/apps/docs'); } + + // If the example snippet is a relative path + // Then we can just join up the current dir path with the relative snippet path + if (filePath.startsWith('./')) { + fileAbsPath = path.join(dirname, filePath); + } + const fileContent = fs.readFileSync(fileAbsPath, 'utf8'); const cachedFile = getFilesOnCache(fileAbsPath); diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 14c850717..ffc00b5a6 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -6,10 +6,10 @@ import '../styles/docsearch.css'; import '../styles/index.css'; import { FuelWalletConnector, FueletWalletConnector } from '@fuels/connectors'; +import { AskCookbook } from '../components/AskCookbook'; import { Provider } from '../components/Provider'; import { ShowWarningProvider } from '../hooks/useShowWarning'; import { VersionProvider } from '../hooks/useVersion'; -import { AskCookbook } from '../components/AskCookbook'; const queryClient = new QueryClient(); diff --git a/tests/utils/fixtures/index.ts b/tests/utils/fixtures/index.ts index 4f7c474f4..6f3427125 100644 --- a/tests/utils/fixtures/index.ts +++ b/tests/utils/fixtures/index.ts @@ -9,7 +9,10 @@ import { waitForExtensions } from './utils/waitForExtenssions'; import { readFileSync } from 'fs'; import { join } from 'path'; -const versionFile = readFileSync(join(process.cwd(), 'src/config/versions.json'), 'utf-8'); +const versionFile = readFileSync( + join(process.cwd(), 'src/config/versions.json'), + 'utf-8' +); const versions = JSON.parse(versionFile); export const test = base.extend<{ @@ -19,7 +22,7 @@ export const test = base.extend<{ // biome-ignore lint/correctness/noEmptyPattern: context: async ({}, use) => { // download fuel wallet - console.log("DOWNLOADING WALLET VERSION", versions.default.wallet) + console.log('DOWNLOADING WALLET VERSION', versions.default.wallet); const fuelPathExtension = await downloadFuel(versions.default.wallet); // prepare browser args const browserArgs = [ diff --git a/tests/utils/runCommand.ts b/tests/utils/runCommand.ts index dbec96813..9c4acba89 100644 --- a/tests/utils/runCommand.ts +++ b/tests/utils/runCommand.ts @@ -1,7 +1,7 @@ import { execSync } from 'child_process'; +import fs from 'fs'; import { EOL } from 'os'; import type { Page } from '@playwright/test'; -import fs from 'fs'; import { clickCopyButton } from './button'; import { expect } from './fixtures'; @@ -22,7 +22,7 @@ export async function runCommand( command = preCommand + copied.text; } } -if (goToFolder) { + if (goToFolder) { const projectPath = `guides-testing/${goToFolder}`; if (fs.existsSync(projectPath)) { console.log(`Directory ${projectPath} already exists. Deleting...`);