Skip to content

Commit 037d118

Browse files
committed
document config setting for tag dictionaries (#61)
1 parent 967b4b0 commit 037d118

File tree

2 files changed

+64
-20
lines changed

2 files changed

+64
-20
lines changed

Diff for: about-configuring-jsdoc.html

+27-12
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ <h2>Table of Contents</h2>
3838
</li>
3939
<li>
4040
<a href="#output-style-configuration">Output style configuration</a>
41-
<ul>
42-
<li>
43-
<a href="#miscellaneous">Miscellaneous</a>
44-
</li>
45-
</ul>
41+
</li>
42+
<li>
43+
<a href="#tags-and-tag-dictionaries">Tags and tag dictionaries</a>
4644
</li>
4745
<li>
4846
<a href="#related-links">Related Links</a>
@@ -54,7 +52,8 @@ <h2 id="configuration-file">Configuration File</h2>
5452
example. If you do not specify a configuration file, this is what JSDoc will use:</p>
5553
<figure><pre class="prettyprint lang-js"><code>{
5654
"tags": {
57-
"allowUnknownTags": true
55+
"allowUnknownTags": true,
56+
"dictionaries": ["jsdoc","closure"]
5857
},
5958
"source": {
6059
"includePattern": ".+\\.js(doc)?$",
@@ -70,6 +69,9 @@ <h2 id="configuration-file">Configuration File</h2>
7069
</figure>
7170
<p>This means:</p>
7271
<ul>
72+
<li>JSDoc allows you to use unrecognized tags (<code>tags.allowUnknownTags</code>);</li>
73+
<li>Both standard JSDoc tags and <a href="https://developers.google.com/closure/compiler/docs/js-for-compiler#tags">Closure Compiler tags</a> are enabled (
74+
<code>tags.dictionaries</code>);</li>
7375
<li>Only files ending in &quot;.js&quot; and &quot;.jsdoc&quot; will be processed (<code>source.includePattern</code>);</li>
7476
<li>Any file starting with an underscore or in a directory starting with an underscore will be
7577
<em>ignored</em> (<code>source.excludePattern</code>);</li>
@@ -207,15 +209,28 @@ <h2 id="output-style-configuration">Output style configuration</h2>
207209
<code>{@link MyNamespace.myFunction}</code> will be in monospace.</p>
208210
<p>If <code>templates.cleverLinks</code> is true, it is used and <code>templates.monospaceLinks</code> is ignored.</p>
209211
<p>Also, there are {@linkcode ...} and {@linkplain ...} if one wishes to force the link to be rendered in monospace or normal font respectively (see <a href="tags-inline-link.html">@link, @linkcode and @linkplain</a> for further information).</p>
210-
<h3 id="miscellaneous">Miscellaneous</h3>
211-
<p>The <code>tags.allowUnknownTags</code> property determines whether tags unrecognised by JSDoc are permitted. If this is false and JSDoc encounters a tag it does
212-
not recognise (e.g. <code>@foobar</code>), it will throw an error. Otherwise, it will just ignore the tag.</p>
213-
<p>By default, it is true.</p>
214-
<figure><pre class="prettyprint"><code>"tags": {
215-
"allowUnknownTags": true
212+
<h2 id="tags-and-tag-dictionaries">Tags and tag dictionaries</h2>
213+
<p>The options in <code>tags</code> control which JSDoc tags are allowed and how each tag is interpreted.</p>
214+
<figure><pre class="prettyprint lang-js"><code>"tags": {
215+
"allowUnknownTags": true,
216+
"dictionaries": ["jsdoc","closure"]
216217
}
217218
</code></pre>
218219
</figure>
220+
<p>The <code>tags.allowUnknownTags</code> property affects how JSDoc handles unrecognized tags. If you set this option to <code>false</code>, and JSDoc finds a
221+
tag that it does not recognize (for example, <code>@foo</code>), JSDoc logs a warning. By default, this option is set to <code>true</code>.</p>
222+
<p>The <code>tags.dictionaries</code> property controls which tags JSDoc recognizes, as well as how JSDoc interprets the tags that it recognizes. In JSDoc 3.3.0
223+
and later, there are two built-in tag dictionaries:
224+
</p>
225+
<ul>
226+
<li><code>jsdoc</code>: Core JSDoc tags.</li>
227+
<li><code>closure</code>: <a href="https://developers.google.com/closure/compiler/docs/js-for-compiler#tags">Closure Compiler tags</a>.</li>
228+
</ul>
229+
<p>By default, both dictionaries are enabled. Also, by default, the <code>jsdoc</code> dictionary is listed first; as a result, if the <code>jsdoc</code> dictionary
230+
handles a tag differently than the <code>closure</code> dictionary, the
231+
<code>jsdoc</code> version of the tag takes precedence.</p>
232+
<p>If you are using JSDoc with a Closure Compiler project, and you want to avoid using tags that Closure Compiler does not recognize, change the <code>tags.dictionaries</code> setting to <code>[&quot;closure&quot;]</code>. You can also change this setting to <code>[&quot;closure&quot;,&quot;jsdoc&quot;]</code> if you want to allow
233+
core JSDoc tags, but you want to ensure that Closure Compiler-specific tags are interpreted as Closure Compiler would interpret them.</p>
219234
<h2 id="related-links">Related Links</h2>
220235
<ul>
221236
<li>

Diff for: content/en/about-configuring-jsdoc.md

+37-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ file, this is what JSDoc will use:
2020
```js
2121
{
2222
"tags": {
23-
"allowUnknownTags": true
23+
"allowUnknownTags": true,
24+
"dictionaries": ["jsdoc","closure"]
2425
},
2526
"source": {
2627
"includePattern": ".+\\.js(doc)?$",
@@ -37,6 +38,9 @@ file, this is what JSDoc will use:
3738

3839
This means:
3940

41+
+ JSDoc allows you to use unrecognized tags (`tags.allowUnknownTags`);
42+
+ Both standard JSDoc tags and [Closure Compiler tags][closure-tags] are enabled
43+
(`tags.dictionaries`);
4044
+ Only files ending in ".js" and ".jsdoc" will be processed (`source.includePattern`);
4145
+ Any file starting with an underscore or in a directory starting with an underscore will be
4246
_ignored_ (`source.excludePattern`);
@@ -48,8 +52,10 @@ These options and others will be further explained on this page.
4852
Further settings may be added to the file as requested by various plugins or templates (for example,
4953
the [Markdown plugin][markdown] can be configured by including a "markdown" key).
5054

55+
[closure-tags]: https://developers.google.com/closure/compiler/docs/js-for-compiler#tags
5156
[markdown]: plugins-markdown.html
5257

58+
5359
## Specifying input files
5460

5561
The "source" set of options, in combination with paths given to JSDoc on the command-line, determine
@@ -152,6 +158,7 @@ The reasoning is as follows:
152158
3. Apply `source.excludePattern`, which will remove `myProject/_private/a.js`.
153159
4. Apply `source.exclude`, which will remove `myProject/lib/ignore.js`.
154160

161+
155162
## Incorporating command-line options into the configuration file
156163

157164
It is possible to put many of JSDoc's [command-line options][options] into the configuration file
@@ -242,19 +249,41 @@ further information).
242249

243250
[link-tag]: tags-inline-link.html
244251

245-
### Miscellaneous
246252

247-
The `tags.allowUnknownTags` property determines whether tags unrecognised by JSDoc are permitted. If
248-
this is false and JSDoc encounters a tag it does not recognise (e.g. `@foobar`), it will throw an
249-
error. Otherwise, it will just ignore the tag.
253+
## Tags and tag dictionaries
254+
255+
The options in `tags` control which JSDoc tags are allowed and how each tag is interpreted.
250256

251-
By default, it is true.
252257

253258
{% example %}
254259

255-
```
260+
```js
256261
"tags": {
257-
"allowUnknownTags": true
262+
"allowUnknownTags": true,
263+
"dictionaries": ["jsdoc","closure"]
258264
}
259265
```
260266
{% endexample %}
267+
268+
The `tags.allowUnknownTags` property affects how JSDoc handles unrecognized tags. If you set this
269+
option to `false`, and JSDoc finds a tag that it does not recognize (for example, `@foo`), JSDoc
270+
logs a warning. By default, this option is set to `true`.
271+
272+
The `tags.dictionaries` property controls which tags JSDoc recognizes, as well as how JSDoc
273+
interprets the tags that it recognizes. In JSDoc 3.3.0 and later, there are two built-in tag
274+
dictionaries:
275+
276+
+ `jsdoc`: Core JSDoc tags.
277+
+ `closure`: [Closure Compiler tags][closure-tags].
278+
279+
By default, both dictionaries are enabled. Also, by default, the `jsdoc` dictionary is listed first;
280+
as a result, if the `jsdoc` dictionary handles a tag differently than the `closure` dictionary, the
281+
`jsdoc` version of the tag takes precedence.
282+
283+
If you are using JSDoc with a Closure Compiler project, and you want to avoid using tags that
284+
Closure Compiler does not recognize, change the `tags.dictionaries` setting to `["closure"]`. You
285+
can also change this setting to `["closure","jsdoc"]` if you want to allow core JSDoc tags, but you
286+
want to ensure that Closure Compiler-specific tags are interpreted as Closure Compiler would
287+
interpret them.
288+
289+
[closure-tags]: https://developers.google.com/closure/compiler/docs/js-for-compiler#tags

0 commit comments

Comments
 (0)