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

gpio, spi and i2c::master cleanup, smaller updates #3010

Merged
merged 6 commits into from
Jan 23, 2025

Conversation

playfulFence
Copy link
Contributor

@playfulFence playfulFence commented Jan 21, 2025

closes #2999 and does some progress towards #2623

@playfulFence playfulFence added the skip-changelog No changelog modification needed label Jan 21, 2025
/// ```rust, no_run
#[doc = crate::before_snippet!()]
/// # use esp_hal::gpio::Io;
/// let mut io = Io::new(peripherals.IO_MUX);
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Member

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?

@playfulFence playfulFence changed the title gpio and i2c::master cleanup, smaller updates gpio, spi and i2c::master cleanup, smaller updates Jan 22, 2025
esp-hal/src/gpio/mod.rs Outdated Show resolved Hide resolved
@@ -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
Copy link
Contributor

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

Copy link
Contributor Author

@playfulFence playfulFence Jan 22, 2025

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.

Copy link
Contributor Author

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

Copy link
Member

@MabezDev MabezDev left a 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.

/// ```rust, no_run
#[doc = crate::before_snippet!()]
/// # use esp_hal::gpio::Io;
/// let mut io = Io::new(peripherals.IO_MUX);
Copy link
Member

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
Copy link
Member

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 :)

esp-hal/src/i2c/master/mod.rs Outdated Show resolved Hide resolved
esp-hal/src/i2c/master/mod.rs Show resolved Hide resolved
esp-hal/src/spi/master.rs Show resolved Hide resolved
Copy link
Member

@MabezDev MabezDev left a 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!

Copy link
Contributor

@bjoernQ bjoernQ left a 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

@bugadani bugadani added this pull request to the merge queue Jan 23, 2025
Merged via the queue into esp-rs:main with commit fc2815b Jan 23, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog No changelog modification needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: move usage examples to corresponding functions/constructors where possible
4 participants