From d4e31f07a11e724c9ebbcbb0f7ea4729e9f666b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 13 Aug 2020 12:18:24 +0200 Subject: [PATCH] matrix-sdk: Fix the docs for our feature flags. --- matrix_sdk/Cargo.toml | 7 +++++++ matrix_sdk/src/client.rs | 17 +++++++++-------- matrix_sdk/src/lib.rs | 6 ++++++ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/matrix_sdk/Cargo.toml b/matrix_sdk/Cargo.toml index dac12605..44888611 100644 --- a/matrix_sdk/Cargo.toml +++ b/matrix_sdk/Cargo.toml @@ -10,12 +10,19 @@ readme = "README.md" repository = "https://github.com/matrix-org/matrix-rust-sdk" version = "0.1.0" +[package.metadata.docs.rs] +features = ["docs"] +rustdoc-args = ["--cfg", "feature=\"docs\""] + [features] default = ["encryption", "sqlite_cryptostore", "messages"] + messages = ["matrix-sdk-base/messages"] encryption = ["matrix-sdk-base/encryption", "dashmap"] sqlite_cryptostore = ["matrix-sdk-base/sqlite_cryptostore"] +docs = ["encryption", "sqlite_cryptostore", "messages"] + [dependencies] async-trait = "0.1.36" dashmap = { version = "3.11.10", optional = true } diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index f8a910ad..b4fb25d0 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -953,6 +953,7 @@ impl Client { /// /// Does nothing if no group session needs to be shared. #[cfg(feature = "encryption")] + #[cfg_attr(feature = "docs", doc(cfg(encryption)))] async fn preshare_group_session(&self, room_id: &RoomId) -> Result<()> { // TODO expose this publicly so people can pre-share a group session if // e.g. a user starts to type a message for a room. @@ -1318,7 +1319,7 @@ impl Client { /// Panics if the client isn't logged in, or if no encryption keys need to /// be uploaded. #[cfg(feature = "encryption")] - #[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] + #[cfg_attr(feature = "docs", doc(cfg(encryption)))] #[instrument] async fn claim_one_time_keys( &self, @@ -1347,7 +1348,7 @@ impl Client { /// /// Panics if the client isn't logged in. #[cfg(feature = "encryption")] - #[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] + #[cfg_attr(feature = "docs", doc(cfg(encryption)))] #[instrument] async fn share_group_session(&self, room_id: &RoomId) -> Result<()> { let mut requests = self @@ -1373,7 +1374,7 @@ impl Client { /// Panics if the client isn't logged in, or if no encryption keys need to /// be uploaded. #[cfg(feature = "encryption")] - #[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] + #[cfg_attr(feature = "docs", doc(cfg(encryption)))] #[instrument] async fn keys_upload(&self) -> Result { let request = self @@ -1407,7 +1408,7 @@ impl Client { /// /// Panics if no key query needs to be done. #[cfg(feature = "encryption")] - #[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] + #[cfg_attr(feature = "docs", doc(cfg(encryption)))] #[instrument] async fn keys_query(&self) -> Result { let mut users_for_query = self @@ -1443,7 +1444,7 @@ impl Client { /// Get a `Sas` verification object with the given flow id. #[cfg(feature = "encryption")] - #[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] + #[cfg_attr(feature = "docs", doc(cfg(encryption)))] pub async fn get_verification(&self, flow_id: &str) -> Option { self.base_client .get_verification(flow_id) @@ -1465,7 +1466,7 @@ impl Client { /// /// Returns a `Sas` object that represents the interactive verification flow. #[cfg(feature = "encryption")] - #[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] + #[cfg_attr(feature = "docs", doc(cfg(encryption)))] pub async fn start_verification(&self, device: Device) -> Result { let (sas, request) = self .base_client @@ -1513,7 +1514,7 @@ impl Client { /// # }); /// ``` #[cfg(feature = "encryption")] - #[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] + #[cfg_attr(feature = "docs", doc(cfg(encryption)))] pub async fn get_device(&self, user_id: &UserId, device_id: &DeviceId) -> Option { self.base_client.get_device(user_id, device_id).await } @@ -1546,7 +1547,7 @@ impl Client { /// # }); /// ``` #[cfg(feature = "encryption")] - #[cfg_attr(docsrs, doc(cfg(feature = "encryption")))] + #[cfg_attr(feature = "docs", doc(cfg(encryption)))] pub async fn get_user_devices( &self, user_id: &UserId, diff --git a/matrix_sdk/src/lib.rs b/matrix_sdk/src/lib.rs index cd9d866e..730b242c 100644 --- a/matrix_sdk/src/lib.rs +++ b/matrix_sdk/src/lib.rs @@ -35,6 +35,7 @@ unused_import_braces, unused_qualifications )] +#![cfg_attr(feature = "docs", feature(doc_cfg))] #[cfg(not(target_arch = "wasm32"))] pub use matrix_sdk_base::JsonStore; @@ -42,9 +43,13 @@ pub use matrix_sdk_base::{ CustomEvent, Error as BaseError, EventEmitter, Room, RoomState, Session, StateStore, SyncRoom, }; #[cfg(feature = "encryption")] +#[cfg_attr(feature = "docs", doc(cfg(encryption)))] pub use matrix_sdk_base::{Device, TrustState}; + #[cfg(feature = "messages")] +#[cfg_attr(feature = "docs", doc(cfg(messages)))] pub use matrix_sdk_base::{MessageQueue, PossiblyRedactedExt}; + pub use matrix_sdk_common::*; pub use reqwest::header::InvalidHeaderValue; @@ -63,6 +68,7 @@ pub use request_builder::{ MessagesRequestBuilder, RegistrationBuilder, RoomBuilder, RoomListFilterBuilder, }; #[cfg(feature = "encryption")] +#[cfg_attr(feature = "docs", doc(cfg(encryption)))] pub use sas::Sas; #[cfg(not(target_arch = "wasm32"))]