Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't extract comments from some situations #34

Closed
mappu opened this issue Sep 25, 2019 · 2 comments
Closed

Can't extract comments from some situations #34

mappu opened this issue Sep 25, 2019 · 2 comments
Labels

Comments

@mappu
Copy link

mappu commented Sep 25, 2019

Hi, thanks for this project -

I have some situations where comments are not properly extracted. I don't have an exact test case, but it's something like:

  1. multiple map key assignments
var x = {
   "foo": translate("foo"), /// TRANSLATORS: description of foo
   "bar": translate("bar"), /// TRANSLATORS: description of bar
   "baz": translate("baz"), /// TRANSLATORS: description of baz
}

In this case only the first comment would be extracted and matched.

  1. Some long concatenation
var x = "foo" +
   /// TRANSLATORS: comments for bar
   translate("bar") + 
   /// TRANSLATORS: comments for baz
   translate("baz") +
   "foo"
;

In this case none of the comments are extracted and matched.

I read the discussion in #4 (comment) so I guess these constructs have some different representation in the AST that is not understood.

In my codebase I can work around this by extracting to a local variable first before building the longer construct. The comments can be extracted in this way, but, it's less clear.

@lukasgeiter
Copy link
Owner

Thanks for reporting this issue. I'll try to fix this in the next release.

@lukasgeiter
Copy link
Owner

I've just published version 3.5.2 which should resolve the first issue.

As for the second example, this should already be working. However, you'll have to explicitly enable the extraction of comments on the previous line with otherLineLeading:

JsExtractors.callExpression('...', {
    arguments: { ... },
    comments: {
        otherLineLeading: true,
        sameLineLeading: true,
        sameLineTrailing: true
    }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants