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

arm: use docsplay::Display for ArmError #2702

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

ithinuel
Copy link
Contributor

This avoids duplication of the documentation

Follows:

ReAttachRequired,

/// An operation was not performed because the required permissions were not given.
/// An operation could not be performed because it lacked the permission to do so: {0}.
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a bit verbose to display as an error. You may add #[ignore_extra_doc_attributes] so that only the first line will be part of the error message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it’d do that by default.

Copy link
Contributor

Choose a reason for hiding this comment

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

displaydoc would IIRC simply fail in this situation, docsplay can handle all the docs you give it. Since the library is not only meant for error messages, it defaults to displaying everything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, I never used it before, I just saw it used in another module and figured this was a good way to reduce the amount of noise in the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's my fork of displaydoc because I had a few issues with it, but it's not perfect. The formatting placeholders can easily introduce inelegant noise into the documentation, and automatically trying to fix that is pretty hard.

@ithinuel ithinuel force-pushed the use-docsplay branch 3 times, most recently from b3a7762 to e7a9030 Compare July 25, 2024 20:21
@@ -0,0 +1 @@
Changed ArmError’s documentation to use docsplay::Display and avoid repetition
Copy link
Contributor

Choose a reason for hiding this comment

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

So, do you really want to keep 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.

I don’t mind either way. It was only to make GH checks happy :)

Copy link
Contributor

Choose a reason for hiding this comment

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

The changelog check is not important, there's a label to pacify it :)

pub enum ArmError {
/// The operation requires a specific architecture.
#[error("The operation requires one of the following architectures: {0:?}.")]
/// The operation requires one of the following architectures: {0:?}.
ArchitectureRequired(&'static [&'static str]),

/// A timeout occurred during an operation
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// A timeout occurred during an operation
/// A timeout occurred during an operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I also add a . after the other {0} ?

Copy link
Contributor

Choose a reason for hiding this comment

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

no, I think that would introduce double dots in some cases.

RegisterParse(#[from] RegisterParseError),

/// Error reading ROM table.
#[error("Error reading ROM table.")]
RomTable(#[source] RomTableError),

/// Failed to erase chip
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Failed to erase chip
/// Failed to erase chip.

@bugadani bugadani added this pull request to the merge queue Jul 25, 2024
Merged via the queue into probe-rs:master with commit 62ca9cd Jul 25, 2024
20 checks passed
@ithinuel ithinuel deleted the use-docsplay branch July 25, 2024 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:skip This PR does not require a changelog entry on release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants