docs: sort events in reference alphabetically (#12845)

This commit is contained in:
Shahed Nasser
2025-06-27 11:56:36 +03:00
committed by GitHub
parent f614d86332
commit fcfd35a157
7 changed files with 2084 additions and 2081 deletions

View File

@@ -1,7 +1,6 @@
import Handlebars from "handlebars"
import pkg from "slugify"
import { DeclarationReflection, ReflectionKind } from "typedoc"
import { pascalToWords } from "utils"
const slugify = pkg.default
@@ -35,16 +34,12 @@ export default function () {
}
if (this.kind === ReflectionKind.Module) {
this.children?.forEach((child, index) => {
const count = parseChildren(child.children || [])
if (count > 0 && index < this.children!.length - 1) {
content.push("")
content.push("---")
content.push("")
}
})
const sortedChildren = sortChildren(
this.children?.map((child) => child.children || []).flat() || []
)
parseChildren(sortedChildren)
} else {
parseChildren(this.children || [])
parseChildren(sortChildren(this.children || []))
}
return content.join("\n")
@@ -67,9 +62,11 @@ function formatEventsType(
}
const content: string[] = []
const subHeaderPrefix = "#".repeat(subtitleLevel)
const header = pascalToWords(
eventVariable.name.replaceAll("WorkflowEvents", "")
)
const header =
eventVariable.comment?.blockTags
.find((tag) => tag.tag === "@category")
?.content.map((content) => content.text)
.join("") || ""
if (showHeader) {
content.push(`${"#".repeat(subtitleLevel - 1)} ${header} Events`)
}
@@ -268,3 +265,9 @@ function getEventWorkflows(event: DeclarationReflection): string[] | undefined {
.join("")
.split(", ")
}
function sortChildren(ref: DeclarationReflection[]) {
return ref.sort((a, b) => {
return a.name.localeCompare(b.name)
})
}