RFC: Syntax for @example tag
See original GitHub issueRFC: Core set of tags for TSDoc brought up the question of the @example
tag that could be used to identify examples. I’m forking it into a separate issue since @c69 pointed out that the design is unclear.
Can anyone find samples of its usage in existing documentation systems?
Since TSDoc will support Markdown, how would it interact with that? Maybe something like this?
/**
* Adds two numbers together.
* @example
* Here's a simple example:
* ```
* // Prints "2":
* console.log(add(1,1));
* ```
* @example
* Here's an example with negative numbers:
* ```
* // Prints "0":
* console.log(add(1,-1));
* ```
*/
export function add(x: number, y: number): number {
}
How would an API reference web site leverage these directives?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:11
- Comments:14 (1 by maintainers)
Top Results From Across the Web
RFC 4151:The 'tag' URI Scheme - IETF
This section first specifies the syntax of tag URIs and gives examples. It then describes a set of rules for minting tags that...
Read more >Language tags in HTML and XML - W3C
Language tag syntax is defined by the IETF 's BCP 47. BCP stands for 'Best Current Practice', and is a persistent name for...
Read more >IETF language tag - Wikipedia
History · Syntax of language tags · List of common primary language subtags · Relation to other standards · Extensions · See also...
Read more >Tag URI
Compatibility with RFC 2822 email addresses: there was discussion on uri@w3.org about how to upgrade the tag scheme's syntax for better compatibility with ......
Read more >doc: RFC 5646: Tags for Identifying Languages - hjp
For example, the user's language preferences in a Web browser can be used to select Web pages appropriately. ... The language tag syntax...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s a good suggestion. Currently API Documenter simply generates names like
Example 1
,Example 2
, etc. Not as informative as it could be.There’s already some precedent, where the
@throws
tag has a convention that the exception name can be specified using text on the same line as the tag.So maybe a similar convention could be used for
@example
as in your sample. (BTW markdown headers should probably start with#
, to avoid making assumptions about the documenter’s heading structure.)So it could be like this:
…and might get rendered like this:
@pgonzal I can have for Angular documentation tool https://github.com/compodoc/compodoc this kind of @example usage which use TypeScript decorator.