Skip to content

Commit 76ffb2e

Browse files
minor: fix documentation of new features (#823)
1 parent a934349 commit 76ffb2e

File tree

7 files changed

+62
-51
lines changed

7 files changed

+62
-51
lines changed

.evergreen/check-rustdoc.sh

+4-7
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ source ./.evergreen/configure-rust.sh
1414
source ./.evergreen/feature-combinations.sh
1515

1616
# build with all available features to ensure all optional dependencies are brought in too.
17-
for ((i = 0; i < ${#FEATURE_COMBINATIONS[@]}; i++)); do
18-
cargo +nightly build ${FEATURE_COMBINATIONS[$i]}
19-
done
17+
cargo +nightly build $ADDITIONAL_FEATURES
2018
cargo clean
2119

2220
chmod -R 555 ${CARGO_HOME}/registry/src
2321

24-
for ((i = 0; i < ${#FEATURE_COMBINATIONS[@]}; i++)); do
25-
cargo +nightly rustdoc ${FEATURE_COMBINATIONS[$i]} -- -D warnings --cfg docsrs
26-
done
27-
22+
# this invocation mirrors the way docs.rs builds our documentation (see the [package.metadata.docs.rs] section
23+
# in Cargo.toml).
24+
cargo +nightly rustdoc $ADDITIONAL_FEATURES -- -D warnings --cfg docsrs

.evergreen/feature-combinations.sh

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
#!/bin/bash
22

3+
# Only default features.
4+
export NO_FEATURES=''
5+
# async-std-related features that conflict with the library's default features.
6+
export ASYNC_STD_FEATURES='--no-default-features --features async-std-runtime,sync'
7+
# All additional features that do not conflict with the default features. New features added to the library should also be added to this list.
8+
export ADDITIONAL_FEATURES='--features tokio-sync,zstd-compression,snappy-compression,zlib-compression,openssl-tls,aws-auth,tracing-unstable,in-use-encryption-unstable'
9+
10+
311
# Array of feature combinations that, in total, provides complete coverage of the driver.
412
# This is useful for linting tasks where we want to get coverage of all features.
513
# Since some of our features are mutually exclusive we cannot just use --all-features.
614
export FEATURE_COMBINATIONS=(
7-
'' # default features
8-
'--no-default-features --features async-std-runtime,sync' # features that conflict w/ default features
9-
'--features tokio-sync,zstd-compression,snappy-compression,zlib-compression,openssl-tls,aws-auth,tracing-unstable,in-use-encryption-unstable' # additive features
15+
"$NO_FEATURES"
16+
"$ASYNC_STD_FEATURES"
17+
"$ADDITIONAL_FEATURES"
1018
)

Cargo.toml

+17-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ exclude = [
2626
"tests/**",
2727
]
2828

29+
# NOTE: any new features added to this list should also be added to the features
30+
# list in the [package.metadata.docs.rs] section below.
2931
[features]
3032
default = ["tokio-runtime"]
3133
tokio-runtime = [
@@ -67,11 +69,12 @@ zstd-compression = ["zstd"]
6769
zlib-compression = ["flate2"]
6870
snappy-compression = ["snap"]
6971

72+
# Enables support for client-side field level encryption and queryable encryption.
7073
# The In Use Encryption API is unstable and may have backwards-incompatible changes in minor version updates.
7174
in-use-encryption-unstable = ["mongocrypt", "rayon", "num_cpus"]
7275

73-
# DO NOT USE; see https://jira.mongodb.org/browse/RUST-580 for the status of tracing/logging support in the Rust driver.
7476
# Enables support for emitting tracing events.
77+
# The tracing API is unstable and may have backwards-incompatible changes in minor version updates.
7578
# TODO: pending https://github.com/tokio-rs/tracing/issues/2036 stop depending directly on log.
7679
tracing-unstable = ["tracing", "log"]
7780

@@ -185,3 +188,16 @@ regex = "1.6.0"
185188

186189
[package.metadata.docs.rs]
187190
rustdoc-args = ["--cfg", "docsrs"]
191+
# async-std-runtime and sync are excluded here because they conflict with the default features.
192+
# Neither feature has any unique documentation associated with it, so we do not need to
193+
# include them in our documentation build.
194+
features = [
195+
"tokio-sync",
196+
"zstd-compression",
197+
"snappy-compression",
198+
"zlib-compression",
199+
"openssl-tls",
200+
"aws-auth",
201+
"tracing-unstable",
202+
"in-use-encryption-unstable"
203+
]

src/client/auth/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ pub enum AuthMechanism {
8282
///
8383
/// Note: Only server versions 4.4+ support AWS authentication. Additionally, the driver only
8484
/// supports AWS authentication with the tokio runtime.
85-
#[cfg(any(feature = "aws-auth", docsrs))]
86-
#[cfg_attr(docsrs, doc(cfg(feature = "aws-auth")))]
85+
#[cfg(feature = "aws-auth")]
8786
MongoDbAws,
8887
}
8988

src/client/options/mod.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,7 @@ pub struct ClientOptions {
536536
/// Note that in cases where truncation occurs the output will not be valid JSON.
537537
///
538538
/// The default value is 1000.
539-
#[cfg(any(feature = "tracing-unstable", docsrs))]
540-
#[cfg_attr(docsrs, doc(cfg(feature = "tracing-unstable")))]
539+
#[cfg(feature = "tracing-unstable")]
541540
#[builder(default)]
542541
pub tracing_max_document_length_bytes: Option<usize>,
543542

@@ -938,8 +937,7 @@ pub struct TlsOptions {
938937
/// is invalid.
939938
///
940939
/// The default value is to error on invalid hostnames.
941-
#[cfg(any(feature = "openssl-tls", docsrs))]
942-
#[cfg_attr(docsrs, doc(cfg(feature = "openssl-tls")))]
940+
#[cfg(feature = "openssl-tls")]
943941
pub allow_invalid_hostnames: Option<bool>,
944942
}
945943

@@ -1072,8 +1070,7 @@ impl ClientOptions {
10721070

10731071
/// This method will be present if the `sync` feature is enabled. It's otherwise identical to
10741072
/// [the async version](#method.parse)
1075-
#[cfg(any(feature = "sync", feature = "tokio-sync", docsrs))]
1076-
#[cfg_attr(docsrs, doc(cfg(any(feature = "sync", feature = "tokio-sync"))))]
1073+
#[cfg(any(feature = "sync", feature = "tokio-sync"))]
10771074
pub fn parse(s: impl AsRef<str>) -> Result<Self> {
10781075
runtime::block_on(Self::parse_uri(s.as_ref(), None))
10791076
}
@@ -1102,8 +1099,7 @@ impl ClientOptions {
11021099

11031100
/// This method will be present if the `sync` feature is enabled. It's otherwise identical to
11041101
/// [the async version](#method.parse_with_resolver_config)
1105-
#[cfg(any(feature = "sync", feature = "tokio-sync", docsrs))]
1106-
#[cfg_attr(docsrs, doc(cfg(any(feature = "sync", feature = "tokio-sync"))))]
1102+
#[cfg(any(feature = "sync", feature = "tokio-sync"))]
11071103
pub fn parse_with_resolver_config(uri: &str, resolver_config: ResolverConfig) -> Result<Self> {
11081104
runtime::block_on(Self::parse_uri(uri, Some(resolver_config)))
11091105
}

src/compression/mod.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,21 @@ impl CompressorId {
6565
pub enum Compressor {
6666
/// Zstd compressor. Requires Rust version 1.54.
6767
/// See [`Zstd`](http://facebook.github.io/zstd/zstd_manual.html) for more information
68-
#[cfg(any(feature = "zstd-compression", docsrs))]
69-
#[cfg_attr(docsrs, doc(cfg(feature = "zstd-compression")))]
68+
#[cfg(feature = "zstd-compression")]
7069
Zstd {
7170
/// Zstd compression level
7271
level: Option<i32>,
7372
},
7473
/// Zlib compressor.
7574
/// See [`Zlib`](https://zlib.net/) for more information.
76-
#[cfg(any(feature = "zlib-compression", docsrs))]
77-
#[cfg_attr(docsrs, doc(cfg(feature = "zlib-compression")))]
75+
#[cfg(feature = "zlib-compression")]
7876
Zlib {
7977
/// Zlib compression level
8078
level: Option<i32>,
8179
},
8280
/// Snappy compressor.
8381
/// See [`Snappy`](http://google.github.io/snappy/) for more information.
84-
#[cfg(any(feature = "snappy-compression", docsrs))]
85-
#[cfg_attr(docsrs, doc(cfg(feature = "snappy-compression")))]
82+
#[cfg(feature = "snappy-compression")]
8683
Snappy,
8784
}
8885

src/lib.rs

+22-24
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,23 @@
4949
//!
5050
//! ### All Feature flags
5151
//!
52-
//! | Feature | Description | Extra dependencies | Default |
53-
//! |:---------------------|:--------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------|:--------|
54-
//! | `tokio-runtime` | Enable support for the `tokio` async runtime | `tokio` 1.0 with the `full` feature | yes |
55-
//! | `async-std-runtime` | Enable support for the `async-std` runtime | `async-std` 1.0 | no |
56-
//! | `sync` | Expose the synchronous API (`mongodb::sync`), using an async-std backend. Cannot be used with the `tokio-runtime` feature flag. | `async-std` 1.0 | no |
57-
//! | `tokio-sync` | Expose the synchronous API (`mongodb::sync`), using a tokio backend. Cannot be used with the `async-std-runtime` feature flag. | `tokio` 1.0 with the `full` feature | no |
58-
//! | `aws-auth` | Enable support for the MONGODB-AWS authentication mechanism. | `reqwest` 0.11 | no |
59-
//! | `bson-uuid-0_8` | Enable support for v0.8 of the [`uuid`](docs.rs/uuid/0.8) crate in the public API of the re-exported `bson` crate. | n/a | no |
60-
//! | `bson-uuid-1` | Enable support for v1.x of the [`uuid`](docs.rs/uuid/1.0) crate in the public API of the re-exported `bson` crate. | n/a | no |
61-
//! | `bson-chrono-0_4` | Enable support for v0.4 of the [`chrono`](docs.rs/chrono/0.4) crate in the public API of the re-exported `bson` crate. | n/a | no |
62-
//! | `bson-serde_with` | Enable support for the [`serde_with`](docs.rs/serde_with/latest) crate in the public API of the re-exported `bson` crate. | `serde_with` 1.0 | no |
63-
//! | `zlib-compression` | Enable support for compressing messages with [`zlib`](https://zlib.net/) | `flate2` 1.0 | no |
64-
//! | `zstd-compression` | Enable support for compressing messages with [`zstd`](http://facebook.github.io/zstd/). This flag requires Rust version 1.54. | `zstd` 0.9.0 | no |
65-
//! | `snappy-compression` | Enable support for compressing messages with [`snappy`](http://google.github.io/snappy/) | `snap` 1.0.5 | no |
66-
//! | `openssl-tls` | Switch TLS connection handling to use ['openssl'](https://docs.rs/openssl/0.10.38/). | `openssl` 0.10.38 | no |
52+
//! | Feature | Description | Default |
53+
//! |:-----------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------|
54+
//! | `tokio-runtime` | Enable support for the `tokio` async runtime. | yes |
55+
//! | `async-std-runtime` | Enable support for the `async-std` runtime. | no |
56+
//! | `sync` | Expose the synchronous API (`mongodb::sync`), using an async-std backend. Cannot be used with the `tokio-runtime` feature flag. | no |
57+
//! | `tokio-sync` | Expose the synchronous API (`mongodb::sync`), using a tokio backend. Cannot be used with the `async-std-runtime` feature flag. | no |
58+
//! | `aws-auth` | Enable support for the MONGODB-AWS authentication mechanism. | no |
59+
//! | `bson-uuid-0_8` | Enable support for v0.8 of the [`uuid`](docs.rs/uuid/0.8) crate in the public API of the re-exported `bson` crate. | no |
60+
//! | `bson-uuid-1` | Enable support for v1.x of the [`uuid`](docs.rs/uuid/1.0) crate in the public API of the re-exported `bson` crate. | no |
61+
//! | `bson-chrono-0_4` | Enable support for v0.4 of the [`chrono`](docs.rs/chrono/0.4) crate in the public API of the re-exported `bson` crate. | no |
62+
//! | `bson-serde_with` | Enable support for the [`serde_with`](docs.rs/serde_with/latest) crate in the public API of the re-exported `bson` crate. | no |
63+
//! | `zlib-compression` | Enable support for compressing messages with [`zlib`](https://zlib.net/). | no |
64+
//! | `zstd-compression` | Enable support for compressing messages with [`zstd`](http://facebook.github.io/zstd/). | no |
65+
//! | `snappy-compression` | Enable support for compressing messages with [`snappy`](http://google.github.io/snappy/). | no |
66+
//! | `openssl-tls` | Switch TLS connection handling to use [`openssl`](https://docs.rs/openssl/0.10.38/). | no |
67+
//! | `in-use-encryption-unstable` | Enable support for client-side field level encryption and queryable encryption. This API is unstable and may be subject to breaking changes in minor releases. | no |
68+
//! | `tracing-unstable` | Enable support for emitting [`tracing`](https://docs.rs/tracing/latest/tracing/) events. This API is unstable and may be subject to breaking changes in minor releases. | no |
6769
//!
6870
//! # Example Usage
6971
//!
@@ -288,10 +290,7 @@
288290
//! it will only happen in a minor or major version release.
289291
290292
#![warn(missing_docs)]
291-
// `missing_crate_level_docs` was renamed with a `rustdoc::` prefix in rustc 1.55, but isn't
292-
// supported in the MSRV.
293-
// TODO: remove the wrapping cfg_attr if/when the MSRV is 1.55+.
294-
#![cfg_attr(docsrs, warn(rustdoc::missing_crate_level_docs))]
293+
#![warn(rustdoc::missing_crate_level_docs)]
295294
#![cfg_attr(
296295
feature = "cargo-clippy",
297296
allow(
@@ -302,7 +301,7 @@
302301
clippy::derive_partial_eq_without_eq
303302
)
304303
)]
305-
#![cfg_attr(docsrs, feature(doc_cfg))]
304+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
306305
#![cfg_attr(test, type_length_limit = "80000000")]
307306
#![doc(html_root_url = "https://docs.rs/mongodb/2.4.0")]
308307

@@ -313,6 +312,8 @@ compile_error!("The `aws-auth` feature flag is only supported on the tokio runti
313312
pub mod options;
314313

315314
pub use ::bson;
315+
#[cfg(feature = "in-use-encryption-unstable")]
316+
pub use ::mongocrypt;
316317

317318
mod bson_util;
318319
pub mod change_stream;
@@ -337,8 +338,7 @@ mod selection_criteria;
337338
mod srv;
338339
#[cfg(feature = "tracing-unstable")]
339340
mod trace;
340-
#[cfg(any(feature = "sync", feature = "tokio-sync", docsrs))]
341-
#[cfg_attr(docsrs, doc(cfg(any(feature = "sync", feature = "tokio-sync"))))]
341+
#[cfg(any(feature = "sync", feature = "tokio-sync"))]
342342
pub mod sync;
343343
#[cfg(test)]
344344
mod test;
@@ -355,8 +355,6 @@ pub use crate::{
355355
};
356356
#[cfg(feature = "in-use-encryption-unstable")]
357357
pub use crate::client::csfle::client_encryption;
358-
#[cfg(feature = "in-use-encryption-unstable")]
359-
pub use ::mongocrypt;
360358

361359
pub use {client::session::ClusterTime, coll::Namespace, index::IndexModel, sdam::public::*};
362360

0 commit comments

Comments
 (0)