Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: alpha beta experimental modifiers (#53)
* new: alpha, beta, and experimental modifiers This adds badges to entities that are marked with stabilitity modifiers. I'm open to suggestions on better ways of rendering this information. * move labels around
- Loading branch information
1 parent
922f406
commit f32fa95
Showing
6 changed files
with
112 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,50 @@ | ||
/** | ||
* a type | ||
* @beta | ||
*/ | ||
export type Type = 'standard'; | ||
|
||
/** | ||
* newy new guy | ||
* @param a a thing | ||
* @param b b thing | ||
* @alpha | ||
*/ | ||
export function bizz(a: string, b: string): string; | ||
|
||
/** | ||
* newy new guy | ||
* @param a a thing | ||
* @param b b thing | ||
* @param c c thing | ||
* @beta | ||
*/ | ||
export function bizz(a: string, b: string, c: string): string; | ||
|
||
/** | ||
* a thing for a thing | ||
* @param a id | ||
* @returns returns the param | ||
* @beta | ||
*/ | ||
export function bizz(...args: string[]): string { | ||
return args[0]; | ||
} | ||
|
||
/** | ||
* thing for a thing | ||
* @beta | ||
*/ | ||
export function bizz(a: string): string { | ||
return a; | ||
} | ||
export interface Foo { | ||
/** | ||
* very experimental | ||
* @alpha | ||
*/ | ||
foo: string; | ||
|
||
/** | ||
* very experimental | ||
* @experimental | ||
*/ | ||
a: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import { JSONOutput } from 'typedoc'; | ||
|
||
function getModifierClassName(tag: string) { | ||
switch (tag) { | ||
case '@beta': | ||
case '@experimental': | ||
return 'warning'; | ||
case '@alpha': | ||
return 'danger'; | ||
default: | ||
return 'info'; | ||
} | ||
} | ||
|
||
export type CommentWithModifiers = Pick<JSONOutput.Comment, 'blockTags' | 'summary'> & | ||
Required<Pick<JSONOutput.Comment, 'modifierTags'>>; | ||
|
||
export function isCommentWithModifiers( | ||
comment?: JSONOutput.Comment, | ||
): comment is CommentWithModifiers { | ||
return !!comment && !!comment.modifierTags && comment.modifierTags.length > 0; | ||
} | ||
|
||
interface CommentBadgesProps { | ||
comment: CommentWithModifiers; | ||
} | ||
|
||
export function CommentBadges({ comment }: CommentBadgesProps) { | ||
const { modifierTags } = comment; | ||
return ( | ||
<div className="badge-group"> | ||
{modifierTags.map((tag) => ( | ||
<span key={tag} className={`badge badge--${getModifierClassName(tag)}`}> | ||
{tag.slice(1)} | ||
</span> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters