diff --git a/src/components/Comment.tsx b/src/components/Comment.tsx index 8c817f4..10736bd 100644 --- a/src/components/Comment.tsx +++ b/src/components/Comment.tsx @@ -32,6 +32,18 @@ export function displayPartsToMarkdown(parts: JSONOutput.CommentDisplayPart[]): .join(''); } +const ADDED_IN_TAG = '@added_in'; + +function getAddedInVersion(comment: JSONOutput.Comment): string | null { + const tag = comment.blockTags?.find((blockTag) => blockTag.tag === ADDED_IN_TAG); + + if (!tag) { + return null; + } + + return displayPartsToMarkdown(tag.content).trim() || null; +} + export function Comment({ comment, root, hideTags = [] }: CommentProps) { if (!comment || !hasComment(comment)) { return null; @@ -40,17 +52,23 @@ export function Comment({ comment, root, hideTags = [] }: CommentProps) { // Hide custom tags. hideTags.push('@reference'); + const addedIn = getAddedInVersion(comment); + const blockTags = comment.blockTags?.filter((tag) => { if (hideTags.includes(tag.tag)) { return false; } - return tag.tag !== '@default'; + return tag.tag !== '@default' && tag.tag !== ADDED_IN_TAG; }) ?? []; return (
+ {addedIn && ( + Added in: {addedIn} + )} + {!!comment.summary && (
diff --git a/src/components/styles.css b/src/components/styles.css index d984783..9c6ac63 100644 --- a/src/components/styles.css +++ b/src/components/styles.css @@ -196,6 +196,11 @@ html[data-theme='light'] .tsd-panel-content { margin-bottom: var(--tsd-spacing-vertical-full); } +.tsd-added-in { + display: inline-block; + margin-bottom: var(--tsd-spacing-vertical); +} + /* SOURCES */ .tsd-sources, diff --git a/src/plugin/data.ts b/src/plugin/data.ts index 1b0e182..17d8659 100644 --- a/src/plugin/data.ts +++ b/src/plugin/data.ts @@ -120,6 +120,8 @@ export async function generateJson( '@apilink', '@doclink', ] as `@${string}`[], + // Recognize the @added_in tag (rendered as a pill) on top of the defaults. + blockTags: [...TypeDoc.OptionDefaults.blockTags, '@added_in'] as `@${string}`[], ...options.typedocOptions, // Control how config and packages are detected tsconfig,