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

Custom prefix/case/suffix for identifiers #794

Merged
merged 5 commits into from
Jan 3, 2024
Merged

Custom prefix/case/suffix for identifiers #794

merged 5 commits into from
Jan 3, 2024

Conversation

burrbull
Copy link
Member

@burrbull burrbull commented Jan 2, 2024

This PR doesn't add new cli options (yet?). But you can pass options by config:

❯ cat svd2rust.toml 
make_mod = true
generic_mod = true
strict = true
pascal_enum_values = true
max_cluster_size = true
atomics = true
atomics_feature = "atomics"
debug_impl = true
defmt_impl = "defmt"
reexport_core_peripherals = true
reexport_interrupt = true

[ident_formats.register_spec]
case = "constant"
suffix = "rs"

[ident_formats.enum_name]
case = "constant"

[ident_formats.enum_write_name]
case = "constant"
prefix = "w"

[ident_formats.field_reader]
case = "constant"
suffix = "r"

[ident_formats.field_writer]
case = "constant"
suffix = "w"

cc @Emilgardis what do you think?
This should not be a breaking change.

@burrbull burrbull force-pushed the idents branch 5 times, most recently from ce76aad to d1f2458 Compare January 2, 2024 11:40
@burrbull burrbull marked this pull request as ready for review January 2, 2024 12:27
@burrbull burrbull requested a review from a team as a code owner January 2, 2024 12:27
@Emilgardis
Copy link
Member

I like it :)

@burrbull
Copy link
Member Author

burrbull commented Jan 3, 2024

Could we merge this as it is?

serde(rename_all = "lowercase")
)]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub enum Case {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this non-exhaustive

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@Emilgardis
Copy link
Member

/ci diff pr

Copy link

github-actions bot commented Jan 3, 2024

Diff for comment

@Emilgardis
Copy link
Member

is the diff ok?

@@ -87431,13 +87431,13 @@ pub struct Peripherals {
     pub OTG_FS_HOST: OTG_FS_HOST,
     ///OTG_FS_PWRCLK
     pub OTG_FS_PWRCLK: OTG_FS_PWRCLK,
-    ///ETHERNET_MMC
+    ///Ethernet_MMC
     pub ETHERNET_MMC: ETHERNET_MMC,
-    ///ETHERNET_MAC
+    ///Ethernet_MAC
     pub ETHERNET_MAC: ETHERNET_MAC,
-    ///ETHERNET_PTP
+    ///Ethernet_PTP
     pub ETHERNET_PTP: ETHERNET_PTP,
-    ///ETHERNET_DMA
+    ///Ethernet_DMA
     pub ETHERNET_DMA: ETHERNET_DMA,
     ///SCB_ACTRL
     pub SCB_ACTRL: SCB_ACTRL,

@burrbull
Copy link
Member Author

burrbull commented Jan 3, 2024

Yes. I think it is better do not change case of peripheral name in documentation.

@Emilgardis Emilgardis added this pull request to the merge queue Jan 3, 2024
Merged via the queue into master with commit 454886e Jan 3, 2024
46 checks passed
@Emilgardis Emilgardis deleted the idents branch January 3, 2024 19:09
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.

2 participants