From 8f9bcd3a65b8ad49594db1c80b21d783c9f79cb8 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Fri, 17 Apr 2020 14:01:57 +0200 Subject: [PATCH] Make docsrs show items for all features with indicators what needs to be enabled to use each conditional item --- Cargo.toml | 4 ++++ src/device_id.rs | 1 + src/event_id.rs | 1 + src/lib.rs | 2 ++ src/room_id.rs | 1 + src/user_id.rs | 1 + 6 files changed, 10 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index bcaf4d11..a714c398 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,10 @@ repository = "https://github.com/ruma/ruma-identifiers" version = "0.14.1" edition = "2018" +[package.metadata.docs.rs] +features = ["all"] +rustdoc-args = ["--cfg", "docsrs"] + [features] default = ["serde"] diff --git a/src/device_id.rs b/src/device_id.rs index 8ee95378..d526f066 100644 --- a/src/device_id.rs +++ b/src/device_id.rs @@ -11,6 +11,7 @@ pub type DeviceId = String; /// Generates a random `DeviceId`, suitable for assignment to a new device. #[cfg(feature = "rand")] +#[cfg_attr(docsrs, doc(cfg(feature = "rand")))] pub fn generate() -> DeviceId { generate_localpart(8) } diff --git a/src/event_id.rs b/src/event_id.rs index b93688d6..e0af1492 100644 --- a/src/event_id.rs +++ b/src/event_id.rs @@ -56,6 +56,7 @@ impl EventId { /// Does not currently ever fail, but may fail in the future if the homeserver cannot be parsed /// parsed as a valid host. #[cfg(feature = "rand")] + #[cfg_attr(docsrs, doc(cfg(feature = "rand")))] pub fn new(server_name: &str) -> Result { use crate::{generate_localpart, is_valid_server_name}; diff --git a/src/lib.rs b/src/lib.rs index c008e968..1f044b51 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,6 +9,7 @@ )] // Since we support Rust 1.36.0, we can't apply this suggestion yet #![allow(clippy::use_self)] +#![cfg_attr(docsrs, feature(doc_cfg))] #[cfg(feature = "diesel")] #[cfg_attr(feature = "diesel", macro_use)] @@ -31,6 +32,7 @@ mod macros; pub mod device_id; #[cfg(feature = "diesel")] +#[cfg_attr(docsrs, doc(cfg(feature = "diesel")))] mod diesel_integration; mod error; mod event_id; diff --git a/src/room_id.rs b/src/room_id.rs index 9d2ae762..88fb82fe 100644 --- a/src/room_id.rs +++ b/src/room_id.rs @@ -34,6 +34,7 @@ impl RoomId { /// /// Fails if the given homeserver cannot be parsed as a valid host. #[cfg(feature = "rand")] + #[cfg_attr(docsrs, doc(cfg(feature = "rand")))] pub fn new(server_name: &str) -> Result { use crate::{generate_localpart, is_valid_server_name}; diff --git a/src/user_id.rs b/src/user_id.rs index 19aec566..e504e47d 100644 --- a/src/user_id.rs +++ b/src/user_id.rs @@ -40,6 +40,7 @@ impl UserId { /// /// Fails if the given homeserver cannot be parsed as a valid host. #[cfg(feature = "rand")] + #[cfg_attr(docsrs, doc(cfg(feature = "rand")))] pub fn new(server_name: &str) -> Result { use crate::generate_localpart;