Jsdoc: Class description not work with `export`

Created on 4 Jan 2016  路  18Comments  路  Source: jsdoc/jsdoc

When I describe an export class

image

nothing generates

image

When I cut the export

image

It works fine

image

How can I solve this problem?

bugfix

Most helpful comment

This is closed, but is still broken in v3.4.2. Without the hack mentioned in https://github.com/jsdoc3/jsdoc/issues/1137#issuecomment-174829004 it still is incorrect.

Here is what we are using in pixi to work around this issue, but this should be reopened because it is still active: https://github.com/pixijs/pixi.js/blob/dev/scripts/jsdoc-fix.js

All 18 comments

It's even worse if you try export default class MyClass { }, and God forbid you have a @module annotation at the beginning of the file (separate doclet from the one above the class definition.

ES2015 is still a work in progress, guys, I believe you can follow it at #555

In this particular case, I'd just recommend separating class description and exporting, it works for me in 3.4:

/** */
class App {}

export default App;

@rozzzly @zandaqo I will separate export and class. Thanks!

@gocreating @rozzzly

It seems like something has been implemented regarding classes that basically hijacks the file. Not only that but it is intentional.

@rozzzly I'm writing a personal plugin for my own docs (slightly opinionated) and part of it is normalizing some of the exports behaviour (cleaner multiple es6 exports with better @module support).

I imagine that I'll be able to separate some of the functionality to fix the class export issue with a plugin.

I'm using babel 6 for my transpiling, which means that my default exports are not synonymous with module.exports() and need to be accessed using require().default so my plugin is also designed to solve that issue for me by putting default exports on exports.default.

If the class functionality of hijacking the entire @module in scope is a design feature that will remain, I will try and put a plugin together -- I'd rather be explicit about what classes represent entire modules via comments than have jsdoc automatically force that on me. Maybe @hegemonic can shed some light here

@rozzzly here's a little demo of what I've got going so far:

Consider this code:

/**
 * Some lib description
 *
 * @module my-lib
 */

/**
 * The plugin object.
 *
 * @type {Object}
 */
const libObject = {};

/**
 * Helper function
 */
function helper () {}

/**
 * Fighter function
 */
function fighter () {}

/**
 * Bazz is a pretty rad function
 */
export default function Bazz () {}

export { libObject, helper, fighter };

/**
 * Super awesome class!
 */
export class App {

}

You get
image

I've still gotta work out a few issues with it but I'll post a link here to the code when I'm done.
In my own docs I have started experimenting with grouping the exports at the top together:

image

@gocreating @rozzzly

I got export default class App working too.... by cheating with a beforeParse event hook using a dirty regex search/replace on the source code.

I got pretty close to solving it in a cleaner way using the visitNode hook, maybe it should be fixed via PR though.

Awesome job @nathanmarks

Hi guys, any progress on this?

I wrote down result of my research on current JSDoc's support for ES6 modules: https://github.com/jsdoc3/jsdoc/issues/555#issuecomment-245549805.

This is indeed a bug. The following example should work; instead, the class description ends up in a separate, misnamed doclet from the class' doclet:

/**
 * Foo module
 * @module foo
 */

/** Class description */
export class Bar {
}

I'll investigate.

Fixed on master and releases/3.4. The fix will be included in JSDoc 3.4.2.

This is closed, but is still broken in v3.4.2. Without the hack mentioned in https://github.com/jsdoc3/jsdoc/issues/1137#issuecomment-174829004 it still is incorrect.

Here is what we are using in pixi to work around this issue, but this should be reopened because it is still active: https://github.com/pixijs/pixi.js/blob/dev/scripts/jsdoc-fix.js

Is it going to be reopened? JSDoc 3.4.3 (Thu, 10 Nov 2016 00:25:10 GMT) is still affected.

update: workaround: @function module:electron-updater/out/AppUpdater.AppUpdater#getFeedURL for methods. i.e. specify full name path.

Can confirm that JSDoc 3.4.3 (Thu, 10 Nov 2016 00:25:10 GMT) still exhibits this behavior.

I made some additional fixes for ES2015 modules and classes on GitHub master. The additional fixes will be included in JSDoc 3.5.0.

If you are still seeing problems on GitHub master, please file a new issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

coot picture coot  路  14Comments

alphanull picture alphanull  路  15Comments

FezVrasta picture FezVrasta  路  23Comments

kripod picture kripod  路  26Comments

gajus picture gajus  路  15Comments