Skip to content

Feature: return comments with the parser #105

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

Merged
merged 5 commits into from
Jan 11, 2024
Merged

Feature: return comments with the parser #105

merged 5 commits into from
Jan 11, 2024

Conversation

Janther
Copy link
Collaborator

@Janther Janther commented Jan 9, 2024

added the comments option and when it's set to true, the AST will have an extra property with an array of all of the comments within the source.
Also fixed a bug where the loc of a token will display the wrong end property if the token contained new lines.

Once this is published prettier-plugin-solidity won't need solidity-comments-extractor anymore.

@Janther Janther requested a review from fvictorio January 9, 2024 21:15
Copy link
Contributor

@fvictorio fvictorio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks a lot @Janther!

I left two very optional comments, feel free to merge whether you apply them or not.

Janther and others added 5 commits January 11, 2024 15:19
Co-authored-by: Franco Victorio <victorio.franco@gmail.com>
Co-authored-by: Franco Victorio <victorio.franco@gmail.com>
@tonisives
Copy link

Just saying the comment parsing seems to be incorrect for some functions. For instance, this one:

    /**
        @notice Returns square-root spot price, lower and upper bounds of the AMM position. 
     */
    function getAMMState()

link

@fvictorio
Copy link
Contributor

fvictorio commented Jun 5, 2024

@tonisives what does the parser produce and why do you think it's wrong? I tried it and got:

[
  {
    type: 'BlockComment',
    value: '*\n' +
      '        @notice Returns square-root spot price, lower and upper bounds of the AMM position. \n' +
      '     '
  }
]

which looks correct to me.

@tonisives
Copy link

I am not familiar with AST representation of comments. I can only write my preference.

*
            @notice Returns square-root spot price, lower and upper bounds of the AMM position. 
         

If I look at this result, then it is missing * and / \ characters.

Another issue is with /// function comments.
They are missing 2 of the / in front of the comment

screenshot-2024-06-06-at-16 33 31 [source](https://github.com/sherlock-audit/2024-03-arrakis/blob/main/arrakis-modular/src/ArrakisMetaVaultFactory.sol#L121)

I would also like to get the whole comment (all 9 lines), but they are as separate objects in the result.

I think it is normal to expect that /// lines above the function compose the full function comment. But again, I don't know AST comments format at all.

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

Successfully merging this pull request may close these issues.

None yet

3 participants