Skip to content

Commit b9e67af

Browse files
committed
improve docs of generated library
1 parent 07406a8 commit b9e67af

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
1010
- Force using rust edition 2021 in CI
1111
- Added lifetime ellision for `FieldWriter` where the explicit lifetimes are not necessary, which
1212
fixes the `clippy::needless_lifetimes` warning on rustc 1.84
13+
- Added `#![cfg_attr(docsrs, feature(doc_auto_cfg))]` to the generated library code. This
14+
adds a display of the feature gates in the documentation of the generated library
1315

1416
## [v0.35.0] - 2024-11-12
1517

src/generate/device.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
5959
#![allow(non_camel_case_types)]
6060
#![allow(non_snake_case)]
6161
#![no_std]
62+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
6263
});
6364
}
6465

src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,23 @@
171171
//! v-trap = ["rt", "riscv-rt/v-trap"]
172172
//! ```
173173
//!
174+
//! ## Generating documentation
175+
//!
176+
//! You can generate the documentation for the generated library using the following command:
177+
//!
178+
//! ```sh
179+
//! RUSTDOCFLAGS="--cfg docsrs --generate-link-to-definition -Z unstable-options" cargo +nightly doc --all-features --open
180+
//! ```
181+
//!
182+
//! It is recommended to add the following block in the `Cargo.toml` of the generated library
183+
//! if you plan to host the library documentaion on `docs.rs`
184+
//!
185+
//! ```toml
186+
//! [package.metadata.docs.rs]
187+
//! all-features = true
188+
//! rustdoc-args = ["--generate-link-to-definition"]
189+
//! ```
190+
//!
174191
//! # Peripheral API
175192
//!
176193
//! To use a peripheral first you must get an *instance* of the peripheral. All the device

0 commit comments

Comments
 (0)