Skip to content

Commit 2895d7e

Browse files
authored
Merge pull request #1370 from wprzytula/set-features-for-docs
doctests: correct configuration wrt crate features
2 parents c33f804 + 8aacdd6 commit 2895d7e

File tree

6 files changed

+40
-23
lines changed

6 files changed

+40
-23
lines changed

scylla-cql/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ keywords = ["database", "scylla", "cql", "cassandra"]
1010
categories = ["database"]
1111
license = "MIT OR Apache-2.0"
1212

13+
[package.metadata."docs.rs"]
14+
all-features = true
15+
1316
[dependencies]
1417
# Important: We use precise version of scylla-macros. This enables
1518
# us to make breaking changes in the doc(hidden) interfaces that are

scylla-macros/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ license = "MIT OR Apache-2.0"
1212
[lib]
1313
proc-macro = true
1414

15+
[package.metadata."docs.rs"]
16+
all-features = true
17+
1518
[dependencies]
1619
darling = "0.20.10"
1720
syn = "2.0"

scylla-proxy/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ keywords = ["database", "scylla", "cql", "cassandra"]
1010
categories = ["database"]
1111
license = "MIT OR Apache-2.0"
1212

13+
[package.metadata."docs.rs"]
14+
all-features = true
15+
1316
[features]
1417
defaults = []
1518

scylla/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ keywords = ["database", "scylla", "cql", "cassandra"]
1010
categories = ["database"]
1111
license = "MIT OR Apache-2.0"
1212

13-
[package.metadata.docs.rs]
13+
[package.metadata."docs.rs"]
1414
all-features = true
1515
rustdoc-args = ["--cfg", "docsrs"]
1616

scylla/src/client/session_builder.rs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -329,27 +329,34 @@ impl GenericSessionBuilder<DefaultMode> {
329329
///
330330
/// Default is None.
331331
///
332-
/// # Example
333-
/// ```
334-
/// # use std::fs;
335-
/// # use std::path::PathBuf;
336-
/// # use scylla::client::session::Session;
337-
/// # use scylla::client::session_builder::SessionBuilder;
338-
/// # use openssl::ssl::{SslContextBuilder, SslVerifyMode, SslMethod, SslFiletype};
339-
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
340-
/// let certdir = fs::canonicalize(PathBuf::from("./examples/certs/scylla.crt"))?;
341-
/// let mut context_builder = SslContextBuilder::new(SslMethod::tls())?;
342-
/// context_builder.set_certificate_file(certdir.as_path(), SslFiletype::PEM)?;
343-
/// context_builder.set_verify(SslVerifyMode::NONE);
344-
///
345-
/// let session: Session = SessionBuilder::new()
346-
/// .known_node("127.0.0.1:9042")
347-
/// .tls_context(Some(context_builder.build()))
348-
/// .build()
349-
/// .await?;
350-
/// # Ok(())
351-
/// # }
352-
/// ```
332+
#[cfg_attr(
333+
feature = "openssl-010",
334+
doc = r#"
335+
# Example
336+
337+
```
338+
# async fn example() -> Result<(), Box<dyn std::error::Error>> {
339+
use std::fs;
340+
use std::path::PathBuf;
341+
use scylla::client::session::Session;
342+
use scylla::client::session_builder::SessionBuilder;
343+
use openssl::ssl::{SslContextBuilder, SslVerifyMode, SslMethod, SslFiletype};
344+
345+
let certdir = fs::canonicalize(PathBuf::from("./examples/certs/scylla.crt"))?;
346+
let mut context_builder = SslContextBuilder::new(SslMethod::tls())?;
347+
context_builder.set_certificate_file(certdir.as_path(), SslFiletype::PEM)?;
348+
context_builder.set_verify(SslVerifyMode::NONE);
349+
350+
let session: Session = SessionBuilder::new()
351+
.known_node("127.0.0.1:9042")
352+
.tls_context(Some(context_builder.build()))
353+
.build()
354+
.await?;
355+
# Ok(())
356+
# }
357+
```
358+
"#
359+
)]
353360
pub fn tls_context(mut self, tls_context: Option<impl Into<TlsContext>>) -> Self {
354361
self.config.tls_context = tls_context.map(|t| t.into());
355362
self

scylla/src/cloud/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ pub enum CloudConfigError {
3535

3636
/// Configuration for creating a session to a serverless cluster.
3737
/// This can be automatically created if you provide the bundle path
38-
/// to the [`CloudSessionBuilder`] constructor.
38+
/// to the [`CloudSessionBuilder`](crate::client::session_builder::CloudSessionBuilder)
39+
/// constructor.
3940
#[derive(Debug)]
4041
pub struct CloudConfig {
4142
datacenters: HashMap<String, Datacenter>,

0 commit comments

Comments
 (0)