Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Support node ranges and locations #89

Closed
mrennie opened this issue Sep 24, 2014 · 1 comment · May be fixed by Ramyromel/eslint-plugin-react#3
Closed

Support node ranges and locations #89

mrennie opened this issue Sep 24, 2014 · 1 comment · May be fixed by Ramyromel/eslint-plugin-react#3

Comments

@mrennie
Copy link

mrennie commented Sep 24, 2014

it would be very helpful if doctrine could support node ranges and locations. I imagine this would be the same infos that the Esprima parser provides, for example:

@param {Foo} one first param

parsed with options {loc:true, ranges:true} would yield something like:

{
    "description": "",
    "tags": [
        {
            "title": "param",
            "description": "first param",
            "type": {
                "type": "NameExpression",
                "name": "Foo"
            },
            "name": "one",
            "loc": {
                "start": { 
                     "line":1, 
                     "column": 0
                 }
                 "end": { 
                     "line": 1, 
                     "column": 30
                 }
            }
           "range": [0, 30]
        }
    ]
}
@nzakas
Copy link
Member

nzakas commented Sep 17, 2015

This would be really useful, we'll definitely add this.

@not-an-aardvark not-an-aardvark self-assigned this Apr 2, 2017
not-an-aardvark added a commit that referenced this issue Apr 2, 2017
This adds a `range` option to the `parse` API. When enabled, each node has a [start, end] range property indicating its location in the comment.

When computing the range with the `unwrap: true` option, the returned range needs to track indices in the original comment, not the unwrapped version. To implement that behavior, this commit updates the unwrapping logic to use a regular expression rather than a state machine. When converting an index, the parser and re-matches the original comment line-by-line, keeping track of the number of discarded "wrapping" characters.
not-an-aardvark added a commit that referenced this issue Nov 15, 2017
This adds a `range` option to the `parse` API. When enabled, each node has a [start, end] range property indicating its location in the comment.

When computing the range with the `unwrap: true` option, the returned range needs to track indices in the original comment, not the unwrapped version. To implement that behavior, this commit updates the unwrapping logic to use a regular expression rather than a state machine. When converting an index, the parser and re-matches the original comment line-by-line, keeping track of the number of discarded "wrapping" characters.
tmcw pushed a commit to documentationjs/doctrine that referenced this issue Apr 11, 2018
This adds a `range` option to the `parse` API. When enabled, each node has a [start, end] range property indicating its location in the comment.

When computing the range with the `unwrap: true` option, the returned range needs to track indices in the original comment, not the unwrapped version. To implement that behavior, this commit updates the unwrapping logic to use a regular expression rather than a state machine. When converting an index, the parser and re-matches the original comment line-by-line, keeping track of the number of discarded "wrapping" characters.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants