Skip to content

Commit 9ae152c

Browse files
committed
document hideconstructor tag (#168)
1 parent a21f7a0 commit 9ae152c

File tree

3 files changed

+265
-0
lines changed

3 files changed

+265
-0
lines changed

content/en/tags-hideconstructor.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
tag: hideconstructor
3+
description: Indicate that the constructor should not be displayed.
4+
related:
5+
- tags-class.html
6+
---
7+
8+
## Syntax
9+
10+
`@hideconstructor`
11+
12+
13+
## Overview
14+
15+
The `@hideconstructor` tag tells JSDoc that the generated documentation should not display the
16+
constructor for a class. This tag is available in JSDoc 3.5.0 and later.
17+
18+
For pre-ES2015 classes, use this tag in combination with the [`@class` or `@constructor`
19+
tag][tags-class].
20+
21+
For ES2015 classes, use this tag in the JSDoc comment for your constructor. If your class does not
22+
have an explicit constructor, use this tag in the JSDoc comment for the class.
23+
24+
[tags-class]: tags-class.html
25+
26+
27+
## Examples
28+
29+
{% example "@hideconstructor tag with pre-ES2015 class" %}
30+
31+
```js
32+
/**
33+
* @classdesc Toaster singleton.
34+
* @class
35+
* @hideconstructor
36+
*/
37+
var Toaster = (function() {
38+
var instance = null;
39+
40+
function Toaster() {}
41+
42+
/**
43+
* Toast an item.
44+
*
45+
* @alias toast
46+
* @memberof Toaster
47+
* @instance
48+
* @param {BreadyThing} item - The item to toast.
49+
* @return {Toast} A toasted bready thing.
50+
*/
51+
Toaster.prototype.toast = function(item) {};
52+
53+
return {
54+
/**
55+
* Get the Toaster instance.
56+
*
57+
* @alias Toaster.getInstance
58+
* @returns {Toaster} The Toaster instance.
59+
*/
60+
getInstance: function() {
61+
if (instance === null) {
62+
instance = new Toaster();
63+
delete instance.constructor;
64+
}
65+
66+
return instance;
67+
}
68+
};
69+
})();
70+
```
71+
{% endexample %}
72+
73+
{% example "@hideconstructor tag with ES2015 class" %}
74+
75+
```js
76+
/**
77+
* Waffle iron singleton.
78+
*/
79+
class WaffleIron {
80+
#instance = null;
81+
82+
/**
83+
* Create the waffle iron.
84+
*
85+
* @hideconstructor
86+
*/
87+
constructor() {
88+
if (#instance) {
89+
return #instance;
90+
}
91+
92+
/**
93+
* Cook a waffle.
94+
*
95+
* @param {Batter} batter - The waffle batter.
96+
* @return {Waffle} The cooked waffle.
97+
*/
98+
this.cook = function(batter) {};
99+
100+
this.#instance = this;
101+
}
102+
103+
/**
104+
* Get the WaffleIron instance.
105+
*
106+
* @return {WaffleIron} The WaffleIron instance.
107+
*/
108+
getInstance() {
109+
return new WaffleIron();
110+
}
111+
}
112+
```
113+
{% endexample %}

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ <h2 id="block-tags">Block Tags</h2>
114114
<dd>Indicate that a function is a generator function.</dd>
115115
<dt><a href="tags-global.html">@global</a></dt>
116116
<dd>Document a global object.</dd>
117+
<dt><a href="tags-hideconstructor.html">@hideconstructor</a></dt>
118+
<dd>Indicate that the constructor should not be displayed.</dd>
117119
<dt><a href="tags-ignore.html">@ignore</a></dt>
118120
<dd>Omit a symbol from the documentation.</dd>
119121
<dt><a href="tags-implements.html">@implements</a></dt>

tags-hideconstructor.html

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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 the constructor should not be displayed.">
8+
<title>Use JSDoc: @hideconstructor</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>@hideconstructor</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="#examples">Examples</a>
35+
</li>
36+
<li>
37+
<a href="#related-links">Related Links</a>
38+
</li>
39+
</ul>
40+
<h2 id="syntax">Syntax</h2>
41+
<p><code>@hideconstructor</code>
42+
</p>
43+
<h2 id="overview">Overview</h2>
44+
<p>The <code>@hideconstructor</code> tag tells JSDoc that the generated documentation should not display the constructor for a class. This tag is available in JSDoc
45+
3.5.0 and later.</p>
46+
<p>For pre-ES2015 classes, use this tag in combination with the <a href="tags-class.html"><code>@class</code> or <code>@constructor</code>
47+
tag</a>.</p>
48+
<p>For ES2015 classes, use this tag in the JSDoc comment for your constructor. If your class does not have an explicit constructor, use this tag in the JSDoc comment
49+
for the class.</p>
50+
<h2 id="examples">Examples</h2>
51+
<figure>
52+
<figcaption>@hideconstructor tag with pre-ES2015 class</figcaption><pre class="prettyprint lang-js"><code>/**
53+
* @classdesc Toaster singleton.
54+
* @class
55+
* @hideconstructor
56+
*/
57+
var Toaster = (function() {
58+
var instance = null;
59+
60+
function Toaster() {}
61+
62+
/**
63+
* Toast an item.
64+
*
65+
* @alias toast
66+
* @memberof Toaster
67+
* @instance
68+
* @param {BreadyThing} item - The item to toast.
69+
* @return {Toast} A toasted bready thing.
70+
*/
71+
Toaster.prototype.toast = function(item) {};
72+
73+
return {
74+
/**
75+
* Get the Toaster instance.
76+
*
77+
* @alias Toaster.getInstance
78+
* @returns {Toaster} The Toaster instance.
79+
*/
80+
getInstance: function() {
81+
if (instance === null) {
82+
instance = new Toaster();
83+
delete instance.constructor;
84+
}
85+
86+
return instance;
87+
}
88+
};
89+
})();
90+
</code></pre>
91+
</figure>
92+
<figure>
93+
<figcaption>@hideconstructor tag with ES2015 class</figcaption><pre class="prettyprint lang-js"><code>/**
94+
* Waffle iron singleton.
95+
*/
96+
class WaffleIron {
97+
#instance = null;
98+
99+
/**
100+
* Create the waffle iron.
101+
*
102+
* @hideconstructor
103+
*/
104+
constructor() {
105+
if (#instance) {
106+
return #instance;
107+
}
108+
109+
/**
110+
* Cook a waffle.
111+
*
112+
* @param {Batter} batter - The waffle batter.
113+
* @return {Waffle} The cooked waffle.
114+
*/
115+
this.cook = function(batter) {};
116+
117+
this.#instance = this;
118+
}
119+
120+
/**
121+
* Get the WaffleIron instance.
122+
*
123+
* @return {WaffleIron} The WaffleIron instance.
124+
*/
125+
getInstance() {
126+
return new WaffleIron();
127+
}
128+
}
129+
</code></pre>
130+
</figure>
131+
<h2 id="related-links">Related Links</h2>
132+
<p>
133+
<a href="tags-class.html">@class</a>
134+
</p>
135+
</article>
136+
<footer>
137+
<a class="license-badge" href="http://creativecommons.org/licenses/by-sa/3.0/">
138+
<img alt="Creative Commons License" class="license-badge" src="images/cc-by-sa.svg" width="80" height="15" />
139+
</a>
140+
<br> Copyright &#169; 2011-2017 the
141+
<a href="https://github.com/jsdoc3/jsdoc3.github.com/contributors">contributors</a> to the JSDoc 3 documentation project.
142+
<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/">
143+
Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.
144+
</footer>
145+
<script type="text/javascript">
146+
prettyPrint();
147+
</script>
148+
</body>
149+
150+
</html>

0 commit comments

Comments
 (0)