documentationjs / documentation

:book: documentation for modern JavaScript
http://documentation.js.org/
Other
5.79k stars 483 forks source link

How to dictate ordering for exported methods? #768

Open sudo-suhas opened 7 years ago

sudo-suhas commented 7 years ago

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

/**
 * 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 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?

toxic-johann commented 7 years ago

bump into the same question. @sudo-suhas Have you solved that?

sudo-suhas commented 7 years ago

No. I wasn't able to. The best I could do was not dictate ordering for few so that they would end up at the bottom.

sudo-suhas commented 7 years ago

@toxic-johann If you put the exported method in its own file, you can dictate ordering for that.

toxic-johann commented 7 years ago

@sudo-suhas thanks~

revolter commented 6 years ago

I'm having a similar problem where I have:

var test = {
    first: {}
    second: {}
}

and having this configuration:

toc:
  - name: test
    children:
      - test.first

throws this error:

Table of contents defined sorting of test.first but no documentation with that namepath was found

but documentation build contains:

"path": [
  {
    "name": "test"
  },
  {
    "name": "first",
    "scope": "static"
  }
],
"namespace": "test.first"

What is the difference between namepath and namespace, and what's the correct syntax?