Skip to content

Commit

Permalink
Merge pull request #50 from palfrey/feature-docs
Browse files Browse the repository at this point in the history
Document feature flags better
  • Loading branch information
palfrey authored Feb 12, 2022
2 parents 418791f + 491026a commit a8b24bd
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
features:
- default
- file_locks
include:
- rust: nightly
features: all
steps:
- uses: actions/checkout@v2.3.4
- uses: actions-rs/toolchain@v1.0.7
Expand All @@ -45,11 +48,18 @@ jobs:
command: clippy
if: ${{ matrix.features == 'default' }}
continue-on-error: ${{ matrix.rust == 'nightly' || matrix.rust == 'beta' }}
- name: Build and test
- name: Build and test feature ${{ matrix.features }}
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --features ${{ matrix.features }}
if: ${{ matrix.features != 'all' }}
- name: Build and test all features
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --all-features
if: ${{ matrix.features == 'all' }}

multi-os-testing:
name: Test suite
Expand Down
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion serial_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ lazy_static = "1.2"
parking_lot = ">= 0.10, < 0.12"
serial_test_derive = { version = "~0.5.1", path = "../serial_test_derive" }
fslock = {version = "0.2", optional = true}
document-features = {version = "0.2", optional=true}

[features]
default = []

## The file_locks feature unlocks the `file_serial` macro
file_locks = ["fslock"]

docsrs = ["document-features"]

# docs.rs-specific configuration
[package.metadata.docs.rs]
all-features = true
all-features = true
# defines the configuration attribute `docsrs`
rustdoc-args = ["--cfg", "docsrs"]
6 changes: 6 additions & 0 deletions serial_test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
//! // Do things
//! }
//! ````
//!
//! ## Feature flags
#![cfg_attr(
feature = "docsrs",
cfg_attr(doc, doc = ::document_features::document_features!())
)]

mod code_lock;
#[cfg(feature = "file_locks")]
Expand Down
3 changes: 3 additions & 0 deletions serial_test_derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! # serial_test_derive
//! Helper crate for [serial_test](../serial_test/index.html)

#![cfg_attr(docsrs, feature(doc_cfg))]

extern crate proc_macro;

use proc_macro::TokenStream;
Expand Down Expand Up @@ -99,6 +101,7 @@ pub fn serial(attr: TokenStream, input: TokenStream) -> TokenStream {
/// Note that in this case you need to specify the `name` arg as well (as per [serial](macro@serial)). The path defaults to a reasonable temp directory for the OS if not specified.
#[proc_macro_attribute]
#[proc_macro_error]
#[cfg_attr(docsrs, doc(cfg(feature = "file_locks")))]
pub fn file_serial(attr: TokenStream, input: TokenStream) -> TokenStream {
fs_serial_core(attr.into(), input.into()).into()
}
Expand Down

0 comments on commit a8b24bd

Please sign in to comment.