JSDoc keeps output comments order

I have a JavaScript object that introduces some public methods, and I want to use JSDoc to document them.

In the source file, I have these functions grouped and ordered in a reasonable order, but after generating the JSDoc, I get all of them in alphabetical order, which does not make much sense.

Is there a way to keep order in the output? I could not find the answer, but I also could not find it impossible.

+7
javascript order jsdoc
source share
1 answer

Short answer:

In the conf.json file, add the opt element "sort": false , where sort indicates whether JSDoc should use alphabetical sorting.

Assuming you are using the conf.json file to specify JSDOC configuration parameters:

jsdoc -c path/to/conf.json 

For example:

 { "tags": { "allowUnknownTags": false }, "source": { "includePattern": ".+\\.js(doc)?$", "excludePattern": "(^|\\/|\\\\)_" }, "plugins": [], "templates": { "cleverLinks": true, "monospaceLinks": false, }, "opts": { "encoding": "utf8", "lenient": false, "sort": false } } 

I also met Docstrap , Bootstrap template for JSDoc3.

Then you can use the "sort" option in the templates section. An example conf.json file for this case might look like this:

 { "tags": { "allowUnknownTags": true, "dictionaries": ["jsdoc","closure"] }, "source": { "includePattern": ".+\\.js(doc|x)?$", "excludePattern": "(^|\\/|\\\\)_" }, "plugins": [], "templates": { "cleverLinks": false, "monospaceLinks": false "sort": false } } 

Description on Docstrap website:

sort The default value is true. Indicates whether jsdoc should sort data or use file order. It can also be a string, and if it is passed directly to jsdoc. The default string is "longname, version, since".

+1
source share

All Articles