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

Commit

Permalink
docs: generate docs for unversioned schema
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Oct 27, 2022
1 parent 265db50 commit b20e30f
Showing 1 changed file with 2 additions and 12 deletions.
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

0 comments on commit b20e30f

Please sign in to comment.