Flame_Phoenix
Flame_Phoenix

Reputation: 17574

How to create categories in JSDoc?

Background

I am documenting my own JS library, and I stumbled upon the lodash library ( https://lodash.com/docs/4.17.4 ).

It's documentation has a sidebar with categories ( Array, Collection, ect ) and each one has documentation for the functions.

Objective

I would like my documentation to have a similar structure using the latest JSDoc version.

Problem

After investigating I couldn't find the jsdoc template used by lodash. I also couldn't find a similar feature nor how to replicate it using JSDOC.

Questions

Upvotes: 4

Views: 5642

Answers (4)

Thomas Kolasa
Thomas Kolasa

Reputation: 114

Problem with category tag support by JSDoc lays not in plugin per se, but in template which needs to have support for the category tag. Personally I use the Docdash template and I took the time and extended the Docdash template with support for category. Usable from the get-go - just needs config.

https://www.npmjs.com/package/docdash-extended

Upvotes: 0

itsbhenry
itsbhenry

Reputation: 51

Just wanted to share an answer that I finally had for once on stackoverflow. You can indeed add @category tags to your JSDoc, you just need to install this plugin via config file:

Upvotes: 0

wojtekk
wojtekk

Reputation: 616

I've just released a new version of better-docs jsdoc template and it supports @category tag. Just add it to your class/module/whatever and it will be namespaced in the sidebar.

https://github.com/SoftwareBrothers/better-docs

Upvotes: 5

Flame_Phoenix
Flame_Phoenix

Reputation: 17574

Solution

After much research I concluded that adding a @category with jsdoc was impossible. In fact, many have tried before and failed:

The only way to somehow simulate this behavior is to use @namespace, but this solution is heavy in drawbacks and is limited in scope:

Still, until such a feature is supported, this is what I am using.

Upvotes: 3

Related Questions