Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix documentation generation for docs.rs #398

Merged
merged 10 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 31 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full

jobs:
Test:
name: Test
Expand Down Expand Up @@ -36,49 +35,57 @@ jobs:
os: windows-latest
rust: stable
steps:
- uses: actions/checkout@master
- name: Install Rust (rustup)
run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
shell: bash
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- uses: taiki-e/install-action@cargo-hack
- name: Run tests
run: cargo hack test --feature-powerset && cargo hack test --feature-powerset --release

Rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: Check formatting
run: cargo fmt --all -- --check

Check:
name: Check
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-netbsd", "x86_64-unknown-redox"]
target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-netbsd", "x86_64-unknown-redox"]
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update stable && rustup default stable
- name: Install Target
run: rustup target add ${{ matrix.target }}
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: taiki-e/install-action@cargo-hack
- name: Run check
run: cargo hack check --feature-powerset --all-targets --examples --bins --tests --target ${{ matrix.target }}

Clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add clippy
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: Run Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
Docs:
name: Docs
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# NOTE: missing "x86_64-fuchsia", nightly unavailable at the time of
# writing.
target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-netbsd", "x86_64-unknown-redox"]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly # NOTE: need nightly for `doc_cfg` feature.
with:
targets: ${{ matrix.target }}
- name: Check docs for docs.rs
run: RUSTDOCFLAGS="-D warnings --cfg docsrs" cargo doc --no-deps --all-features --target ${{ matrix.target }}
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ include = [
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
targets = ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-netbsd", "x86_64-unknown-redox"]

[package.metadata.playground]
features = ["all"]
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Targets available via Rustup that are supported.
# NOTE: keep in sync with the CI and docs.rs targets.
TARGETS ?= "aarch64-apple-ios" "aarch64-linux-android" "x86_64-apple-darwin" "x86_64-fuchsia" "x86_64-pc-windows-msvc" "x86_64-pc-solaris" "x86_64-unknown-freebsd" "x86_64-unknown-illumos" "x86_64-unknown-linux-gnu" "x86_64-unknown-netbsd" "x86_64-unknown-redox"

test:
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl Type {
///
/// Used for the DCCP protocol.
#[cfg(all(feature = "all", target_os = "linux"))]
#[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))]
pub const DCCP: Type = Type(sys::SOCK_DCCP);

/// Type corresponding to `SOCK_SEQPACKET`.
Expand Down Expand Up @@ -316,7 +316,7 @@ impl Protocol {

/// Protocol corresponding to `DCCP`.
#[cfg(all(feature = "all", target_os = "linux"))]
#[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))]
pub const DCCP: Protocol = Protocol(sys::IPPROTO_DCCP);

#[cfg(all(feature = "all", any(target_os = "freebsd", target_os = "linux")))]
Expand Down
18 changes: 12 additions & 6 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ impl Socket {
///
/// On Windows it is not possible retrieve the nonblocking mode status.
#[cfg(all(feature = "all", unix))]
#[cfg_attr(docsrs, doc(all(feature = "all", unix)))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix))))]
pub fn nonblocking(&self) -> io::Result<bool> {
sys::nonblocking(self.as_raw())
}
Expand Down Expand Up @@ -425,6 +425,7 @@ impl Socket {
///
/// [`recv`]: Socket::recv
/// [`out_of_band_inline`]: Socket::out_of_band_inline
#[cfg_attr(target_os = "redox", allow(rustdoc::broken_intra_doc_links))]
pub fn recv_out_of_band(&self, buf: &mut [MaybeUninit<u8>]) -> io::Result<usize> {
self.recv_with_flags(buf, sys::MSG_OOB)
}
Expand Down Expand Up @@ -640,7 +641,7 @@ impl Socket {
/// Identical to [`send`] but allows for specification of arbitrary flags to the underlying
/// `send` call.
///
/// [`send`]: #method.send
/// [`send`]: Socket::send
pub fn send_with_flags(&self, buf: &[u8], flags: c_int) -> io::Result<usize> {
sys::send(self.as_raw(), buf, flags)
}
Expand Down Expand Up @@ -672,8 +673,9 @@ impl Socket {
///
/// For more information, see [`send`], [`out_of_band_inline`].
///
/// [`send`]: #method.send
/// [`out_of_band_inline`]: #method.out_of_band_inline
/// [`send`]: Socket::send
/// [`out_of_band_inline`]: Socket::out_of_band_inline
#[cfg_attr(target_os = "redox", allow(rustdoc::broken_intra_doc_links))]
pub fn send_out_of_band(&self, buf: &[u8]) -> io::Result<usize> {
self.send_with_flags(buf, sys::MSG_OOB)
}
Expand Down Expand Up @@ -1084,7 +1086,7 @@ impl Socket {
///
/// [`set_header_included`]: Socket::set_header_included
#[cfg(all(feature = "all", not(target_os = "redox")))]
#[cfg_attr(docsrs, doc(all(feature = "all", not(target_os = "redox"))))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", not(target_os = "redox")))))]
pub fn header_included(&self) -> io::Result<bool> {
unsafe {
getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, sys::IP_HDRINCL)
Expand All @@ -1103,8 +1105,12 @@ impl Socket {
/// [raw(7)]: https://man7.org/linux/man-pages/man7/raw.7.html
/// [`IP_TTL`]: Socket::set_ttl
/// [`IP_TOS`]: Socket::set_tos
#[cfg_attr(
any(target_os = "illumos", target_os = "solaris"),
allow(rustdoc::broken_intra_doc_links)
)]
#[cfg(all(feature = "all", not(target_os = "redox")))]
#[cfg_attr(docsrs, doc(all(feature = "all", not(target_os = "redox"))))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", not(target_os = "redox")))))]
pub fn set_header_included(&self, included: bool) -> io::Result<()> {
unsafe {
setsockopt(
Expand Down
Loading