documentationjs / documentationjs/documentation
How to dictate ordering for exported methods?
- Dominant language
- JavaScript
- Stars
- 5.8k
- Forks
- 481
- PR merge metrics
- No merged PRs in 30d
Description
I have not been able to figure out how to set the ordering for exported methods using the `documentation.yml` approach.
Consider this simple function defined in the `index.js`
```js
/**
* Utility function to pretty print objects to console.
* To be used in development.
*
* @param {Object} obj
*/
exports.prettyPrint = function prettyPrint(obj) {
console.log(JSON.stringify(obj, null, 2));
};
```
If I try to add it to the `documentation.yml` file, I get the following error message:
```
Table of contents defined sorting of prettyPrint but no documentation with that namepath was found
```
I think this is because [`comment.memberof`](https://github.com/documentationjs/documentation/blob/master/src/sort.js#L70) will be set to `index`:
Comment Object JSON
```json
{
"description": {
"type": "root",
"children": [{
"type": "paragraph",
"children": [{
"type": "text",
"value": "Utility function to pretty print objects to console.\nTo be used in development.",
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 2,
"column": 27,
"offset": 79
},
"indent": [
1
]
}
}],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 2,
"column": 27,
"offset": 79
},
"indent": [
1
]
}
}],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 2,
"column": 27,
"offset": 79
}
}
},
"tags": [{
"title": "param",
"description": null,
"lineNumber": 4,
"type": {
"type": "NameExpression",
"name": "Object"
},
"name": "obj"
}],
"loc": {
"start": {
"line": 488,
"column": 0
},
"end": {
"line": 493,
"column": 3
}
},
"context": {
"loc": {
"start": {
"line": 494,
"column": 0
},
"end": {
"line": 496,
"column": 2
}
},
"file": "E:\\Projects\\repos\\elastic-builder\\src\\index.js",
"sortKey": "!E:\\Projects\\repos\\elastic-builder\\src\\index.js 00000494",
"github": {
"url": "https://github.com/sudo-suhas/elastic-builder/blob/6cc2d48579e1ec9af7f929f8d3052a7177423ff8/src/index.js#L494-L496",
"path": "src/index.js"
}
},
"augments": [],
"errors": [],
"examples": [],
"params": [{
"title": "param",
"name": "obj",
"lineNumber": 4,
"type": {
"type": "NameExpression",
"name": "Object"
}
}],
"properties": [],
"returns": [],
"sees": [],
"throws": [],
"todos": [],
"name": "prettyPrint",
"kind": "function",
"memberof": "index",
"scope": "static"
}
```
So how do I specify the sort order for such exported functions?
Contributor guide
Assessment
This issue has not been assessed yet.