Skip to content

Improved parsing of @tags #181

@jcalfee

Description

@jcalfee

I have some existing jsdocs and I want to use esdoc for its es6 support. I hit a snag...

It looks like the esdoc relies on the extra *s being precisely positioned. This really threw me for a while. I would suggest that the doc tags be read properly even though they are not proceeded by a star or the spacing after the star varry.

For example, this does not parse the args into a table:

/**
 *  this is object destructuring.
 *  @param {Object} param - this is object param.
 *  @param {number} param.foo - this is property param.
 *  @param {string} param.bar - this is property param.
 */
export function myFunc({ foo, bar }){}

Instead of a table, the text falls through: this is object destructuring. @param {Object} param - this is object param. @param {number} param.foo - this is property param. @param {string} param.bar - this is property param.

But this works:

/**
 * this is object destructuring.
 * @param {Object} param - this is object param.
 * @param {number} param.foo - this is property param.
 * @param {string} param.bar - this is property param.
 */
export function myFunc({ foo, bar }){}

This is not easy to figure out if the docs have other things going on (like my real test case). I would suggest that the parsing not depend on the asterisk at all. Or, at least put a warning about this in your docs.

The ideal implementation should consider many variants including this one valid :

/**
    this is object destructuring.
    @param {Object} param - this is object param.
    @param {number} param.foo - this is property param.
    @param {string} param.bar - this is property param.
 */
export function myFunc({ foo, bar }){}

In version 0.4.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions