-
Notifications
You must be signed in to change notification settings - Fork 440
Please add a TriviaPiece.commentValue
property
#1890
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
Comments
Tracked in Apple’s issue tracker as rdar://111922531 |
Using let triviaPiece = TriviaPiece.docLineComment("/// Text")
|
Well, the latter case gets hard for multi-line comments. What's the content of: /**
* Hello, folks!
* I am a banana!
*/ I think just returning the string verbatim is fine—anybody who cares about processing it can do so. Or, if it is easy enough, you could provide |
I think stripping off the Now the question is: What should we do with the space after We could do the same for block comments and use the same logic whether to remove a space after |
Sounds good to me. I had the same idea in mind. I can try implement it 🤗 |
One more edge case jumped into my mind. Do we care about multi comments in one Trivia(
pieces: [
.docLineComment("/// docLineComment_1.1"),
.docLineComment("/// docLineComment_1.2"),
.newlines(2),
.docBlockComment("""
/**
docBlockComment_1.1
docBlockComment_1.2
/*
"""),
.docLineComment("/// docLineComment_2.1"),
.docLineComment("/// docLineComment_2.2"),
]
) |
Well, I expect these properties to be on |
We could have the convenience property on |
FWIW, I just implemented logic in swift-format that tries to mimic what the compiler's Markup component does to extract doc comments from swift-syntax would be a better home for this, especially since I imagine it'll happen eventually anyway as more of the compiler gets moved from C++ to Swift. |
Hi all, is this issue still up for grabs? 👨🏻💻 @allevato sounds like you’ve done some great work with Swift format related to this. Do you have plans to bring it in to this issue? Or am I good to look at this? |
Yes, it is. |
I personally don't have the cycles right now, but if you are interested in using the |
Thanks both! @ahoppen Are you able to assign me please? |
Hi all, I'm looking at this issue now and got a nice basic implementation working but would love some input on a particular use case. For the source code below, what would you expect the output to be of /*
* Hello, folks!
* // Apples and oranges
* I am a banana!
*/ I have an idea of what I'd expect (and have implemented it that way at the moment) but would be good to get other's opinions before I move further. (Equally this would apply for doc comment blocks containing a doc comment line too or a variant of the two) Option A 🍎["Hello, folks! Apples and oranges I am a banana!"] Option B 🍌["Hello, folks! // Apples and oranges I am a banana!"] Option C 🥕["Hello, folks!", "Apples and oranges", "I am a banana!"] Option D 🍊["Hello, folks! I am a banana!", "Apples and oranges"] Option E 🤔Or something else entirely? |
I would expect either |
Agreed! I'd expect option B from the examples above if I were to access that value so I'll go down that path. Thanks! |
Hi @DougGregor @ahoppen, |
@zyadtaha it doesn't look like anyone is actively working on it. The draft PR is almost a year old and hasn't received any updates based on the code review in the pull request. |
@zyadtaha Feel free to take over my draft PR and address the issues on there if you'd like. Happy to help out if you have any questions. |
Description
There are four kinds of comment tracked by
TriviaPiece
. It'd be a nice convenience to be able to extract the string values of those comments. May I suggest something like:The text was updated successfully, but these errors were encountered: