Skip to content

Commit 3329fa8

Browse files
committed
Documentation improvements
1 parent e3c510b commit 3329fa8

File tree

6 files changed

+37
-9
lines changed

6 files changed

+37
-9
lines changed

Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ chrono = "0.4"
2828
diesel = { version = "2.0.0-rc.1", default-features = false, features = ["chrono"]}
2929

3030
[features]
31-
default = ["postgres", "mysql", "deadpool", "bb8", "mobc"]
31+
default = []
3232
mysql = ["diesel/mysql_backend", "mysql_async", "mysql_common"]
3333
postgres = ["diesel/postgres_backend", "tokio-postgres", "tokio", "tokio/rt-multi-thread"]
3434

3535
[[test]]
3636
name = "integration_tests"
3737
path = "tests/lib.rs"
3838
harness = true
39+
40+
[package.metadata.docs.rs]
41+
features = ["postgres", "mysql", "deadpool", "bb8", "mobc"]
42+
no-default-features = true
43+
rustc-args = ["--cfg", "doc_cfg"]
44+
rustdoc-args = ["--cfg", "doc_cfg"]

src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![cfg_attr(doc_cfg, feature(doc_cfg, doc_auto_cfg))]
12
//! Diesel-async provides async variants of diesel releated query functionality
23
//!
34
//! diesel-async is an extension to diesel itself. It is designed to be used togehter
@@ -71,20 +72,24 @@ use futures::{Future, Stream};
7172
#[cfg(feature = "mysql")]
7273
mod mysql;
7374
#[cfg(feature = "postgres")]
74-
mod pg;
75+
pub mod pg;
7576
#[cfg(any(feature = "deadpool", feature = "bb8", feature = "mobc"))]
7677
pub mod pooled_connection;
7778
mod run_query_dsl;
7879
mod stmt_cache;
7980
mod transaction_manager;
8081

8182
#[cfg(feature = "mysql")]
83+
#[doc(inline)]
8284
pub use self::mysql::AsyncMysqlConnection;
8385
#[cfg(feature = "postgres")]
86+
#[doc(inline)]
8487
pub use self::pg::AsyncPgConnection;
88+
#[doc(inline)]
8589
pub use self::run_query_dsl::*;
8690

87-
use self::transaction_manager::{AnsiTransactionManager, TransactionManager};
91+
#[doc(inline)]
92+
pub use self::transaction_manager::{AnsiTransactionManager, TransactionManager};
8893

8994
/// Perform simple operations on a backend.
9095
///
@@ -147,7 +152,7 @@ where
147152
/// If the transaction fails to commit due to a `SerializationFailure` or a
148153
/// `ReadOnlyTransaction` a rollback will be attempted.
149154
/// If the rollback fails, the error will be returned in a
150-
/// [`Error::RollbackErrorOnCommit`](crate::result::Error::RollbackErrorOnCommit),
155+
/// [`Error::RollbackErrorOnCommit`](diesel::result::Error::RollbackErrorOnCommit),
151156
/// from which you will be able to extract both the original commit error and
152157
/// the rollback error.
153158
/// In addition, the connection will be considered broken

src/pg/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
//! Provides types and functions related to working with PostgreSQL
2+
//!
3+
//! Much of this module is re-exported from database agnostic locations.
4+
//! However, if you are writing code specifically to extend Diesel on
5+
//! PostgreSQL, you may need to work with this module directly.
6+
17
use self::error_helper::ErrorHelper;
28
use self::row::PgRow;
39
use self::serialize::ToSqlHelper;

src/pg/transaction_builder.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@ use diesel::pg::Pg;
33
use diesel::query_builder::{AstPass, QueryBuilder, QueryFragment};
44
use diesel::QueryResult;
55
use futures::future::BoxFuture;
6-
76
use crate::{AnsiTransactionManager, AsyncConnection, TransactionManager};
87

8+
/// Used to build a transaction, specifying additional details.
9+
///
10+
/// This struct is returned by [`AsyncPgConnection::build_transaction`].
11+
/// See the documentation for methods on this struct for usage examples.
12+
/// See [the PostgreSQL documentation for `SET TRANSACTION`][pg-docs]
13+
/// for details on the behavior of each option.
14+
///
15+
/// [`AsyncPgConnection::build_transaction`]: super::AsyncPgConnection::build_transaction()
16+
/// [pg-docs]: https://www.postgresql.org/docs/current/static/sql-set-transaction.html
17+
#[must_use = "Transaction builder does nothing unless you call `run` on it"]
18+
#[cfg(feature = "postgres")]
919
pub struct TransactionBuilder<'a, C> {
1020
connection: &'a mut C,
1121
isolation_level: Option<IsolationLevel>,

src/run_query_dsl/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ pub mod return_futures {
171171
use diesel::QueryResult;
172172
use std::pin::Pin;
173173

174-
/// The future returned by [`RunQueryDsl::load`] and [`RunQueryDsl::get_results`]
174+
/// The future returned by [`RunQueryDsl::load`](super::RunQueryDsl::load)
175+
/// and [`RunQueryDsl::get_results`](super::RunQueryDsl::get_results)
175176
///
176177
/// This is essentially `impl Future<Output = QueryResult<Vec<U>>>`
177178
pub type LoadFuture<'conn, 'query, Q, Conn, U> = futures::future::AndThen<
@@ -188,7 +189,7 @@ pub mod return_futures {
188189
>,
189190
>;
190191

191-
/// The future returned by [`RunQueryDsl::get_results`]
192+
/// The future returned by [`RunQueryDsl::get_result`](super::RunQueryDsl::get_result)
192193
///
193194
/// This is essentially `impl Future<Output = QueryResult<U>>`
194195
pub type GetResult<'conn, 'query, Q, Conn, U> = futures::future::AndThen<
@@ -223,7 +224,7 @@ pub mod return_futures {
223224
>,
224225
>;
225226

226-
/// The future returned by [`RunQueryDsl::execute`]
227+
/// The future returned by [`RunQueryDsl::execute`](super::RunQueryDsl::execute)
227228
///
228229
/// This is essentially `impl Future<Output = QueryResult<usize>>`
229230
pub type Execute<'conn, 'query, Conn> = <Conn as AsyncConnectionGatWorkaround<

src/transaction_manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub trait TransactionManager<Conn: AsyncConnection>: Send {
4949
/// Executes the given function inside of a database transaction
5050
///
5151
/// Each implementation of this function needs to fulfill the documented
52-
/// behaviour of [`Connection::transaction`]
52+
/// behaviour of [`AsyncConnection::transaction`]
5353
async fn transaction<F, R, E>(conn: &mut Conn, callback: F) -> Result<R, E>
5454
where
5555
F: FnOnce(&mut Conn) -> BoxFuture<Result<R, E>> + Send,

0 commit comments

Comments
 (0)