Skip to content

Commit

Permalink
add example of documenting destructuring parameters (#177)
Browse files Browse the repository at this point in the history
Fixes: #159
Refs: jsdoc/jsdoc#987
  • Loading branch information
zhengzongyi authored and hegemonic committed Aug 7, 2017
1 parent 5505441 commit 40b3b1e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
17 changes: 17 additions & 0 deletions content/en/tags-param.md
Expand Up @@ -107,6 +107,23 @@ Project.prototype.assign = function(employee) {
```
{% endexample %}

If a parameter is destructured without an explicit name, you can give the object an appropriate one and
document its properties.

{% example "Documenting a destructuring parameter" %}
```js
/**
* Assign the project to an employee.
* @param {Object} employee - The employee who is responsible for the project.
* @param {string} employee.name - The name of the employee.
* @param {string} employee.department - The employee's department.
*/
Project.prototype.assign = function({ name, department }) {
// ...
};
```
{% endexample %}

You can also combine this syntax with JSDoc's syntax for array parameters. For example, if multiple
employees can be assigned to a project:

Expand Down
15 changes: 13 additions & 2 deletions tags-param.html
Expand Up @@ -127,8 +127,19 @@ <h3 id="parameters-with-properties">Parameters with properties</h3>
Project.prototype.assign = function(employee) {
// ...
};
</code></pre>
</figure>
</code></pre></figure>
<p>If a parameter is destructured without an explicit name, you can give the object an appropriate one and document its properties.</p>
<figure>
<figcaption>Documenting a destructuring parameter</figcaption><pre class="prettyprint lang-js"><code>/**
* Assign the project to an employee.
* @param {Object} employee - The employee who is responsible for the project.
* @param {string} employee.name - The name of the employee.
* @param {string} employee.department - The employee's department.
*/
Project.prototype.assign = function({ name, department }) {
// ...
};
</code></pre></figure>
<p>You can also combine this syntax with JSDoc&#39;s syntax for array parameters. For example, if multiple employees can be assigned to a project:</p>
<figure>
<figcaption>Documenting properties of values in an array</figcaption><pre class="prettyprint lang-js"><code>/**
Expand Down

0 comments on commit 40b3b1e

Please sign in to comment.