From a5a3a34a1a38be80b73bea2eb5202ed81a2b0bbe Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 1 Aug 2021 17:34:26 +0200 Subject: [PATCH 1/4] Run `cargo doc` in our CI job --- .github/workflows/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d99a2d820..cd7d224d9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,6 +65,11 @@ jobs: with: command: build + - name: "Run cargo doc" + uses: actions-rs/cargo@v1 + with: + command: doc + - name: "Run cargo build for stable without instructions" uses: actions-rs/cargo@v1 with: From acfa59c6b7bf1ec6b6c4165cd536e3ff1f5bbfc6 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sun, 1 Aug 2021 17:47:09 +0200 Subject: [PATCH 2/4] Use `#[cfg(doc)]` instead of docs.rs-specific cfg flag The documentation can also be built locally using `cargo doc --open`. Doc links should be working there as well. --- Cargo.toml | 3 --- src/instructions/segmentation.rs | 2 +- src/registers/control.rs | 2 +- src/registers/model_specific.rs | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c0f64c9f1..1bc113a86 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,9 +42,6 @@ inline_asm = [] abi_x86_interrupt = [] const_fn = [] -[package.metadata.docs.rs] -rustdoc-args = ["--cfg", "docsrs"] - [package.metadata.release] no-dev-version = true pre-release-replacements = [ diff --git a/src/instructions/segmentation.rs b/src/instructions/segmentation.rs index b5423095a..548a556da 100644 --- a/src/instructions/segmentation.rs +++ b/src/instructions/segmentation.rs @@ -1,6 +1,6 @@ //! Provides functions to read and write segment registers. -#[cfg(docsrs)] +#[cfg(doc)] use crate::{ registers::control::Cr4Flags, structures::gdt::{Descriptor, GlobalDescriptorTable}, diff --git a/src/registers/control.rs b/src/registers/control.rs index c55b55871..904be4100 100644 --- a/src/registers/control.rs +++ b/src/registers/control.rs @@ -1,7 +1,7 @@ //! Functions to read and write control registers. pub use super::model_specific::{Efer, EferFlags}; -#[cfg(docsrs)] +#[cfg(doc)] use crate::{registers::rflags::RFlags, structures::paging::PageTableFlags}; use bitflags::bitflags; diff --git a/src/registers/model_specific.rs b/src/registers/model_specific.rs index 073a08c4f..191ace54a 100644 --- a/src/registers/model_specific.rs +++ b/src/registers/model_specific.rs @@ -1,6 +1,6 @@ //! Functions to read and write model specific registers. -#[cfg(docsrs)] +#[cfg(doc)] use crate::{ instructions::segmentation::{Segment64, FS, GS}, registers::control::Cr4Flags, From 17ca2b07cdee30daf9ea4c5c7d271f2cb998b00b Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Fri, 13 Aug 2021 17:47:08 -0700 Subject: [PATCH 3/4] Add doc_cfg for annotations on nightly Signed-off-by: Joe Richey --- Cargo.toml | 3 ++- src/instructions/interrupts.rs | 5 ++++- src/instructions/mod.rs | 5 ++++- src/lib.rs | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1bc113a86..e476b63d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,10 +37,11 @@ cc = { version = "1.0.37", optional = true } default = [ "nightly", "instructions" ] instructions = [] external_asm = [ "cc" ] -nightly = [ "inline_asm", "const_fn", "abi_x86_interrupt" ] +nightly = [ "inline_asm", "const_fn", "abi_x86_interrupt", "doc_cfg" ] inline_asm = [] abi_x86_interrupt = [] const_fn = [] +doc_cfg = [] [package.metadata.release] no-dev-version = true diff --git a/src/instructions/interrupts.rs b/src/instructions/interrupts.rs index f1d171cf8..eee606ee9 100644 --- a/src/instructions/interrupts.rs +++ b/src/instructions/interrupts.rs @@ -153,7 +153,10 @@ pub fn int3() { /// immediate. This macro will be replaced by a generic function when support for /// const generics is implemented in Rust. #[cfg(feature = "inline_asm")] -#[cfg_attr(docsrs, doc(cfg(any(feature = "nightly", feature = "inline_asm"))))] +#[cfg_attr( + feature = "doc_cfg", + doc(cfg(any(feature = "nightly", feature = "inline_asm"))) +)] #[macro_export] macro_rules! software_interrupt { ($x:expr) => {{ diff --git a/src/instructions/mod.rs b/src/instructions/mod.rs index de1c4c3fa..27c42f17a 100644 --- a/src/instructions/mod.rs +++ b/src/instructions/mod.rs @@ -54,7 +54,10 @@ pub fn bochs_breakpoint() { /// Gets the current instruction pointer. Note that this is only approximate as it requires a few /// instructions to execute. #[cfg(feature = "inline_asm")] -#[cfg_attr(docsrs, doc(cfg(any(feature = "nightly", feature = "inline_asm"))))] +#[cfg_attr( + feature = "doc_cfg", + doc(cfg(any(feature = "nightly", feature = "inline_asm"))) +)] #[inline(always)] pub fn read_rip() -> crate::VirtAddr { let rip: u64; diff --git a/src/lib.rs b/src/lib.rs index cf146e31a..73a6c5061 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ #![cfg_attr(feature = "const_fn", feature(const_fn_trait_bound))] // PageSize marker trait #![cfg_attr(feature = "inline_asm", feature(asm))] #![cfg_attr(feature = "abi_x86_interrupt", feature(abi_x86_interrupt))] -#![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(feature = "doc_cfg", feature(doc_cfg))] #![warn(missing_docs)] #![deny(missing_debug_implementations)] From 5354b0243510a5f01138ad1c6b408d1d755f0c39 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Fri, 13 Aug 2021 17:52:23 -0700 Subject: [PATCH 4/4] CI: add cargo doc run using stable features Signed-off-by: Joe Richey --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd7d224d9..82e408a91 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,6 +70,13 @@ jobs: with: command: doc + - name: "Run cargo doc for stable" + uses: actions-rs/cargo@v1 + with: + command: doc + args: --no-default-features --features external_asm,instructions + if: runner.os != 'Windows' + - name: "Run cargo build for stable without instructions" uses: actions-rs/cargo@v1 with: