Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/components/Comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 (
<div className={`tsd-comment tsd-typography ${root ? 'tsd-comment-root' : ''}`}>
{addedIn && (
<span className="badge badge--secondary tsd-added-in">Added in: {addedIn}</span>
)}

{!!comment.summary && (
<div className="lead">
<Markdown content={displayPartsToMarkdown(comment.summary)} />
Expand Down
5 changes: 5 additions & 0 deletions src/components/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/plugin/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading