Skip to content

Commit

Permalink
feat(api-documenter): Support annotation of alpha APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Josmithr committed Sep 19, 2023
1 parent aa81d5d commit 71d2f0c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
25 changes: 21 additions & 4 deletions apps/api-documenter/src/documenters/MarkdownDocumenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ export class MarkdownDocumenter {
}

if (ApiReleaseTagMixin.isBaseClassOf(apiItem)) {
if (apiItem.releaseTag === ReleaseTag.Beta) {
if (apiItem.releaseTag === ReleaseTag.Alpha) {
this._writeAlphaWarning(output);
} else if (apiItem.releaseTag === ReleaseTag.Beta) {
this._writeBetaWarning(output);
}
}
Expand Down Expand Up @@ -1000,10 +1002,13 @@ export class MarkdownDocumenter {
const section: DocSection = new DocSection({ configuration });

if (ApiReleaseTagMixin.isBaseClassOf(apiItem)) {
if (apiItem.releaseTag === ReleaseTag.Beta) {
if (apiItem.releaseTag === ReleaseTag.Alpha || apiItem.releaseTag === ReleaseTag.Beta) {
section.appendNodesInParagraph([
new DocEmphasisSpan({ configuration, bold: true, italic: true }, [
new DocPlainText({ configuration, text: '(BETA)' })
new DocPlainText({
configuration,
text: `(${apiItem.releaseTag === ReleaseTag.Alpha ? 'ALPHA' : 'BETA'})`
})
]),
new DocPlainText({ configuration, text: ' ' })
]);
Expand Down Expand Up @@ -1152,10 +1157,22 @@ export class MarkdownDocumenter {
}
}

private _writeAlphaWarning(output: DocSection): void {
const configuration: TSDocConfiguration = this._tsdocConfiguration;
const betaWarning: string =
'This API is provided as an alpha preview for developers and may change' +
' based on feedback that we receive. Do not use this API in a production environment.';
output.appendNode(
new DocNoteBox({ configuration }, [
new DocParagraph({ configuration }, [new DocPlainText({ configuration, text: betaWarning })])
])
);
}

private _writeBetaWarning(output: DocSection): void {
const configuration: TSDocConfiguration = this._tsdocConfiguration;
const betaWarning: string =
'This API is provided as a preview for developers and may change' +
'This API is provided as a beta preview for developers and may change' +
' based on feedback that we receive. Do not use this API in a production environment.';
output.appendNode(
new DocNoteBox({ configuration }, [
Expand Down
2 changes: 1 addition & 1 deletion apps/api-documenter/src/documenters/YamlDocumenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ export class YamlDocumenter {
}

if (ApiReleaseTagMixin.isBaseClassOf(apiItem)) {
if (apiItem.releaseTag === ReleaseTag.Beta) {
if (apiItem.releaseTag === ReleaseTag.Alpha || apiItem.releaseTag === ReleaseTag.Beta) {
yamlItem.isPreview = true;
}
}
Expand Down

0 comments on commit 71d2f0c

Please sign in to comment.