🎥 Make videos programmatically with React
still works
Jonny Burger7fbc5e8d4f81
diff --git a/packages/ai-improvements/improve-docs.ts b/packages/ai-improvements/improve-docs.tsindex 36b5e2336a..8228a58641 100644--- a/packages/ai-improvements/improve-docs.ts+++ b/packages/ai-improvements/improve-docs.ts@@ -1,75 +1,63 @@import path from "path";import { articles } from "../docs/src/data/articles";import { OpenAI } from "openai";+import { getApis } from "./map-over-api";const openai = new OpenAI({apiKey: process.env.OPEN_AI_API_KEY,});-for (const article of articles) {- const filePath = path.join(- path.join(process.cwd(), "..", "docs", article.relativePath)- );- const contents = await Bun.file(filePath).text();- const containsSourceCode = contents- .toLowerCase()- .includes("source code for ");+const apis = await getApis();- if (containsSourceCode) {- const match = contents.match(/\[.*source code for.*\]\((.*)\)/i);- if (!match) {- console.error(`Could not find source code for article ${article.title}`);- continue;- }- const url = match[1];- const p = url.replace(- "https://github.com/remotion-dev/remotion/blob/main/",- ""- );- const flag = path.join(".done", article.id);+for (const api of apis) {+ const contents = await Bun.file(api.filePath).text();+ if (!api.sourceCodePath) {+ continue;+ }++ const flag = path.join(".done", api.id);- if (await Bun.file(flag).exists()) {- console.log(`Article ${article.title} already processed`);- continue;- }+ if (await Bun.file(flag).exists()) {+ console.log(`Article ${api.title} already processed`);+ continue;+ }- const file = path.join(process.cwd(), "..", "..", p);- console.log(file);- const sourceContents = await Bun.file(file).text();- console.log(`Article ${article.title} contains source code`);+ const file = path.join(process.cwd(), "..", "..", api.sourceCodePath);+ console.log(file);+ const sourceContents = await Bun.file(file).text();+ console.log(`Article ${api.title} contains source code`);- const stream = await openai.chat.completions.create({- model: "gpt-4-turbo",- messages: [- {- role: "system",- content: [- "You are going to be given an API and an API documentation.",- "respond if you think the API documentation is missing parameters the user can pass or the return value is not right.",- "Also point out typos.",- "Do only point out obvious mistakes.",- "Sometimes props are documented like ### `delayRenderRetries`<AvailableFrom v='4.0.140' />, which is fine",- "Consider that the documentation may contain backticks and html tags, which are not mistakes.",- "Point out if the markdown is not formatted correctly.",- "Rewrite paragraphs and sentences that we need to correct.",- "Otherwise, just say OK.",- ].join("\n"),- },- {- role: "user",- content: "This is the source code for the API:\n" + sourceContents,- },- {- role: "user",- content: "This is the markdown of the documentation:\n" + contents,- },- ],- stream: true,- });- for await (const chunk of stream) {- process.stdout.write(chunk.choices[0]?.delta?.content || "");- }- await Bun.write(flag, "txt");- process.exit(0);+ const stream = await openai.chat.completions.create({+ model: "gpt-4-turbo",+ messages: [+ {+ role: "system",+ content: [+ "You are going to be given an API and an API documentation.",+ "respond if you think the API documentation is missing parameters the user can pass or the return value is not right.",+ "Also point out typos.",+ "Do only point out obvious mistakes.",+ "Sometimes props are documented like ### `delayRenderRetries`<AvailableFrom v='4.0.140' />, which is fine",+ "Consider that the documentation may contain backticks and html tags, which are not mistakes.",+ "Point out if the markdown is not formatted correctly.",+ "Rewrite paragraphs and sentences that we need to correct.",+ "Otherwise, just say OK.",+ ].join("\n"),+ },+ {+ role: "user",+ content: "This is the source code for the API:\n" + sourceContents,+ },+ {+ role: "user",+ content: "This is the markdown of the documentation:\n" + contents,+ },+ ],+ stream: true,+ });+ for await (const chunk of stream) {+ process.stdout.write(chunk.choices[0]?.delta?.content || "");}+ await Bun.write(flag, "txt");+ process.exit(0);}diff --git a/packages/ai-improvements/map-over-api.ts b/packages/ai-improvements/map-over-api.tsnew file mode 100644index 0000000000..b3ef2784bc--- /dev/null+++ b/packages/ai-improvements/map-over-api.ts@@ -0,0 +1,51 @@+import path from "path";+import { articles } from "../docs/src/data/articles";++const getSourceCodeLink = async (filePath: string) => {+ const contents = await Bun.file(filePath).text();+ const containsSourceCode = contents+ .toLowerCase()+ .includes("source code for ");++ if (!containsSourceCode) {+ return null;+ }++ const match = contents.match(/\[.*source code for.*\]\((.*)\)/i);+ if (!match) {+ return null;+ }+ const url = match[1];+ const p = url.replace(+ "https://github.com/remotion-dev/remotion/blob/main/",+ ""+ );++ return p;+};++type Api = {+ filePath: string;+ sourceCodePath: string | null;+ id: string;+ title: string;+};++const arr: Api[] = [];++export const getApis = async () => {+ for (const article of articles) {+ const filePath = path.join(+ path.join(process.cwd(), "..", "docs", article.relativePath)+ );+ const sourceCodeLink = await getSourceCodeLink(filePath);+ arr.push({+ filePath,+ sourceCodePath: sourceCodeLink,+ id: article.id,+ title: article.title,+ });+ }++ return arr;+};diff --git a/packages/docs/docs/renderer/get-compositions.mdx b/packages/docs/docs/renderer/get-compositions.mdxindex 5189ec70fb..61a0a658b2 100644--- a/packages/docs/docs/renderer/get-compositions.mdx+++ b/packages/docs/docs/renderer/get-compositions.mdx@@ -15,14 +15,14 @@ For every compositions their [`calculateMetadata()`](/docs/composition#calculate```tsconst getCompositions: (- bundleOrServeUrl: string,+ serveUrlOrWebpackUrl: string,options?: GetCompositionsConfig,) => Promise<TComposition[]>;```## Arguments-### `bundleOrServeUrl`+### `serveUrlOrWebpackUrl`A string pointing to a [Remotion Bundle](/docs/terminology/bundle) generated by [`bundle()`](/docs/bundle) or a URL that hosts the the bundled Remotion project.