Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: Only build reference docs if feature is enabled (#47273)

Chris Chinchillabce47daeea58
diff --git a/apps/docs/internals/generate-reference-markdown.ts b/apps/docs/internals/generate-reference-markdown.ts
index 7c751d07cf3..b5470a73325 100644
--- a/apps/docs/internals/generate-reference-markdown.ts
+++ b/apps/docs/internals/generate-reference-markdown.ts
@@ -1,5 +1,6 @@
import fs from 'node:fs/promises'
import path from 'node:path'
+import { isFeatureEnabled, type Feature } from 'common/enabled-features'
import matter from 'gray-matter'
import yaml from 'js-yaml'
import { fromMarkdown } from 'mdast-util-from-markdown'
@@ -41,6 +42,11 @@ type RefBase = {
outFile: string
/** Folder under docs/ref/ that holds .mdx sections for `type: "markdown"` entries. */
mdxDir: string
+ /**
+ * Enabled-features flag gating this reference. When set and the feature is
+ * disabled in enabled-features.json, the file is not generated.
+ */
+ feature?: Feature
}
type SdkLegacyRef = RefBase & {
@@ -99,6 +105,7 @@ const REFERENCES: Ref[] = [
mdxDir: path.join(MDX_ROOT, 'dart'),
sectionsPath: path.join(GENERATED, 'dart.v2.sections.json'),
functionsPath: path.join(GENERATED, 'dart.v2.functions.json'),
+ feature: 'sdk:dart',
},
{
kind: 'sdk-legacy',
@@ -107,6 +114,7 @@ const REFERENCES: Ref[] = [
mdxDir: path.join(MDX_ROOT, 'kotlin'),
sectionsPath: path.join(GENERATED, 'kotlin.v1.sections.json'),
functionsPath: path.join(GENERATED, 'kotlin.v1.functions.json'),
+ feature: 'sdk:kotlin',
},
{
kind: 'sdk-legacy',
@@ -115,6 +123,7 @@ const REFERENCES: Ref[] = [
mdxDir: path.join(MDX_ROOT, 'python'),
sectionsPath: path.join(GENERATED, 'python.v2.sections.json'),
functionsPath: path.join(GENERATED, 'python.v2.functions.json'),
+ feature: 'sdk:python',
},
{
kind: 'sdk-legacy',
@@ -123,6 +132,7 @@ const REFERENCES: Ref[] = [
mdxDir: path.join(MDX_ROOT, 'swift'),
sectionsPath: path.join(GENERATED, 'swift.v2.sections.json'),
functionsPath: path.join(GENERATED, 'swift.v2.functions.json'),
+ feature: 'sdk:swift',
},
{
kind: 'sdk-legacy',
@@ -131,6 +141,7 @@ const REFERENCES: Ref[] = [
mdxDir: path.join(MDX_ROOT, 'csharp'),
sectionsPath: path.join(GENERATED, 'csharp.v0.sections.json'),
functionsPath: path.join(GENERATED, 'csharp.v0.functions.json'),
+ feature: 'sdk:csharp',
},
]
@@ -393,8 +404,10 @@ async function generate() {
path.join(process.cwd(), 'content/reference/javascript/v2/typeSpec.json')
)
+ const references = REFERENCES.filter((ref) => !ref.feature || isFeatureEnabled(ref.feature))
+
await Promise.all(
- REFERENCES.map(async (ref) => {
+ references.map(async (ref) => {
let output: string
switch (ref.kind) {
case 'sdk-legacy':
@@ -424,7 +437,7 @@ async function generate() {
})
)
- console.log(`Generated ${REFERENCES.length} markdown files under public/markdown/reference/`)
+ console.log(`Generated ${references.length} markdown files under public/markdown/reference/`)
}
generate()