docs: generate docs for unversioned schema (#8535)

This commit is contained in:
Daniel Roe 2022-10-27 17:45:04 +02:00 committed by GitHub
parent 265db50515
commit 7302bf2f6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,7 +11,7 @@ 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
@ -19,16 +19,6 @@ function generateMarkdown (schema: Schema, title: string, level: string, parentV
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}`, '')
@ -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)
}