Skip to content

Commit b37511d

Browse files
committed
WIP: build docs from 2.0 dev branches
1 parent c4eea2e commit b37511d

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

src/globals/globals.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export const sketchesPerPage = 12 as const;
1414
export const eventsPerPage = 12 as const;
1515

1616
export const cdnLibraryUrl =
17-
`https://cdn.jsdelivr.net/npm/p5@${p5Version}/lib/p5.min.js` as const;
17+
`/p5.min.js` as const;
18+
// `https://cdn.jsdelivr.net/npm/p5@${p5Version}/lib/p5.min.js` as const;
1819
export const fullDownloadUrl =
1920
`https://github.com/processing/p5.js/releases/download/v${p5Version}/p5.zip` as const;
2021
export const libraryDownloadUrl =

src/scripts/parsers/reference.ts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { cloneLibraryRepo, readFile } from "../utils";
22
import fs from "fs/promises";
3-
import { exec } from "child_process";
3+
import { exec, execSync } from "child_process";
44
import path from "path";
55
import { fileURLToPath } from "url";
66
import type { ParsedLibraryReference } from "../../../types/parsers.interface";
@@ -18,13 +18,16 @@ const yuidocOutputPath = path.join(__dirname, "out")
1818
export const parseLibraryReference =
1919
async (): Promise<ParsedLibraryReference | null> => {
2020
// Clone p5.js
21-
await cloneLibraryRepo(localPath);
21+
await cloneLibraryRepo(localPath, 'https://github.com/Garima3110/p5.js.git', 'shaders', { shouldFixAbsolutePathInPreprocessor: false });
2222
// TODO(dave): let this happen via `npm run docs` in the p5 repo once we
2323
// merge the 2.0 branch
24-
await saveYuidocOutput('p5.js', 'data-p5', {
24+
await createP5Docs('p5.js', 'data-p5')
25+
// If dev
26+
await createP5Build('p5.js')
27+
/*await saveYuidocOutput('p5.js', 'data-p5', {
2528
flags: `--config ${path.join(__dirname, '../../../yuidoc.json')}`,
2629
inputPath: './src',
27-
});
30+
});*/
2831
const p5Data = await getYuidocOutput('data-p5');
2932
if (!p5Data) throw new Error('Error generating p5 reference data!');
3033

@@ -128,6 +131,31 @@ export const saveYuidocOutput = async (
128131
}
129132
};
130133

134+
export const createP5Docs = async (inDirName: string, outDirName: string) => {
135+
execSync('npm install', {
136+
cwd: path.join(__dirname, 'in', inDirName),
137+
})
138+
execSync('npm run docs', {
139+
cwd: path.join(__dirname, 'in', inDirName),
140+
})
141+
const outputFilePath = path.join(yuidocOutputPath, outDirName);
142+
await fs.mkdir(outputFilePath, { recursive: true })
143+
await fs.cp(
144+
path.join(__dirname, 'in', inDirName, 'docs', 'reference', 'data.json'),
145+
path.join(outputFilePath, 'data.json'),
146+
)
147+
}
148+
149+
export const createP5Build = async (inDirName: string) => {
150+
execSync('npm run build', {
151+
cwd: path.join(__dirname, 'in', inDirName)
152+
})
153+
await fs.cp(
154+
path.join(__dirname, 'in', inDirName, 'lib', 'p5.min.js'),
155+
path.join(__dirname, '../../../public', 'p5.min.js'),
156+
)
157+
}
158+
131159
export async function combineYuidocData(
132160
inputData: ParsedLibraryReference[],
133161
outDirName: string

0 commit comments

Comments
 (0)