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

WIP: try to use quote + prettyplease #132

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft

Conversation

hasezoey
Copy link
Collaborator

@hasezoey hasezoey commented Feb 8, 2024

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

@hasezoey hasezoey requested a review from Wulf February 8, 2024 17:34
@hasezoey hasezoey marked this pull request as draft February 8, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant