diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c4c3c6..314692d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,12 +57,20 @@ jobs: components: rustfmt - run: cargo fmt --all --check + doc: + name: Documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + - run: cargo rustdoc -- --cfg docsrs + # One job that "summarizes" the success state of this pipeline. This can then be added to branch # protection, rather than having to add each job separately. success: name: Success runs-on: ubuntu-latest - needs: [test, no_std, clippy, fmt] + needs: [test, no_std, clippy, fmt, doc] # Github branch protection is exceedingly silly and treats "jobs skipped because a dependency # failed" as success. So we have to do some contortions to ensure the job fails if any of its # dependencies fails. diff --git a/Cargo.lock b/Cargo.lock index 01a1a8c..18764f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,4 +4,4 @@ version = 4 [[package]] name = "num-primitive" -version = "0.1.0" +version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index e8afc31..bdf3ce8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "num-primitive" -version = "0.1.0" +version = "0.1.1" description = "Traits for primitive numeric types" repository = "https://github.com/rust-num/num-primitive" license = "MIT OR Apache-2.0" @@ -14,12 +14,17 @@ default = ["std"] std = [] [lints.rust] +missing-docs = "deny" private-bounds = "deny" private-interfaces = "deny" unconditional-recursion = "deny" unnameable-types = "deny" unreachable-pub = "deny" +[lints.rustdoc] +broken-intra-doc-links = "deny" +private-intra-doc-links = "deny" + [package.metadata.release] allow-branch = ["main"] sign-tag = true diff --git a/RELEASES.md b/RELEASES.md index cb49bb2..3ce1a74 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,7 @@ +# Release 0.1.1 (2025-12-11) + +- Link documentation to inherent methods. + # Release 0.1.0 (2025-12-09) - Initial release with MSRV 1.85. diff --git a/src/float.rs b/src/float.rs index c1d2769..b9133df 100644 --- a/src/float.rs +++ b/src/float.rs @@ -485,6 +485,7 @@ macro_rules! impl_float { // NOTE: This is still effectively forwarding, but we need some indirection // to avoid naming the unstable `core::convert::FloatToInt`. + #[doc = forward_doc!(to_int_unchecked)] #[inline] unsafe fn to_int_unchecked(self) -> Int where diff --git a/src/macros.rs b/src/macros.rs index ad95660..7083d01 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1,24 +1,28 @@ /// Forward a method to an inherent method macro_rules! forward { ($(fn $method:ident ( self $( , $arg:ident : $ty:ty )* ) -> $ret:ty ; )*) => {$( + #[doc = forward_doc!($method)] #[inline] fn $method(self $( , $arg : $ty )* ) -> $ret { Self::$method(self $( , $arg )* ) } )*}; ($(fn $method:ident ( &self $( , $arg:ident : $ty:ty )* ) -> $ret:ty ; )*) => {$( + #[doc = forward_doc!($method)] #[inline] fn $method(&self $( , $arg : $ty )* ) -> $ret { Self::$method(self $( , $arg )* ) } )*}; ($(fn $method:ident ( $( $arg:ident : $ty:ty ),* ) -> $ret:ty ; )*) => {$( + #[doc = forward_doc!($method)] #[inline] fn $method($( $arg : $ty ),* ) -> $ret { Self::$method($( $arg ),* ) } )*}; ($(unsafe fn $method:ident ( self $( , $arg:ident : $ty:ty )* ) -> $ret:ty ; )*) => {$( + #[doc = forward_doc!($method)] #[inline] unsafe fn $method(self $( , $arg : $ty )* ) -> $ret { // SAFETY: we're just passing through here! @@ -27,6 +31,19 @@ macro_rules! forward { )*}; } +/// A string suitable for method `#[doc = ...]` +macro_rules! forward_doc { + ($method:ident) => { + concat!( + "See the inherent [`", + stringify!($method), + "`][Self::", + stringify!($method), + "] method." + ) + }; +} + /// Declare a `const` that copies an original value macro_rules! use_consts { ($base:ident :: { $( $name:ident : $ty:ty ,)+ }) => {