Skip to content

Commit 9776531

Browse files
committed
improve docs of generated library
1 parent 4ca8cfb commit 9776531

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
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
1616
- Other internal clippy fixes for `clippy::manual_div_ceil`, `clippy::nonminimal_bool` and
1717
`clippy::needless_lifetimes`
1818
- Update `svd-rs` to 0.14.11
19+
- Added `#![cfg_attr(docsrs, feature(doc_auto_cfg))]` to the generated library code. This
20+
adds a display of the feature gates in the documentation of the generated library
1921

2022
## [v0.35.0] - 2024-11-12
2123

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)