Skip to content

Commit

Permalink
Match CI doc testing with docs.rs. (#5)
Browse files Browse the repository at this point in the history
* Remove `-Zunstable-options -Zrustdoc-scrape-examples` from CI. It
wasn't even enabled for docs.rs and we don't have any examples, so not
worth enabling scraping at this point.
* Treat doc warnings as errors. Historically we've not done so due to
various `rustdoc` bugs giving false positives but I got it to pass
without failure right now, so perhaps better times have arrived.
* Enable the `doc_auto_cfg` feature for docs.rs which will show a little
tip next to feature gated functionality informing of the crate feature
flag.
  • Loading branch information
xStrom authored Nov 5, 2024
1 parent 3502072 commit f926fc1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,13 @@ jobs:
with:
save-if: ${{ github.event_name != 'merge_group' }}

# We test documentation using nightly to match docs.rs. This prevents potential breakages
# We test documentation using nightly to match docs.rs.
- name: cargo doc
run: cargo doc --workspace --locked --all-features --no-deps --document-private-items -Zunstable-options -Zrustdoc-scrape-examples
run: cargo doc --workspace --locked --all-features --no-deps --document-private-items
env:
RUSTDOCFLAGS: '--cfg docsrs -D warnings'

# If this fails, consider changing your text or adding something to .typos.toml
# If this fails, consider changing your text or adding something to .typos.toml.
typos:
runs-on: ubuntu-latest
steps:
Expand Down
12 changes: 6 additions & 6 deletions color/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ rust-version.workspace = true
# Whilst we prepare the initial release
publish = false

[features]
default = ["std"]
std = []
libm = ["dep:libm"]

[package.metadata.docs.rs]
all-features = true
# There are no platform specific docs.
default-target = "x86_64-unknown-linux-gnu"
# Color is entirely platform-agnostic, so only display docs for one platform
targets = []

[features]
default = ["std"]
std = []
libm = ["dep:libm"]

[dependencies]

[dependencies.libm]
Expand Down
1 change: 1 addition & 0 deletions color/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
// LINEBENDER LINT SET - v1
// See https://linebender.org/wiki/canonical-lints/
// These lints aren't included in Cargo.toml because they
Expand Down
2 changes: 1 addition & 1 deletion color/src/tagged.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub enum ColorspaceTag {
}

/// A color with a runtime colorspace tag. This type will likely get merged with
/// [`CssColor`].
/// [`CssColor`][crate::css::CssColor].
#[derive(Clone, Copy, Debug)]
pub struct TaggedColor {
pub cs: ColorspaceTag,
Expand Down
12 changes: 6 additions & 6 deletions color_operations/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ rust-version.workspace = true
# Whilst we prepare the initial release
publish = false

[features]
default = ["std"]
std = ["color/std"]
libm = ["color/libm"]

[package.metadata.docs.rs]
all-features = true
# There are no platform specific docs.
default-target = "x86_64-unknown-linux-gnu"
# Color is entirely platform-agnostic, so only display docs for one platform
targets = []

[features]
default = ["std"]
std = ["color/std"]
libm = ["color/libm"]

[dependencies]
color = { workspace = true, default-features = false }

Expand Down
1 change: 1 addition & 0 deletions color_operations/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

#![cfg_attr(all(not(feature = "std"), not(test)), no_std)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
// LINEBENDER LINT SET - v1
// See https://linebender.org/wiki/canonical-lints/
// These lints aren't included in Cargo.toml because they
Expand Down

0 comments on commit f926fc1

Please sign in to comment.