-
Notifications
You must be signed in to change notification settings - Fork 21
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
Escape javadoc special characters #1342
Conversation
return formatForeignBlockCommentFrom(comment, 0, indent) | ||
} | ||
|
||
// formatForeignBlockCommentFrom is like [formatForeignBlockComment], except that it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style nit for helper functions fHelper that are only called from f and are not supposed to be used anywhere else I personally forgo the doc comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a helper function. It's called directly from the rest of the module. It's used for generating comments like:
fprintf(w, formatForeignBlockCommentFrom("@return "+invoke.Comment, 1))
That way any @
in the invoke.Comment
string is escaped but the first @
of the @return
is left alone.
// Then write the code block itself | ||
dst.WriteString(code(comment[codeStart:codeEndOffset])) | ||
// Then adjust copiedTo to start after the code block | ||
comment = comment[codeEndOffset:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old-fashioned scanner FTW.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing this!
Reverts #1342 Testing this out on pulumi/pulumi-azure#1992 it appears that the latest version still cannot properly escape the generated code, moreover it seems to have regressed on not escaping `->` properly which might further break things. I think we might be better off reverting for now until we work this out to pass more test cases. Apologies for merging that without diving deeper - it looked solid at code review time, I guess we don't have downstream checks here yet to demonstrate that derivative providers cannot build with the changes.
Description
Fixes #1271
Correctly scope comment escapes to outside of code blocks. The resulting code is both more idiomatic javadoc and safe to embed.
I have two motivating examples:
Correctness: Upstream comments that start lines with
@pattern
will now be escaped to{@literal @}pattern
. This has prevented us from publishing in the past (A release workflow silently fails for Java sdk pulumi-gcp#1950, Java SDK does not pass javadoc pulumi-auth0#516, Java SDK does not pass javadoc pulumi-azure#1979)Idiomaticity: Generated code blocks will no longer be HTML escaped (since they don't need to be). Instead, they will render correctly.
Checklist