Skip to content

Commit

Permalink
Merge branch 'master' into hc/fix-guide-typos
Browse files Browse the repository at this point in the history
  • Loading branch information
calldelegation authored Dec 6, 2024
2 parents 3f43d00 + f6d00fd commit 6489f30
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 90 deletions.
2 changes: 1 addition & 1 deletion docs/fuels-ts
Submodule fuels-ts updated 645 files
2 changes: 1 addition & 1 deletion docs/nightly/fuels-ts
Submodule fuels-ts updated 645 files
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@
"shiki@>0.14.4": "0.14.4"
}
}
}
}
42 changes: 1 addition & 41 deletions scripts/generate-links/processVPConfig.mjs
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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:') ||
Expand Down Expand Up @@ -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 };
Expand Down
3 changes: 1 addition & 2 deletions scripts/update-nightly/updateSubmodules.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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`;
Expand Down
9 changes: 6 additions & 3 deletions src/components/AskCookbook.tsx
Original file line number Diff line number Diff line change
@@ -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 <BaseAskCookbook apiKey={PUBLIC_API_KEY} />;
}
};
3 changes: 2 additions & 1 deletion src/components/VersionDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
</Dropdown.Trigger>
<Dropdown.Menu
disabledKeys={versionSet === 'default' ? [FUEL_TESTNET] : [versionSet]}
Expand Down
2 changes: 1 addition & 1 deletion src/config/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@
"image": ""
}
}
}
}
2 changes: 1 addition & 1 deletion src/config/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"sway_libs": "0.24.0",
"sway_standards": "0.6.1"
}
}
}
2 changes: 1 addition & 1 deletion src/lib/md-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class DocParser {
slug = slug.replaceAll(key, value as string);
}

if(slug.endsWith('/src')){
if (slug.endsWith('/src')) {
slug = slug.replace('/src', '');
}

Expand Down
66 changes: 36 additions & 30 deletions src/lib/plugins/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export function handleLinks(
if (newUrl.includes('/sway-libs')) {
newUrl = newUrl
.replace('/src/src/', '/src/')
.replace('sway-libs/tree/libs/nft','sway-libs/tree/v0.12.0/libs/nft');
.replace(
'sway-libs/tree/libs/nft',
'sway-libs/tree/v0.12.0/libs/nft'
);
}
}

Expand Down Expand Up @@ -302,70 +305,73 @@ function handleNewURLs(

function replaceInternalLinks(href: string, base: string) {
let newHref = href;
if(newHref.startsWith('https://github.com/FuelLabs/sway-standards/') && newHref.endsWith('.md') && !newHref.includes('README.md')){
if (
newHref.startsWith('https://github.com/FuelLabs/sway-standards/') &&
newHref.endsWith('.md') &&
!newHref.includes('README.md')
) {
const split = newHref.split('/');
let docName = split[split.length -1].replace(".md", "");
let docName = split[split.length - 1].replace('.md', '');
switch (docName) {
case 'src-2':
docName = 'src-2-inline-documentation'
docName = 'src-2-inline-documentation';
break;
case 'src-3':
docName = 'src-3-minting-and-burning'
docName = 'src-3-minting-and-burning';
break;
case 'src-5':
docName = 'src-5-ownership'
docName = 'src-5-ownership';
break;
case 'src-6':
docName = 'src-6-vault'
docName = 'src-6-vault';
break;
case 'src-7':
docName = 'src-7-asset-metadata'
docName = 'src-7-asset-metadata';
break;
case 'src-8':
docName = 'src-8-bridged-asset'
docName = 'src-8-bridged-asset';
break;
case 'src-9':
docName = 'src-9-metadata-keys'
docName = 'src-9-metadata-keys';
break;
case 'src-10':
docName = 'src-10-native-bridge'
docName = 'src-10-native-bridge';
break;
case 'src-11':
docName = 'src-11-security-information'
docName = 'src-11-security-information';
break;
case 'src-12':
docName = 'src-12-contract-factory'
docName = 'src-12-contract-factory';
break;
case 'src-13':
docName = 'src-13-soulbound-address'
docName = 'src-13-soulbound-address';
break;
case 'src-14':
docName = 'src-14-simple-upgradeable-proxies'
docName = 'src-14-simple-upgradeable-proxies';
break;
case 'src-20':
docName = 'src-20-native-asset'
docName = 'src-20-native-asset';
break;
default:
break;
}
newHref = `docs/sway-standards/${docName}`
newHref = `docs/sway-standards/${docName}`;
}

if(newHref.includes('specs.fuel.network/')){
if (newHref.includes('specs.fuel.network/')) {
newHref = newHref
.replace('.html', '')
.replace('/protocol/abi/', '/abi/')
.replace(/\/index$/, '/')
.replace('https://', '')
.replace('http://', '')
.replace('specs.fuel.network/', 'docs/specs/')
.replace('/master/', '/')
.replace('/tree/', '/')
.replace('/blob/', '/')
.replace(/\/v\d+\.\d+\.\d+\//, '/')
.replace('.html', '')
.replace('/protocol/abi/', '/abi/')
.replace(/\/index$/, '/')
.replace('https://', '')
.replace('http://', '')
.replace('specs.fuel.network/', 'docs/specs/')
.replace('/master/', '/')
.replace('/tree/', '/')
.replace('/blob/', '/')
.replace(/\/v\d+\.\d+\.\d+\//, '/');
}


if (
newHref.startsWith('https://fuellabs.github.io') &&
!newHref.includes('fuellabs.github.io/block-explorer-v2') &&
Expand Down Expand Up @@ -431,7 +437,7 @@ function replaceInternalLinks(href: string, base: string) {
if (newHref.startsWith('/docs/')) {
newHref = newHref.replace('/docs/', 'docs/');
}
if(newHref.startsWith('docs/')){
if (newHref.startsWith('docs/')) {
newHref = newHref.replace('/src/', '/');
}

Expand Down
10 changes: 8 additions & 2 deletions src/lib/plugins/mdbook-example-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ export function handleExampleImports(
if (paths.length > 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];
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
7 changes: 5 additions & 2 deletions tests/utils/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<{
Expand All @@ -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 = [
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/runCommand.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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...`);
Expand Down

0 comments on commit 6489f30

Please sign in to comment.