@@ -87,28 +87,30 @@ function addTheXandYProperties({ x, y }) {
87
87
}
88
88
```
89
89
90
- Destructured parameters are ** unnamed** : while we have names for x & y,
91
- the function doesn't declare what it will call the object you call
92
- this function with. So documentation.js names your destructured parameters
93
- for you: if the param is the first, it'll call it ` $0 ` , if second, ` $1 ` ,
94
- and so on.
90
+ Destructured parameters are ** unnamed** in the code: while we have names
91
+ for x & y, the function doesn't declare what it will call the object you
92
+ call this function with. So you must name the parent object of
93
+ destructured parameters to document them in documentation.js.
95
94
96
95
So, if you want to add more detailed documentation for properties
97
- within destructured params, prefix property names with $0 for the object,
98
- or $1 if it's the second parameter, and so on - the number is the position
99
- of the destructuring parameter within the list of parameters. Here's
100
- an example:
96
+ within destructured params, name the parent object, then prefix property
97
+ names with the parent object. Here's an example:
101
98
102
99
``` js
103
100
/**
104
- * This method has partially inferred params
105
- * @param {String} $0.fishes number of kinds of fish
101
+ * This method has hierachical params
102
+ * @param {Object} animals different kinds of animals
103
+ * @param {String} animals.fishes number of kinds of fish
106
104
*/
107
105
function fishesAndFoxes ({ fishes, foxes }) {
108
106
return fishes + foxes;
109
107
}
110
108
```
111
109
110
+ Note: documentation.js used to implicitly call those parent objects
111
+ ` $0 ` , ` $1 ` , etc. Starting in documentation.js 4.0.0-rc.1 the more
112
+ explicit syntax is required.
113
+
112
114
## Object Factories
113
115
114
116
Libraries like [ d3] ( http://d3js.org/ ) eschew JavaScript's ` new ` operator
0 commit comments