-
Notifications
You must be signed in to change notification settings - Fork 46
feat: add DBC_FILE_NAME + ver, proper code formatting
#131
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
Conversation
Instead of a comment at the top, generate usable constants: ```rust pub const DBC_FILE_NAME: &str = "filename"; pub const DBC_FILE_VERSION: &str = "1.0"; ``` Use token parser and `prettyplease` code formatter to generate stable code output. This also allows us to migrate to syn/quote-based code generation in the future, rather than rely on text manipulation.
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.
Pull request overview
This PR replaces the comment-based file metadata header with usable constants and implements proper code formatting using prettyplease and syn for stable output generation.
Changes:
- Replaced top-of-file comments with
DBC_FILE_NAMEandDBC_FILE_VERSIONconstants - Integrated
prettypleasefor consistent code formatting - Added
synandprettypleasedependencies to enable token-based parsing and formatting
Reviewed changes
Copilot reviewed 53 out of 98 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/lib.rs | Replaced comment generation with constant declarations; integrated prettyplease formatting in generate() and write() methods |
| Cargo.toml | Added prettyplease and syn dependencies for code formatting |
| tests-snapshots/dbc-cantools/*.snap.rs | Updated snapshot files showing formatted output with new constants replacing comments |
| tests-snapshots/dbc-cantools/*.snap.stderr | Updated error snapshots reflecting new line numbers after formatting changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
src/lib.rs
Outdated
| })?; | ||
|
|
||
| writeln!(w)?; | ||
| let dbc_name = config.dbc_name.escape_default(); |
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.
What do you think of putting these at the top of the file, before the other imports, with a comment indicating "/// Code generated from DBC file"? Then the future #[doc] usage via quote will still be do-able (it will comment the filename string) and the message appears where it used to, as a warning to someone who might attempt to modify it.
Instead of a comment at the top, generate usable constants:
Use token parser and
prettypleasecode formatter to generate stable code output. This also allows us to migrate to syn/quote-based code generation in the future, rather than rely on text manipulation.Note that this re-generates all expected code files, but the changes are minor - mostly a few newlines, minor formatting, and the two new constants from above.