-
Notifications
You must be signed in to change notification settings - Fork 240
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
gpio
, spi
and i2c::master
cleanup, smaller updates
#3010
Conversation
esp-hal/src/gpio/mod.rs
Outdated
/// ```rust, no_run | ||
#[doc = crate::before_snippet!()] | ||
/// # use esp_hal::gpio::Io; | ||
/// let mut io = Io::new(peripherals.IO_MUX); |
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.
Oh come on, do we really need this?
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.
Meeh, no, but I can purely imagine someone struggling with something like "which peripheral should I put there" or such stuff 😆
I know, it hurts to see such simple things there, but I think it doesn't hurt us to have even such things with examples to avoid a potential handful of questions like the one I wrote above
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.
I know, it hurts to see such simple things there, but I think it doesn't hurt us to have even such things with examples to avoid a potential handful of questions like the one I wrote above
I understand the sentiment here, but I think we should try and let rustdoc do the heavy lifting for us here, https://docs.esp-rs.org/esp-hal/esp-hal/0.23.1/esp32c6/esp_hal/gpio/struct.Io.html gives a clickable link to the IO_MUX
type, which shows where it comes from. If we follow this practice on every API item we're going to have more doc comments than code I think.
Would you mind removing this one?
3733c9b
to
5c86c0c
Compare
gpio
and i2c::master
cleanup, smaller updatesgpio
, spi
and i2c::master
cleanup, smaller updates
esp-hal/src/gpio/mod.rs
Outdated
@@ -1319,8 +1353,9 @@ impl<'d> Input<'d> { | |||
/// otherwise your program will be stuck in a loop as long as the pin is | |||
/// reading the corresponding level. | |||
/// | |||
/// ## Example: print something when a button is pressed. | |||
/// ## Example |
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.
If you're splitting out the title into a subsection, call this Examples
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.
There's only one example, so # Examples
wouldn't be suitable here (? 🤷🏼 ). I just made it follow the “format” that is used everywhere in the driver.
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.
Or, actually, we can just replace every occurrence of # Example
with # Examples
to be more consistent
a559080
to
3c1236a
Compare
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.
Thanks for looking into this! I think there are some nice improvements here, just a bit bits to address.
esp-hal/src/gpio/mod.rs
Outdated
/// ```rust, no_run | ||
#[doc = crate::before_snippet!()] | ||
/// # use esp_hal::gpio::Io; | ||
/// let mut io = Io::new(peripherals.IO_MUX); |
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.
I know, it hurts to see such simple things there, but I think it doesn't hurt us to have even such things with examples to avoid a potential handful of questions like the one I wrote above
I understand the sentiment here, but I think we should try and let rustdoc do the heavy lifting for us here, https://docs.esp-rs.org/esp-hal/esp-hal/0.23.1/esp32c6/esp_hal/gpio/struct.Io.html gives a clickable link to the IO_MUX
type, which shows where it comes from. If we follow this practice on every API item we're going to have more doc comments than code I think.
Would you mind removing this one?
@@ -1426,6 +1470,14 @@ impl<'d> Input<'d> { | |||
/// | |||
/// The output signal can be passed to peripherals in place of an output | |||
/// pin. | |||
/// ```rust, no_run |
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.
I'm not so sure about these GPIO doc comments, they seem to, on some level repeat themselves. Perhaps we should just document split
, and leave the rest? Or maybe we can reference split in the other API items.
Not that stress about this at the moment though, as these are unstable APIs :)
3c1236a
to
f57158e
Compare
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.
My concerns have been addressed, thanks!
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.
We can always improve on docs, I guess but this is already an improvement
closes #2999 and does some progress towards #2623