Skip to content

Commit

Permalink
Fix non-hidden docs on docs.rs (#280, #276, #278)
Browse files Browse the repository at this point in the history
- Do not import traits when building on `docs.rs` (fixes #276).
- Use `macro@` prefix for README intra-doc links to disambiguate them
with traits (fixes #278).

The result can be checked by running the command reproducing `docs.rs`
build nearly:
```bash
RUSTDOCFLAGS='--cfg docsrs' cargo rustdoc -p derive_more --features full --open
```

Additionally:
- fix crate version in README

Co-authored-by: Jelte Fennema <github-tech@jeltef.nl>
  • Loading branch information
tyranron and JelteF authored Jul 26, 2023
1 parent a45f7b2 commit f067867
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ in `Cargo.toml`:

```toml
[dependencies]
derive_more = "0.99.0"
derive_more = "=1.0.0-beta.3"
# You can specify the types of derives that you need for less time spent
# compiling. For the full list of features see this crate its `Cargo.toml`.
features = ["from", "add", "iterator"]
Expand Down
51 changes: 25 additions & 26 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
// These links overwrite the ones in `README.md`
// to become proper intra-doc links in Rust docs.
//! [`From`]: crate::From
//! [`Into`]: crate::Into
//! [`FromStr`]: crate::FromStr
//! [`TryInto`]: crate::TryInto
//! [`IntoIterator`]: crate::IntoIterator
//! [`AsRef`]: crate::AsRef
//! [`From`]: macro@crate::From
//! [`Into`]: macro@crate::Into
//! [`FromStr`]: macro@crate::FromStr
//! [`TryInto`]: macro@crate::TryInto
//! [`IntoIterator`]: macro@crate::IntoIterator
//! [`AsRef`]: macro@crate::AsRef
//!
//! [`Debug`]: crate::Debug
//! [`Display`-like]: crate::Display
//! [`Debug`]: macro@crate::Debug
//! [`Display`-like]: macro@crate::Display
//!
//! [`Error`]: crate::Error
//! [`Error`]: macro@crate::Error
//!
//! [`Index`]: crate::Index
//! [`Deref`]: crate::Deref
//! [`Not`-like]: crate::Not
//! [`Add`-like]: crate::Add
//! [`Mul`-like]: crate::Mul
//! [`Sum`-like]: crate::Sum
//! [`IndexMut`]: crate::IndexMut
//! [`DerefMut`]: crate::DerefMut
//! [`AddAssign`-like]: crate::AddAssign
//! [`MulAssign`-like]: crate::MulAssign
//! [`Index`]: macro@crate::Index
//! [`Deref`]: macro@crate::Deref
//! [`Not`-like]: macro@crate::Not
//! [`Add`-like]: macro@crate::Add
//! [`Mul`-like]: macro@crate::Mul
//! [`Sum`-like]: macro@crate::Sum
//! [`IndexMut`]: macro@crate::IndexMut
//! [`DerefMut`]: macro@crate::DerefMut
//! [`AddAssign`-like]: macro@crate::AddAssign
//! [`MulAssign`-like]: macro@crate::MulAssign
//!
//! [`Constructor`]: crate::Constructor
//! [`IsVariant`]: crate::IsVariant
//! [`Unwrap`]: crate::Unwrap
//! [`TryUnwrap`]: crate::TryUnwrap
//! [`Constructor`]: macro@crate::Constructor
//! [`IsVariant`]: macro@crate::IsVariant
//! [`Unwrap`]: macro@crate::Unwrap
//! [`TryUnwrap`]: macro@crate::TryUnwrap

// The README includes doctests requiring these features. To make sure that
// tests pass when not all features are provided we exclude it when the
Expand Down Expand Up @@ -97,15 +97,14 @@ pub use self::try_unwrap::TryUnwrapError;
// derive.
macro_rules! re_export_traits((
$feature:literal, $new_module_name:ident, $module:path $(, $traits:ident)* $(,)?) => {
#[cfg(feature = $feature)]
#[cfg(all(feature = $feature, any(not(docsrs), ci)))]
mod $new_module_name {
pub use $module::{$($traits),*};
}

#[cfg(feature = $feature)]
#[cfg(all(feature = $feature, any(not(docsrs), ci)))]
#[doc(hidden)]
pub use crate::$new_module_name::*;

}
);

Expand Down

0 comments on commit f067867

Please sign in to comment.