Skip to content

add example of documenting destructuring parameters #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions content/en/tags-param.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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