From 9b388d9168671507fb4bbc1cd55caec1f1ccfd7c Mon Sep 17 00:00:00 2001 From: Konstantin Wohlwend Date: Fri, 20 Jun 2025 15:50:57 -0700 Subject: [PATCH] Remove remnants of Fern docs --- apps/backend/scripts/generate-openapi.ts | 11 +-- scripts/generate-docs.ts | 101 ----------------------- 2 files changed, 1 insertion(+), 111 deletions(-) delete mode 100644 scripts/generate-docs.ts diff --git a/apps/backend/scripts/generate-openapi.ts b/apps/backend/scripts/generate-openapi.ts index 7c87ec16e..d4f56eb76 100644 --- a/apps/backend/scripts/generate-openapi.ts +++ b/apps/backend/scripts/generate-openapi.ts @@ -1,12 +1,10 @@ -import { parseOpenAPI, parseWebhookOpenAPI } from '@/lib/openapi'; +import { parseOpenAPI } from '@/lib/openapi'; import { isSmartRouteHandler } from '@/route-handlers/smart-route-handler'; -import { webhookEvents } from '@stackframe/stack-shared/dist/interface/webhooks'; import { writeFileSyncIfChanged } from '@stackframe/stack-shared/dist/utils/fs'; import { HTTP_METHODS } from '@stackframe/stack-shared/dist/utils/http'; import { typedKeys } from '@stackframe/stack-shared/dist/utils/objects'; import { glob } from 'glob'; import path from 'path'; -import yaml from 'yaml'; async function main() { console.log("Started docs schema generator"); @@ -34,14 +32,7 @@ async function main() { }))), audience, }); - const openAPISchema = yaml.stringify(openApiSchemaObject); writeFileSyncIfChanged(`../mcp-server/openapi/${audience}.json`, JSON.stringify(openApiSchemaObject, null, 2)); - writeFileSyncIfChanged(`../../docs/fern/openapi/${audience}.yaml`, openAPISchema); - - const webhookOpenAPISchema = yaml.stringify(parseWebhookOpenAPI({ - webhooks: webhookEvents, - })); - writeFileSyncIfChanged(`../../docs/fern/openapi/webhooks.yaml`, webhookOpenAPISchema); } console.log("Successfully updated docs schemas"); } diff --git a/scripts/generate-docs.ts b/scripts/generate-docs.ts deleted file mode 100644 index 25a2c7206..000000000 --- a/scripts/generate-docs.ts +++ /dev/null @@ -1,101 +0,0 @@ -import fs from "fs"; -import path from "path"; -import yaml from "yaml"; -import { PLATFORMS, copyFromSrcToDest, processMacros, withGeneratorLock, writeFileSyncIfChanged } from "./utils"; - -interface DocObject { - platform?: string; - [key: string]: any; -} - -function processDocObject(obj: any, platforms: string[]): { result: any, validPaths: string[] } { - // If not an object, return as is - if (typeof obj !== 'object' || obj === null) { - return { result: obj, validPaths: [] }; - } - - // Handle arrays - if (Array.isArray(obj)) { - const processed = obj - .map(item => processDocObject(item, platforms)) - .filter(item => item.result !== null); - return { - result: processed.map(p => p.result), - validPaths: processed.flatMap(p => p.validPaths) - }; - } - - // Handle objects - const docObj = obj as DocObject; - - // If object has platform and it doesn't match current platform, exclude it - if (docObj.platform) { - if (!platforms.includes(docObj.platform)) { - return { result: null, validPaths: [] }; - } - // Remove the platform field from the output - const { platform: _, ...rest } = docObj; - obj = rest; - } - - const validPaths: string[] = []; - - // Recursively process all properties - const result: { [key: string]: any } = {}; - for (const [key, value] of Object.entries(obj)) { - const { result: processed, validPaths: processedValidPaths } = processDocObject(value, platforms); - processedValidPaths.forEach(path => validPaths.push(path)); - - if (processed !== null) { - if (typeof processed === 'string') { - if (key === 'path') { - validPaths.push(processed.split('/').slice(3).join('/')); - } - - result[key] = processed.replace(/{platform}/g, platforms[0]); - } else { - result[key] = processed; - } - } - } - - return { - result, - validPaths - } -} - -withGeneratorLock(async () => { - const docsDir = path.resolve(__dirname, "..", "docs", "fern"); - const templateDir = path.join(docsDir, "docs", "pages-template"); - const ymlTemplatePath = path.join(docsDir, "docs-template.yml"); - - for (const platform of ["next", "js", "react", "python"]) { - const destDir = path.join(docsDir, 'docs', `pages-${platform}`); - - const mainYmlContent = fs.readFileSync(ymlTemplatePath, "utf-8"); - const macroProcessed = processMacros(mainYmlContent, PLATFORMS[platform]); - const template = yaml.parse(macroProcessed); - const { result: processed, validPaths: processedValidPaths } = processDocObject(template, PLATFORMS[platform]); - const output = yaml.stringify(processed); - writeFileSyncIfChanged(path.join(docsDir, `${platform}.yml`), output); - - // Copy the entire template directory, processing macros for each file - copyFromSrcToDest({ - srcDir: templateDir, - destDir, - editFn: (relativePath, content) => { - return processMacros(content, PLATFORMS[platform]); - }, - filterFn: (relativePath) => { - if (relativePath.endsWith('.mdx') && !relativePath.startsWith('snippets')) { - return processedValidPaths.includes(relativePath); - } - return true; - } - }); - } -}).catch((error) => { - console.error(error); - process.exit(1); -});