Skip to content

Commit

Permalink
Add docs rules
Browse files Browse the repository at this point in the history
  • Loading branch information
rustworthy committed Aug 24, 2024
1 parent 46cadab commit 0fa2892
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:
- name: cargo llvm-cov
env:
POSTGRES_URL: postgres://username:[email protected]:5444/pgboss
run: cargo llvm-cov --locked --all-features --test e2e --lcov --output-path lcov.info -- include-ignored
run: cargo llvm-cov --locked --all-features --lcov --output-path lcov.info -- --include-ignored
- name: Record Rust version
run: echo "RUST=$(rustc --version)" >> "$GITHUB_ENV"
- name: Upload to codecov.io
Expand Down
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ categories = ["asynchronous"]

exclude = [".github", "docker", ".gitignore", "Makefile"]

[features]
default = []

[dependencies]
chrono = { version = "0.4.38", features = [] }
Expand All @@ -25,3 +27,7 @@ sqlx = { version = "0.8.0", features = [
[dev-dependencies]
lazy_static = "1.5.0"
tokio = { version = "1.39.2", features = ["macros", "rt"] }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ check:
cargo clippy --all-features
cargo d --no-deps --all-features

# https://users.rust-lang.org/t/how-to-document-optional-features-in-api-docs/64577/3
.PHONY: doc
doc:
RUSTDOCFLAGS='--cfg docsrs' cargo +nightly d --all-features --open
Expand Down
4 changes: 3 additions & 1 deletion src/client/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use sqlx::postgres::{PgConnectOptions, PgPool};
use super::{opts, Client};
use crate::utils;

/// Builder for [`Client`].
#[derive(Debug, Clone)]
pub struct ClientBuilder {
schema: String,
Expand All @@ -17,6 +18,7 @@ impl Default for ClientBuilder {
}

impl ClientBuilder {
/// Schema name.
pub fn schema<S>(mut self, schema: S) -> Self
where
S: Into<String>,
Expand All @@ -37,7 +39,7 @@ impl ClientBuilder {
self.use_pool(pool).await
}

// Connect to the PostgreSQL server using specific `PgConnectOptions`
/// Connect to the PostgreSQL server using specific `PgConnectOptions`
pub async fn connect_with(opts: PgConnectOptions) -> Result<Client, sqlx::Error> {
let pool = utils::create_pool_with(opts).await?;
Client::use_pool(pool).await
Expand Down
1 change: 1 addition & 0 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod public;

pub use builder::ClientBuilder;

/// PgBoss client.
#[derive(Debug, Clone)]
pub struct Client {
pool: PgPool,
Expand Down
9 changes: 5 additions & 4 deletions src/client/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ use sqlx::postgres::PgConnectOptions;
use sqlx::postgres::PgPool;
use sqlx::types::Json;

use super::{builder, opts, Client};
use super::{builder::ClientBuilder, opts, Client};

impl Client {
pub fn builder() -> builder::ClientBuilder {
builder::ClientBuilder::default()
/// Create an instance of [`ClientBuilder`]
pub fn builder() -> ClientBuilder {
ClientBuilder::default()
}

/// Connect to the PostgreSQL server.
Expand All @@ -26,7 +27,7 @@ impl Client {
Client::use_pool(pool).await
}

// Connect to the PostgreSQL server using specific `PgConnectOptions`
/// Connect to the PostgreSQL server using specific `PgConnectOptions`
pub async fn connect_with(opts: PgConnectOptions) -> Result<Self, sqlx::Error> {
let pool = utils::create_pool_with(opts).await?;
Client::use_pool(pool).await
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! Crate docs
#![deny(missing_docs)]
#![cfg_attr(docsrs, feature(doc_cfg))]

mod client;
mod job;
mod queue;
Expand Down
2 changes: 2 additions & 0 deletions src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ impl std::fmt::Display for QueuePolicy {
}
}

/// Queue configuration.
#[derive(Debug, Clone, Default, Serialize)]
pub struct QueueOptions {
/// Policy to apply to this queue.
pub policy: QueuePolicy,
}

0 comments on commit 0fa2892

Please sign in to comment.