Skip to content

Commit a21f7a0

Browse files
committed
document sourceType option; add supported versions to recurseDepth option (#166)
1 parent 60664fa commit a21f7a0

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

about-configuring-jsdoc.html

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ <h2>Table of Contents</h2>
3939
<li>
4040
<a href="#specifying-input-files">Specifying input files</a>
4141
</li>
42+
<li>
43+
<a href="#specifying-the-source-type">Specifying the source type</a>
44+
</li>
4245
<li>
4346
<a href="#incorporating-command-line-options-into-the-configuration-file">Incorporating command-line options into the configuration file</a>
4447
</li>
@@ -87,6 +90,7 @@ <h2 id="default-configuration-options">Default configuration options</h2>
8790
"includePattern": ".+\\.js(doc|x)?$",
8891
"excludePattern": "(^|\\/|\\\\)_"
8992
},
93+
"sourceType": "module",
9094
"tags": {
9195
"allowUnknownTags": true,
9296
"dictionaries": ["jsdoc","closure"]
@@ -104,6 +108,7 @@ <h2 id="default-configuration-options">Default configuration options</h2>
104108
<li>If recursion is enabled with the <a href="about-commandline.html"><code>-r</code> command-line flag</a>, JSDoc will search for files 10 levels deep (<code>recurseDepth</code>).</li>
105109
<li>Only files ending in <code>.js</code>, <code>.jsdoc</code>, and <code>.jsx</code> will be processed (<code>source.includePattern</code>).</li>
106110
<li>Any file starting with an underscore, or in a directory starting with an underscore, will be ignored (<code>source.excludePattern</code>).</li>
111+
<li>JSDoc supports code that uses <a href="howto-es2015-modules.html">ES2015 modules</a> (<code>sourceType</code>).</li>
107112
<li>JSDoc allows you to use unrecognized tags (<code>tags.allowUnknownTags</code>).</li>
108113
<li>Both standard JSDoc tags and <a href="https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#jsdoc-tags">Closure Compiler tags</a> are enabled (
109114
<code>tags.dictionaries</code>).</li>
@@ -130,9 +135,9 @@ <h2 id="configuring-plugins">Configuring plugins</h2>
130135
<p>You can configure the Markdown plugin by adding a <code>markdown</code> object to your configuration file. See
131136
<a href="plugins-markdown.html">Configuring the Markdown Plugin</a> for details.</p>
132137
<h2 id="specifying-recursion-depth">Specifying recursion depth</h2>
133-
<p>The <code>recurseDepth</code> option controls how many levels deep JSDoc will recursively search for source files and tutorials. This option is used only if
134-
you also specify the <a href="about-commandline.html"><code>-r</code> command-line
135-
flag</a>, which tells JSDoc to recursively search for input files.</p>
138+
<p>The <code>recurseDepth</code> option controls how many levels deep JSDoc will recursively search for source files and tutorials. This option is available in
139+
JSDoc 3.5.0 and later. This option is used only if you also specify the <a href="about-commandline.html"><code>-r</code> command-line flag</a>, which tells
140+
JSDoc to recursively search for input files.</p>
136141
<figure><pre class="prettyprint lang-js"><code>{
137142
"recurseDepth": 10
138143
}
@@ -222,6 +227,19 @@ <h2 id="specifying-input-files">Specifying input files</h2>
222227
<li>JSDoc applies <code>source.excludePattern</code>, which removes <code>myProject/_private/a.js</code>.</li>
223228
<li>JSDoc applies <code>source.exclude</code>, which removes <code>myProject/lib/ignore.js</code>.</li>
224229
</ol>
230+
<h2 id="specifying-the-source-type">Specifying the source type</h2>
231+
<p>The <code>sourceType</code> option affects how JSDoc parses your JavaScript files. This option is available in JSDoc 3.5.0 and later. This option accepts the
232+
following values:</p>
233+
<ul>
234+
<li><code>module</code> (default): Use this value for most types of JavaScript files.</li>
235+
<li><code>script</code>: Use this value if JSDoc logs errors such as <code>Delete of an unqualified identifier in
236+
strict mode</code> when it parses your code.</li>
237+
</ul>
238+
<figure><pre class="prettyprint lang-js"><code>{
239+
"sourceType": "module"
240+
}
241+
</code></pre>
242+
</figure>
225243
<h2 id="incorporating-command-line-options-into-the-configuration-file">Incorporating command-line options into the configuration file</h2>
226244
<p>You can put many of JSDoc&#39;s <a href="about-commandline.html">command-line options</a> into the configuration file instead of specifying them on the command
227245
line. To do this, add the long names of the relevant options into an

content/en/about-configuring-jsdoc.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ If you do not specify a configuration file, JSDoc uses the following configurati
6565
"includePattern": ".+\\.js(doc|x)?$",
6666
"excludePattern": "(^|\\/|\\\\)_"
6767
},
68+
"sourceType": "module",
6869
"tags": {
6970
"allowUnknownTags": true,
7071
"dictionaries": ["jsdoc","closure"]
@@ -85,6 +86,7 @@ for files 10 levels deep (`recurseDepth`).
8586
+ Only files ending in `.js`, `.jsdoc`, and `.jsx` will be processed (`source.includePattern`).
8687
+ Any file starting with an underscore, or in a directory starting with an underscore, will be
8788
ignored (`source.excludePattern`).
89+
+ JSDoc supports code that uses [ES2015 modules][es2015-modules] (`sourceType`).
8890
+ JSDoc allows you to use unrecognized tags (`tags.allowUnknownTags`).
8991
+ Both standard JSDoc tags and [Closure Compiler tags][closure-tags] are enabled
9092
(`tags.dictionaries`).
@@ -95,6 +97,7 @@ These options and others are explained in the following sections.
9597

9698
[about-commandline]: about-commandline.html
9799
[closure-tags]: https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler#jsdoc-tags
100+
[es2015-modules]: howto-es2015-modules.html
98101
[tags-inline-link]: tags-inline-link.html
99102

100103

@@ -132,8 +135,9 @@ You can configure the Markdown plugin by adding a `markdown` object to your conf
132135
## Specifying recursion depth
133136

134137
The `recurseDepth` option controls how many levels deep JSDoc will recursively search for source
135-
files and tutorials. This option is used only if you also specify the [`-r` command-line
136-
flag][about-commandline], which tells JSDoc to recursively search for input files.
138+
files and tutorials. This option is available in JSDoc 3.5.0 and later. This option is used only if
139+
you also specify the [`-r` command-line flag][about-commandline], which tells JSDoc to recursively
140+
search for input files.
137141

138142
{% example %}
139143

@@ -249,6 +253,25 @@ files:
249253
[about-commandline]: about-commandline.html
250254

251255

256+
## Specifying the source type
257+
258+
The `sourceType` option affects how JSDoc parses your JavaScript files. This option is available in
259+
JSDoc 3.5.0 and later. This option accepts the following values:
260+
261+
+ `module` (default): Use this value for most types of JavaScript files.
262+
+ `script`: Use this value if JSDoc logs errors such as `Delete of an unqualified identifier in
263+
strict mode` when it parses your code.
264+
265+
{% example %}
266+
267+
```js
268+
{
269+
"sourceType": "module"
270+
}
271+
```
272+
{% endexample %}
273+
274+
252275
## Incorporating command-line options into the configuration file
253276

254277
You can put many of JSDoc's [command-line options][options] into the configuration file instead of

0 commit comments

Comments
 (0)