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

Document attributes #17

Open
asomers opened this issue Aug 4, 2018 · 4 comments
Open

Document attributes #17

asomers opened this issue Aug 4, 2018 · 4 comments

Comments

@asomers
Copy link

asomers commented Aug 4, 2018

It looks like the bitfield macro supports placing pretty much any compiler attribute on the struct or on any field. This is very useful, especially for doing things like #[derive(Clone)]. But it's not documented anywhere. Ideally it should be documented in the API docs and in the examples.

@asomers
Copy link
Author

asomers commented Aug 4, 2018

Also, it would be good to show an example of documenting the generated struct. Placing doc comments above the pub struct line seems to work.

@dzamlo
Copy link
Owner

dzamlo commented Aug 4, 2018

This is documented with the phrase "The syntax of this macro is the syntax of a tuple struct, including attributes and documentation comments, " on https://docs.rs/bitfield/0.13.0/bitfield/macro.bitfield.html for the struct and as the first element of list following "A field declaration is composed of the following:" on https://docs.rs/bitfield/0.13.0/bitfield/macro.bitfield_fields.html for the fields.

Do you think that adding that using that in the example would be enough to make it clear and discoverable ?

(as a side note, documentation comments are transformed into an attribute by the rust compiler before they reach the macro. This means that if you have a macro that support arbitrary attributes, it also support documentation comments)

@asomers
Copy link
Author

asomers commented Aug 4, 2018

The current documentation isn't very clear. I didn't realize that I could attach attributes until I had read the source. Examples would be very helpful.

@JayKickliter
Copy link

I've been using this crate for about a year now, and also only just realized I could add attributes.

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

No branches or pull requests

3 participants