-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jsii): reflect stabilities in doc comment summaries (#1951)
In order to make the stability of certain API elements more clear, note any non-standard API stabilities in the APIs summary docstring. This makes it clearly visible in the IDEs autocomplete. IMPLEMENTATION NOTES We put the onus of rendering of the `(experimental)/(deprecated)` prefixes on the code generators for every language. We played with the idea of sticking it directly into the manifest but then the API reference would also have had it, and the API reference already has color coding and graphical symbols to indicate these statuses. To modify the `.js/.d.ts` generation: * Reversed the order of `program.emit()` and `assembler.emit()`. `assembler.emit()` now comes first, so that we know the correct stability before we start emitting code. * For every node we encounter, we regenerate the doc comment block to include stability in the summary line if appropriate. We remember the desired doc comment block for later. * The annotation is being done by TypeScript transforms. The original comments are stripped out of the SourceFile (in-memory) and replaced with synthetic comments containing the generated doc comments.
- Loading branch information
Showing
18 changed files
with
815 additions
and
283 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as spec from '@jsii/spec'; | ||
|
||
export function stabilityPrefixFor(element: spec.Documentable): string { | ||
if (element.docs?.stability === spec.Stability.Experimental) { | ||
return '(experimental) '; | ||
} | ||
if (element.docs?.stability === spec.Stability.Deprecated) { | ||
return '(deprecated) '; | ||
} | ||
return ''; | ||
} | ||
|
||
export function renderSummary(docs?: spec.Docs): string { | ||
return docs?.summary ? stabilityPrefixFor({ docs }) + docs.summary : ''; | ||
} |
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
Oops, something went wrong.