diff --git a/Cargo.lock b/Cargo.lock index 3ef160a54..36fc825ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1711,7 +1711,7 @@ dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)", - "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.toml b/Cargo.toml index 300f64431..6b55257e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ authors = [ [package.metadata.docs.rs] features = [ "tls", "postgres", "mysql", "uuid", "chrono" ] +rustdoc-args = ["--cfg", "docsrs"] [features] default = [ "macros", "runtime-async-std" ] diff --git a/sqlx-core/src/error.rs b/sqlx-core/src/error.rs index f3d0244a2..4a1f19394 100644 --- a/sqlx-core/src/error.rs +++ b/sqlx-core/src/error.rs @@ -148,6 +148,7 @@ impl From> for Error { } #[cfg(feature = "tls")] +#[cfg_attr(docsrs, doc(cfg(feature = "tls")))] impl From for Error { #[inline] fn from(err: async_native_tls::Error) -> Self { diff --git a/sqlx-core/src/io/tls.rs b/sqlx-core/src/io/tls.rs index 233997540..0e5f136f5 100644 --- a/sqlx-core/src/io/tls.rs +++ b/sqlx-core/src/io/tls.rs @@ -40,6 +40,7 @@ impl MaybeTlsStream { } #[cfg(feature = "tls")] + #[cfg_attr(docsrs, doc(cfg(feature = "tls")))] pub async fn upgrade( &mut self, url: &Url, diff --git a/sqlx-core/src/lib.rs b/sqlx-core/src/lib.rs index 5e6048f18..8eaffa5e5 100644 --- a/sqlx-core/src/lib.rs +++ b/sqlx-core/src/lib.rs @@ -1,5 +1,6 @@ #![recursion_limit = "256"] #![forbid(unsafe_code)] +#![cfg_attr(docsrs, feature(doc_cfg))] #[macro_use] pub mod error; @@ -37,9 +38,11 @@ pub mod types; pub mod row; #[cfg(feature = "mysql")] +#[cfg_attr(docsrs, doc(cfg(feature = "mysql")))] pub mod mysql; #[cfg(feature = "postgres")] +#[cfg_attr(docsrs, doc(cfg(feature = "postgres")))] pub mod postgres; pub use database::Database; @@ -63,9 +66,11 @@ pub use pool::Pool; pub use row::{FromRow, Row}; #[cfg(feature = "mysql")] +#[cfg_attr(docsrs, doc(cfg(feature = "mysql")))] #[doc(inline)] pub use mysql::MySql; #[cfg(feature = "postgres")] +#[cfg_attr(docsrs, doc(cfg(feature = "postgres")))] #[doc(inline)] pub use postgres::Postgres; diff --git a/sqlx-core/src/types.rs b/sqlx-core/src/types.rs index 7a52ccfd2..b8371a940 100644 --- a/sqlx-core/src/types.rs +++ b/sqlx-core/src/types.rs @@ -5,9 +5,11 @@ use std::fmt::{Debug, Display}; use crate::Database; #[cfg(feature = "uuid")] +#[cfg_attr(docsrs, doc(cfg(feature = "uuid")))] pub use uuid::Uuid; #[cfg(feature = "chrono")] +#[cfg_attr(docsrs, doc(cfg(feature = "chrono")))] pub mod chrono { pub use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc}; } diff --git a/src/lib.rs b/src/lib.rs index 46e5e8bb3..f9ccab40f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ #![allow(dead_code)] +#![cfg_attr(docsrs, feature(doc_cfg))] #[cfg(not(any(feature = "runtime-tokio", feature = "runtime-async-std")))] compile_error!("one of 'runtime-async-std' or 'runtime-tokio' features must be enabled"); @@ -21,9 +22,11 @@ pub use sqlx_core::{query, query_as}; pub use sqlx_core::query_as_mapped; #[cfg(feature = "mysql")] +#[cfg_attr(docsrs, doc(cfg(feature = "mysql")))] pub use sqlx_core::mysql::{self, MySql, MySqlConnection, MySqlPool}; #[cfg(feature = "postgres")] +#[cfg_attr(docsrs, doc(cfg(feature = "postgres")))] pub use sqlx_core::postgres::{self, PgConnection, PgPool, Postgres}; #[cfg(feature = "macros")] diff --git a/src/macros.rs b/src/macros.rs index 54cb6d782..35f911fd4 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -83,6 +83,7 @@ /// * [query_file!] if you want to define the SQL query out-of-line, /// * [query_file_as!] if you want both of the above. #[macro_export] +#[cfg_attr(docsrs, doc(cfg(feature = "macros")))] macro_rules! query ( // by emitting a macro definition from our proc-macro containing the result tokens, // we no longer have a need for `proc-macro-hack` @@ -145,6 +146,7 @@ macro_rules! query ( /// # fn main() {} /// ``` #[macro_export] +#[cfg_attr(docsrs, doc(cfg(feature = "macros")))] macro_rules! query_file ( ($query:literal) => (#[allow(dead_code)]{ #[macro_use] @@ -210,6 +212,7 @@ macro_rules! query_file ( /// # fn main() {} /// ``` #[macro_export] +#[cfg_attr(docsrs, doc(cfg(feature = "macros")))] macro_rules! query_as ( ($out_struct:path, $query:literal) => (#[allow(dead_code)] { #[macro_use] @@ -260,6 +263,7 @@ macro_rules! query_as ( /// # fn main() {} /// ``` #[macro_export] +#[cfg_attr(docsrs, doc(cfg(feature = "macros")))] macro_rules! query_file_as ( ($out_struct:path, $query:literal) => (#[allow(dead_code)] { #[macro_use]