Closed wahuneke closed 1 year ago
I've done some googling to try to find support for this supposed coding convention. I'm not seeing much of anything anywhere. Maybe I've made the whole thing up. Pycharm
definitely does it (https://www.jetbrains.com/help/pycharm/using-todo.html#add-multiline-todo)
I think this feature probably belongs just within my own app. I'll keep my implementation there unless others speak up to indicate this has broader usefulness.
Maybe this is a niche feature. I can just put it into my own app, if you don't want it in ast-comments.
I think it would be great to have an addition to the parse function or a pre-packaged helper that walks the tree and merges consecutive Comment nodes in cases where they fit some rule.
In my case (and I think this is not uncommon), I use this convention for multiline comments:
In the above example, it is a multiline comment that is a long TODO item. The above convention happens to be the one followed in
PyCharm
, ie it will identify the above as a multiline TODO and keep track of it for you in its list of todos.I'm proposing you add some merger predicate option which allows people to provide their own convention for merging one comment with another. Probably something like: Callable[[str, str], bool] meaning, we'll give you the body of the current comment and the body of the one that follows, you return True if these two should be considered part of the same comment. ie the second will get absorbed into the node above it.
As with my other issue ticket, I'm happy to impl this in a PR if you like.
Thanks!