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

improve docs of generated library #899

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
- Some fixes for the `svd2rust-regress` tool and update of its documentation
- Other internal clippy fixes for `clippy::manual_div_ceil`, `clippy::nonminimal_bool` and
`clippy::needless_lifetimes`
- Added `#![cfg_attr(docsrs, feature(doc_auto_cfg))]` to the generated library code. This
adds a display of the feature gates in the documentation of the generated library

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

Expand Down
1 change: 1 addition & 0 deletions src/generate/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![no_std]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
});
}

Expand Down
17 changes: 17 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,23 @@
//! v-trap = ["rt", "riscv-rt/v-trap"]
//! ```
//!
//! ## Generating documentation
//!
//! You can generate the documentation for the generated library using the following command:
//!
//! ```sh
//! RUSTDOCFLAGS="--cfg docsrs --generate-link-to-definition -Z unstable-options" cargo +nightly doc --all-features --open
//! ```
//!
//! It is recommended to add the following block in the `Cargo.toml` of the generated library
//! if you plan to host the library documentaion on `docs.rs`
//!
//! ```toml
//! [package.metadata.docs.rs]
//! all-features = true
//! rustdoc-args = ["--generate-link-to-definition"]
//! ```
//!
//! # Peripheral API
//!
//! To use a peripheral first you must get an *instance* of the peripheral. All the device
Expand Down