From 580ec4fb7781b794ce49a2d49c380ea9f7b3735d Mon Sep 17 00:00:00 2001 From: kunstewi Date: Mon, 9 Mar 2026 23:24:34 +0530 Subject: [PATCH 1/2] added the logic for generating reference docs from local custom build of p5.sound.js --- src/scripts/parsers/reference.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/scripts/parsers/reference.ts b/src/scripts/parsers/reference.ts index 92d44a1e22..0494930e0b 100644 --- a/src/scripts/parsers/reference.ts +++ b/src/scripts/parsers/reference.ts @@ -55,12 +55,21 @@ export const parseLibraryReference = if (useExternalP5Sound) { console.log('Cloning separate p5.sound repo'); - // Clone p5.sound.js - await cloneLibraryRepo( - localSoundPath, - 'https://github.com/processing/p5.sound.js.git', - 'main' - ); + // Clone or copy p5.sound.js + if (process.env.LOCAL_P5_SOUND_PATH) { + console.log(`Copying local p5.sound.js from ${process.env.LOCAL_P5_SOUND_PATH}`); + await fs.cp(process.env.LOCAL_P5_SOUND_PATH, localSoundPath, { + recursive: true, + // Ignore node_modules and .git to speed up the copy + filter: (src) => !src.includes('node_modules') && !src.includes('.git') + }); + } else { + await cloneLibraryRepo( + localSoundPath, + 'https://github.com/processing/p5.sound.js.git', + 'main' + ); + } await saveYuidocOutput('p5.sound.js', 'data-sound'); const soundData = await getYuidocOutput('data-sound'); if (!soundData) throw new Error('Error generating p5.sound reference data!'); From b7e20547965bc9fa0f0af181679d730b1dad27f8 Mon Sep 17 00:00:00 2001 From: kunstewi Date: Tue, 10 Mar 2026 12:32:25 +0530 Subject: [PATCH 2/2] updated the docs and extended the cleanup logic to also cleanup p5.sound.js build --- docs/scripts.md | 19 +++++++++++++++++++ src/scripts/resetBranchTest.ts | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/scripts.md b/docs/scripts.md index 17b841f224..c119ed2c36 100644 --- a/docs/scripts.md +++ b/docs/scripts.md @@ -6,6 +6,8 @@ They are all runnable via npm scripts. ## Testing the docs of your fork +### p5.js + If you are contributing a change to the main p5.js repo that affects documentation, you will want to preview how your changes will look on the website. To do so, make sure you have committed your changes to a branch of your fork of p5.js. Then, in the p5.js-website repo, run the following command, using the URL of your fork of p5 before the `#`, and the name of your branch after the `#`: @@ -30,6 +32,23 @@ For example, if you have a local p5.js clone repo called `p5.js` as a sibling di npm run custom:dev ../p5.js#yourBranch ``` +### p5.sound.js + +If you want to preview changes to the `p5.sound.js` documentation from your local machine, you can use the `LOCAL_P5_SOUND_PATH` environment variable. This will copy your local `p5.sound` repository directly instead of cloning it from GitHub, which is useful when testing your own unpushed changes or custom branches. + +Provide the file-path to your local `p5.sound` repository when running the reference build script. For example, if you have a local clone called `p5.sound` as a sibling directory to the website, you could run: + +```sh +LOCAL_P5_SOUND_PATH=../p5.sound npm run build:reference +``` +otherwise if you have added the file-path to the `p5.sound.js` build in your `.env` file using the +`LOCAL_P5_SOUND_PATH` environment variable, you could simply run: + +```sh +npm run build:reference +``` +This will copy your local files over (ignoring `node_modules` and `.git` folders to speed up the process) and build the reference documentation using those files. + ### Resetting your changes When you're done, you can run this command to reset your changes: diff --git a/src/scripts/resetBranchTest.ts b/src/scripts/resetBranchTest.ts index c444ec9ad0..288bc9972e 100644 --- a/src/scripts/resetBranchTest.ts +++ b/src/scripts/resetBranchTest.ts @@ -17,7 +17,7 @@ async function main() { envFilePath, currentEnv .split('\n') - .filter((line: string) => !line.startsWith('P5_') && !line.startsWith('PUBLIC_P5_')) + .filter((line: string) => !line.startsWith('P5_') && !line.startsWith('PUBLIC_P5_') && !line.startsWith('LOCAL_P5_SOUND_PATH')) .join('\n') ); }