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

inlined comments #10

Open
t3rn0 opened this issue Mar 5, 2023 · 4 comments
Open

inlined comments #10

t3rn0 opened this issue Mar 5, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@t3rn0
Copy link
Owner

t3rn0 commented Mar 5, 2023

Currently we don't identify inlined comments in code, all comments are just regular (not inlined) (https://github.com/t3rn0/ast-comments#notes).
Difference between them is lost after the code is parsed into the tree.
We should try distinguish inlined and regular comments when unparsing the tree back to the code.

It'd be great to cover following cases:

  • simple expression:
    a = 1  # c1
    
  • if-elif-else
    if a:  # c2
        ...
    elif b:  # c3
        ...
    else:  # c4
        ...
    
  • try-except-else-finally
  • for-else
  • match
@t3rn0 t3rn0 added the enhancement New feature or request label Mar 5, 2023
@Roni1993
Copy link

anyway i can support with this ticket?
i stumbled upon your lib today and it does exactly what i need but this bug is causing me small issues :/

example:

def __init__(self, **kwargs: Any):
    """Initialize a MarkdownTextSplitter."""
    separators = [
        # First, try to split along class definitions
        "\nclass ",
        "\ndef ",
        "\n\tdef ",
        # Now split by the normal type of lines
        "\n\n",
        "\n",
        " ",
        "",
    ]
    super().__init__(separators=separators, **kwargs)

becomes this:

def __init__(self, **kwargs: Any):
    """Initialize a MarkdownTextSplitter."""
    # First, try to split along class definitions
    # Now split by the normal type of lines
    separators = ['\nclass ', '\ndef ', '\n\tdef ', '\n\n', '\n', ' ', '']
    super().__init__(separators=separators, **kwargs)

@t3rn0
Copy link
Owner Author

t3rn0 commented Apr 17, 2023

Thanks for noticing that.
The example you gave is not relevant to the issue, so I opened another one #13
I don't have enough time to look at it right now but I'll try to fix it next month

@zmievsa
Copy link
Contributor

zmievsa commented Dec 21, 2023

Any progress here? Not urgent for me as this lib already does everything I need but I just wanted to add a gentle nudge to continue developing it as it's an amazing tool for anyone who delved a bit too deep into AST.

Big thanks for making this effort and I hope this library gets a lot more popular!

@t3rn0
Copy link
Owner Author

t3rn0 commented Dec 25, 2023

Hello. Thank you for your interest in the library.
The original problem here was resolved a few commits ago. Almost...
There is one element left: comments for match blocks.
Now this issue serves as a kind reminder to me that there is still work to be done. 😁

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

When branches are created from issues, their pull requests are automatically linked.

3 participants