Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

docs: generate docs for unversioned schema #8535

Merged
merged 1 commit into from Oct 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 2 additions & 12 deletions docs/scripts/gen-docs.ts
Expand Up @@ -11,24 +11,14 @@ export async function main () {
await generateDocs({ configFile, configTemplate })
}

function generateMarkdown (schema: Schema, title: string, level: string, parentVersions: string[] = []) {
function generateMarkdown (schema: Schema, title: string, level: string) {
const lines: string[] = []

// Skip private
if (schema.tags?.includes('@private')) {
return []
}

// Versions
const versions = (schema.tags || []).map(t => t.match(/@version (\d+)/)?.[1]).filter(Boolean)
if (!versions.length) {
// Inherit from parent if not specified
versions.push(...parentVersions)
}
if (!versions.includes('3')) {
return []
}

// Render heading
lines.push(`${level} ${title}`, '')

Expand Down Expand Up @@ -72,7 +62,7 @@ function generateMarkdown (schema: Schema, title: string, level: string, parentV
const keys = Object.keys(schema.properties || {}).sort()
for (const key of keys) {
const val = schema.properties[key] as Schema
const propLines = generateMarkdown(val, `\`${key}\``, level + '#', versions)
const propLines = generateMarkdown(val, `\`${key}\``, level + '#')
if (propLines.length) {
lines.push('', ...propLines)
}
Expand Down