NeoBirth / accelerometer.rs

Generic Rust accelerometer support, including traits and types for taking readings from 2 or 3-axis accelerometers
Apache License 2.0
26 stars 10 forks source link

Add defmt support and highlight crate features in docs.rs #70

Open sunsided opened 4 months ago

sunsided commented 4 months ago

This adds support for defmt via the defmt feature flag. This mainly brings defmt to the error types, but also adds it to Orientation.

To improve documentation, I added a rustdoc conditional feature for highlighting gated feature. All of the defmt::Format implementations could have been simply derived with a cfg_attr, but it doesn't work smoothly with the #[cfg_attr(docsrs, doc(...))] annotation.

To test documentation, you can run:

RUSTDOCFLAGS='--cfg docsrs' cargo +nightly doc --open --all-features

It should render like this:

image

sunsided commented 4 months ago

Since you're using micromath, I added a PR for defmt support there as well (https://github.com/tarcieri/micromath/pull/108). If that happens, I'll come back and forward the feature.