Skip to content

Comments lost in variable declarations #570

Closed
@pago

Description

@pago

In #544 support for patterns like

/**
 * Does foo!
 */
var foo = function() {};

export { foo }

has been added. However, the comment is lost and does not appear in the generated documentation.

I've tried to add it by adjusting addComments within lib/extractors/exported.js to the following:

function getComments(data, path) {
    if (!hasJSDocComment(path)) {
      if (t.isVariableDeclarator(path.parentPath.node)) {
        return getComments(data, path.parentPath);
      }
      if (t.isVariableDeclaration(path.parentPath.node) && path.parentPath.node.declarations.length === 1) {
        return getComments(data, path.parentPath);
      }
      var result = addBlankComment(data, path, path.node);
      return result ? [result] : [];
    }
    return path.node.leadingComments.filter(isJSDocComment).map(function (comment) {
      return addComment(data, comment.value, comment.loc, path, path.node.loc, true);
    }).filter(Boolean);
  }

which worked (in some cases) but also resulted in some duplicated documentation. Any hint on how to implement this?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions