diff --git a/Cargo.toml b/Cargo.toml index 5ff51eb5..fb572048 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ frunk- = ["frunk"] macros = ["teloxide-macros"] -nightly = [] # currently used only for `README.md` tests +nightly = [] # currently used for `README.md` tests and building docs for `docsrs` to add `This is supported on feature="..." only.` [dependencies] serde_json = "1.0.55" @@ -68,8 +68,9 @@ pretty_env_logger = "0.4.0" lazy_static = "1.4.0" tokio = { version = "0.2.21", features = ["fs", "stream", "rt-threaded", "macros"] } -[package.metadata."docs.rs"] +[package.metadata.docs.rs] all-features = true +rustdoc-args = ["--cfg", "docsrs"] [[test]] name = "redis" diff --git a/src/bot/download.rs b/src/bot/download.rs index 7035cfe7..0dec6543 100644 --- a/src/bot/download.rs +++ b/src/bot/download.rs @@ -56,6 +56,8 @@ impl Bot { /// [`tokio::fs::File`]: tokio::fs::File /// [`Bot::download_file`]: crate::Bot::download_file #[cfg(feature = "unstable-stream")] + // FIXME(waffle): use `docsrs` here when issue with combine is resolved + #[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "unstable-stream")))] pub async fn download_file_stream( &self, path: &str, diff --git a/src/dispatching/dialogue/mod.rs b/src/dispatching/dialogue/mod.rs index 00bdc6cf..883e6c8f 100644 --- a/src/dispatching/dialogue/mod.rs +++ b/src/dispatching/dialogue/mod.rs @@ -158,10 +158,13 @@ pub use transition::{ }; #[cfg(feature = "macros")] -#[cfg_attr(all(docsrs, feature = "nightly"), doc(cfg(feature = "macros")))] +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "macros")))] pub use teloxide_macros::Transition; #[cfg(feature = "redis-storage")] +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "redis-storage")))] pub use storage::{RedisStorage, RedisStorageError}; pub use storage::{serializer, InMemStorage, Serializer, Storage}; diff --git a/src/dispatching/dialogue/storage/mod.rs b/src/dispatching/dialogue/storage/mod.rs index ed5319c8..ab8181cf 100644 --- a/src/dispatching/dialogue/storage/mod.rs +++ b/src/dispatching/dialogue/storage/mod.rs @@ -9,6 +9,8 @@ use futures::future::BoxFuture; pub use in_mem_storage::InMemStorage; #[cfg(feature = "redis-storage")] +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "redis-storage")))] pub use redis_storage::{RedisStorage, RedisStorageError}; pub use serializer::Serializer; use std::sync::Arc; diff --git a/src/dispatching/dialogue/storage/serializer.rs b/src/dispatching/dialogue/storage/serializer.rs index 20fa4841..16ce266a 100644 --- a/src/dispatching/dialogue/storage/serializer.rs +++ b/src/dispatching/dialogue/storage/serializer.rs @@ -32,9 +32,13 @@ where /// /// [CBOR]: https://en.wikipedia.org/wiki/CBOR #[cfg(feature = "cbor-serializer")] +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "cbor-serializer")))] pub struct CBOR; #[cfg(feature = "cbor-serializer")] +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "cbor-serializer")))] impl Serializer for CBOR where D: Serialize + DeserializeOwned, @@ -54,9 +58,13 @@ where /// /// [Bincode]: https://github.com/servo/bincode #[cfg(feature = "bincode-serializer")] +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "bincode-serializer")))] pub struct Bincode; #[cfg(feature = "bincode-serializer")] +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "bincode-serializer")))] impl Serializer for Bincode where D: Serialize + DeserializeOwned, diff --git a/src/lib.rs b/src/lib.rs index 08ffe910..8639abd6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,7 +41,15 @@ #![allow(clippy::match_bool)] #![forbid(unsafe_code)] #![cfg_attr(all(feature = "nightly", doctest), feature(external_doc))] -#![cfg_attr(all(docsrs, feature = "nightly"), feature(doc_cfg))] +// we pass "--cfg docsrs" when building docs to add `This is supported on feature="..." only.` +// +// To properly build docs of this crate run +// ```console +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +// $ RUSTDOCFLAGS="--cfg teloxide_docsrs" cargo +nightly doc --open --all-features +// ``` +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#![cfg_attr(all(teloxide_docsrs, feature = "nightly"), feature(doc_cfg))] pub use bot::{Bot, BotBuilder}; pub use dispatching::repls::{ @@ -63,10 +71,8 @@ pub mod types; pub mod utils; #[cfg(feature = "macros")] -extern crate teloxide_macros; - -#[cfg(feature = "macros")] -#[cfg_attr(all(docsrs, feature = "nightly"), doc(cfg(feature = "macros")))] +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "macros")))] pub use teloxide_macros::teloxide; #[cfg(all(feature = "nightly", doctest))] diff --git a/src/net/download.rs b/src/net/download.rs index 05f08f5d..6f9c87b0 100644 --- a/src/net/download.rs +++ b/src/net/download.rs @@ -28,6 +28,8 @@ where } #[cfg(feature = "unstable-stream")] +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "unstable-stream")))] pub async fn download_file_stream( client: &Client, token: &str, diff --git a/src/net/mod.rs b/src/net/mod.rs index b4944959..118b6036 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -1,4 +1,6 @@ #[cfg(feature = "unstable-stream")] +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "unstable-stream")))] pub use download::download_file_stream; pub use self::{ diff --git a/src/prelude.rs b/src/prelude.rs index a7ce757e..61773b4e 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -15,6 +15,8 @@ pub use crate::{ }; #[cfg(feature = "frunk")] +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "frunk")))] pub use crate::utils::UpState; pub use tokio::sync::mpsc::UnboundedReceiver; diff --git a/src/utils/command.rs b/src/utils/command.rs index a2bd4c22..5e9c034d 100644 --- a/src/utils/command.rs +++ b/src/utils/command.rs @@ -50,7 +50,8 @@ use serde::export::Formatter; use std::{error::Error, fmt::Display}; #[cfg(feature = "macros")] -#[cfg_attr(all(docsrs, feature = "nightly"), doc(cfg(feature = "macros")))] +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "macros")))] pub use teloxide_macros::BotCommand; /// An enumeration of bot's commands. diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 6882383b..e20a7a81 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -9,4 +9,6 @@ mod up_state; pub use client_from_env::client_from_env; #[cfg(feature = "frunk")] +// FIXME(waffle): use `docsrs` here when issue with combine is resolved +#[cfg_attr(all(teloxide_docsrs, feature = "nightly"), doc(cfg(feature = "frunk")))] pub use up_state::UpState;