documentationjs / documentationjs/documentation

How to dictate ordering for exported methods?

Aperta
#768 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
5.8k
Fork
481
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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?

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia leggendo in src/sort.js la parte relativa alla gestione di comment.memberof e confrontala con l’esempio di ordinamento descritto nell’issue in documentation.yml. Riproduci l’errore usando la funzione prettyPrint esportata in src/index.js. Il lavoro è completato quando è documentato il modo supportato per specificare l’ordine oppure il comportamento di ordinamento dell’issue è chiarito con un esempio verificato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
documentation
Tipo di issue
Documentazione
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.