Merge pull request #85 from yaahc/unstable-features

Add doc_cfg attributes for conditional portions of the API
This commit is contained in:
Austin Bonander 2020-01-27 16:04:18 -08:00 committed by GitHub
commit 214467841d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 1 deletions

2
Cargo.lock generated
View file

@ -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)",
]

View file

@ -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" ]

View file

@ -148,6 +148,7 @@ impl From<ProtocolError<'_>> for Error {
}
#[cfg(feature = "tls")]
#[cfg_attr(docsrs, doc(cfg(feature = "tls")))]
impl From<async_native_tls::Error> for Error {
#[inline]
fn from(err: async_native_tls::Error) -> Self {

View file

@ -40,6 +40,7 @@ impl MaybeTlsStream {
}
#[cfg(feature = "tls")]
#[cfg_attr(docsrs, doc(cfg(feature = "tls")))]
pub async fn upgrade(
&mut self,
url: &Url,

View file

@ -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;

View file

@ -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};
}

View file

@ -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")]

View file

@ -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]