Skip to content

Comments lost in variable declarations #570

@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

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy