docs-util: support @tags comments (#10627)

* support tags in tsdocs + add them in frontmatter

* fixes
This commit is contained in:
Shahed Nasser
2024-12-17 13:07:59 +02:00
committed by GitHub
parent 6367bccde8
commit 2a73d0ac0d
6 changed files with 64 additions and 18 deletions
+1
View File
@@ -6,4 +6,5 @@ export * from "./hooks-util"
export * from "./step-utils"
export * from "./str-formatting"
export * from "./str-utils"
export * from "./tag-utils"
export * from "./workflow-utils"
+25
View File
@@ -0,0 +1,25 @@
import { CommentTag, DeclarationReflection, Reflection } from "typedoc"
export const getTagsAsArray = (tag: CommentTag): string[] => {
return tag.content
.map((content) => content.text)
.join("")
.split(",")
.map((value) => value.trim())
}
export const getTagComments = (reflection: Reflection): CommentTag[] => {
const tagComments: CommentTag[] = []
reflection.comment?.blockTags
.filter((tag) => tag.tag === `@tags`)
.forEach((tag) => tagComments.push(tag))
if (reflection instanceof DeclarationReflection) {
reflection.signatures?.forEach((signature) =>
tagComments.push(...getTagComments(signature))
)
}
return tagComments
}