Skip to content

Commit 0ccd6f9

Browse files
committed
improve docs of generated library
1 parent c94dc77 commit 0ccd6f9

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
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
1313
- Some fixes for the `svd2rust-regress` tool and update of its documentation
14+
- Added `#![cfg_attr(docsrs, feature(doc_auto_cfg))]` to the generated library code. This
15+
adds a display of the feature gates in the documentation of the generated library
1416

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

src/generate/device.rs

+1
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

+17
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)