8000 document generator tag · ethereum-node/jsdoc.github.io@165a087 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 165a087

Browse files
committed
document generator tag
The example uses the currently nonexistent yields tag, which will be added in jsdoc/jsdoc#1388.
1 parent 48d0c0e commit 165a087

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed

content/en/tags-generator.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
tag: generator
3+
description: Indicate that a function is a generator function.
4+
---
5+
6+
## Syntax
7+
8+
`@generator`
9+
10+
11+
## Overview
12+
13+
The `@generator` tag indicates that a function is a [generator function][generator], meaning that it
14+
was declared using the syntax `function* foo() {}`. This tag is available in JSDoc 3.5.0 and later.
15+
16+
In general, you do not need to use this tag, because JSDoc automatically detects generator functions
17+
and identifies them in the generated documentation. However, if you are writing a virtual comment
18+
for a generator function that does not appear in your code, you can use this tag to tell JSDoc that
19+
the function is a generator function.
20+
21+
[generator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*
22+
23+
24+
## Example
25+
26+
The following example shows a virtual comment that uses the `@generator` tag:
27+
28+
{% example "Virtual comment with @generator tag" %}
29+
30+
```js
31+
/**
32+
* Generate numbers in the Fibonacci sequence.
33+
*
34+
* @generator
35+
* @function fibonacci
36+
* @yields {number} The next number in the Fibonacci sequence.
37+
*/
38+
```
39+
40+
{% endexample %}

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ <h2 id="block-tags">Block Tags</h2>
110110
<dd>Describe the events this method may fire.</dd>
111111
<dt><a href="tags-function.html">@function</a> (synonyms: @func, @method)</dt>
112112
<dd>Describe a function or method.</dd>
113+
<dt><a href="tags-generator.html">@generator</a></dt>
114+
<dd>Indicate that a function is a generator function.</dd>
113115
<dt><a href="tags-global.html">@global</a></dt>
114116
<dd>Document a global object.</dd>
115117
<dt><a href="tags-ignore.html">@ignore</a></dt>

tags-generator.html

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<!DOCTYPE html>
2+
<!-- THIS IS A GENERATED FILE. DO NOT EDIT. -->
3+
<html lang="en">
4+
5+
<head>
6+
<meta charset="utf-8">
7+
<meta name="description" content="Indicate that a function is a generator function.">
8+
<title>Use JSDoc: @generator</title>
9+
<link rel="stylesheet" href="styles/usejsdoc.css">
10+
<link rel="stylesheet" href="styles/prettify.css">
11+
<link rel="stylesheet" href="styles/css3-github-ribbon.css">
12+
<script src="scripts/prettify.js"></script>
13+
<!--[if lt IE 9]>
14+
<script src="scripts/html5shiv.min.js"></script>
15+
<script src="scripts/html5shiv-printshiv.min.js"></script>
16+
<![endif]-->
17+
</head>
18+
19+
<body>
20+
<header>
21+
<a href="./index.html">@use JSDoc</a>
22+
</header>
23+
<article>
24+
<h1>@generator</h1>
25+
<h2>Table of Contents</h2>
26+
<ul>
27+
<li>
28+
<a href="#syntax">Syntax</a>
29+
</li>
30+
<li>
31+
<a href="#overview">Overview</a>
32+
</li>
33+
<li>
34+
<a href="#example">Example</a>
35+
</li>
36+
</ul>
37+
<h2 id="syntax">Syntax</h2>
38+
<p><code>@generator</code>
39+
</p>
40+
<h2 id="overview">Overview</h2>
41+
<p>The <code>@generator</code> tag indicates that a function is a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*">generator function</a>,
42+
meaning that it was declared using the syntax <code>function* foo() {}</code>. This tag is available in JSDoc 3.5.0 and later.</p>
43+
<p>In general, you do not need to use this tag, because JSDoc automatically detects generator functions and identifies them in the generated documentation. However,
44+
if you are writing a virtual comment for a generator function that does not appear in your code, you can use this tag to tell JSDoc that the function is a
45+
generator function.</p>
46+
<h2 id="example">Example</h2>
47+
<p>The following example shows a virtual comment that uses the <code>@generator</code> tag:</p>
48+
<figure>
49+
<figcaption>Virtual comment with @generator tag</figcaption><pre class="prettyprint lang-js"><code>/**
50+
* Generate numbers in the Fibonacci sequence.
51+
*
52+
* @generator
53+
* @function fibonacci
54+
* @yields {number} The next number in the Fibonacci sequence.
55+
*/
56+
</code></pre>
57+
</figure>
58+
</article>
59+
<footer>
60+
<a class="license-badge" href="http://creativecommons.org/licenses/by-sa/3.0/">
61+
<img alt="Creative Commons License" class="license-badge" src="images/cc-by-sa.svg" width="80" height="15" />
62+
</a>
63+
<br> Copyright &#169; 2011-2017 the
64+
<a href="https://github.com/jsdoc3/jsdoc3.github.com/contributors">contributors</a> to the JSDoc 3 documentation project.
65+
<br> This website is <a href="https://github.com/jsdoc3/jsdoc3.github.com">open source</a> and is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">
66+
Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.
67+
</footer>
68+
<script type="text/javascript">
69+
prettyPrint();
70+
</script>
71+
</body>
72+
73+
</html>

0 commit comments

Comments
 (0)
0