This PR is a POC (which may be extended upon) to use quote + prettyplease for code generation instead of a string.
limitations i have found while using quote + syn + prettyplease:
does not preserve empty new lines
doc-comments will either get formatted as /** */ if multiline
does not preserve comments (that are not doc-comments)
does not indent multiline doc-comments
doc-comments have to be done in a separate variable, because quote does not allow interpolation in a comment
aside from those problems there are some things which could be done, but i have not done yet:
re-order the functions so that only one buffer is required (cannot add a beginning impl and a end impl like a string)
refactor structs / functions to use proc-macro2 / syn types (as to not require so much syn::parse)
re #105
PS: i know the tests are failing, i have just included 2 updated test cases which cover the all the cases this PR touches, and to simplify a quick review
my personal opinion is that at least in the current state (see limitations), the string representation is a lot better; but we should maybe still store proc-macro2 / syn types in things like StructField or names, to maybe ensure they are valid idents and stuff
This PR is a POC (which may be extended upon) to use
quote
+prettyplease
for code generation instead of a string.limitations i have found while using quote + syn + prettyplease:
/** */
if multilineaside from those problems there are some things which could be done, but i have not done yet:
buffer
is required (cannot add a beginningimpl
and a endimpl
like a string)syn::parse
)re #105
PS: i know the tests are failing, i have just included 2 updated test cases which cover the all the cases this PR touches, and to simplify a quick review
my personal opinion is that at least in the current state (see limitations), the string representation is a lot better; but we should maybe still store proc-macro2 / syn types in things like
StructField
or names, to maybe ensure they are valid idents and stuff