Skip to content

Commit 772e0ca

Browse files
authored
docs: fix documentation build on Windows (#6945)
1 parent 3b677d1 commit 772e0ca

File tree

6 files changed

+32
-15
lines changed

6 files changed

+32
-15
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ jobs:
180180
run: |
181181
set -euxo pipefail
182182
RUSTFLAGS="$RUSTFLAGS -C panic=abort -Zpanic-abort-tests" cargo nextest run --workspace --exclude tokio-macros --exclude tests-build --all-features --tests
183-
183+
184184
test-integration-tests-per-feature:
185185
needs: basics
186186
name: Run integration tests for each feature
@@ -768,7 +768,15 @@ jobs:
768768

769769
docs:
770770
name: docs
771-
runs-on: ubuntu-latest
771+
runs-on: ${{ matrix.run.os }}
772+
strategy:
773+
matrix:
774+
run:
775+
- os: windows-latest
776+
- os: ubuntu-latest
777+
RUSTFLAGS: --cfg tokio_taskdump
778+
RUSTDOCFLAGS: --cfg tokio_taskdump
779+
772780
steps:
773781
- uses: actions/checkout@v4
774782
- name: Install Rust ${{ env.rust_nightly }}
@@ -780,8 +788,8 @@ jobs:
780788
run: |
781789
cargo doc --lib --no-deps --all-features --document-private-items
782790
env:
783-
RUSTFLAGS: --cfg docsrs --cfg tokio_unstable --cfg tokio_taskdump
784-
RUSTDOCFLAGS: --cfg docsrs --cfg tokio_unstable --cfg tokio_taskdump -Dwarnings
791+
RUSTFLAGS: --cfg docsrs --cfg tokio_unstable ${{ matrix.run.RUSTFLAGS }}
792+
RUSTDOCFLAGS: --cfg docsrs --cfg tokio_unstable -Dwarnings ${{ matrix.run.RUSTDOCFLAGS }}
785793

786794
loom-compile:
787795
name: build loom tests
@@ -1106,11 +1114,11 @@ jobs:
11061114
- name: Make sure dictionary words are sorted and unique
11071115
run: |
11081116
# `sed` removes the first line (number of words) and
1109-
# the last line (new line).
1110-
#
1117+
# the last line (new line).
1118+
#
11111119
# `sort` makes sure everything in between is sorted
11121120
# and contains no duplicates.
1113-
#
1121+
#
11141122
# Since `sort` is sensitive to locale, we set it
11151123
# using LC_ALL to en_US.UTF8 to be consistent in different
11161124
# environments.

tokio/src/io/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ cfg_io_driver_impl! {
231231
pub(crate) use poll_evented::PollEvented;
232232
}
233233

234+
// The bsd module can't be build on Windows, so we completely ignore it, even
235+
// when building documentation.
236+
#[cfg(unix)]
234237
cfg_aio! {
235238
/// BSD-specific I/O types.
236239
pub mod bsd {

tokio/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#![cfg_attr(docsrs, feature(doc_cfg))]
2020
#![cfg_attr(docsrs, allow(unused_attributes))]
2121
#![cfg_attr(loom, allow(dead_code, unreachable_pub))]
22+
#![cfg_attr(windows, allow(rustdoc::broken_intra_doc_links))]
2223

2324
//! A runtime for writing reliable network applications without compromising speed.
2425
//!
@@ -633,15 +634,15 @@ pub mod stream {}
633634
// local re-exports of platform specific things, allowing for decent
634635
// documentation to be shimmed in on docs.rs
635636

636-
#[cfg(docsrs)]
637+
#[cfg(all(docsrs, unix))]
637638
pub mod doc;
638639

639640
#[cfg(any(feature = "net", feature = "fs"))]
640-
#[cfg(docsrs)]
641+
#[cfg(all(docsrs, unix))]
641642
#[allow(unused)]
642643
pub(crate) use self::doc::os;
643644

644-
#[cfg(not(docsrs))]
645+
#[cfg(not(all(docsrs, unix)))]
645646
#[allow(unused)]
646647
pub(crate) use std::os;
647648

tokio/src/net/tcp/socket.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,9 @@ impl fmt::Debug for TcpSocket {
787787
}
788788
}
789789

790+
// These trait implementations can't be build on Windows, so we completely
791+
// ignore them, even when building documentation.
792+
#[cfg(unix)]
790793
cfg_unix! {
791794
impl AsRawFd for TcpSocket {
792795
fn as_raw_fd(&self) -> RawFd {

tokio/src/net/windows/named_pipe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cfg_io_util! {
1717
}
1818

1919
// Hide imports which are not used when generating documentation.
20-
#[cfg(not(docsrs))]
20+
#[cfg(windows)]
2121
mod doc {
2222
pub(super) use crate::os::windows::ffi::OsStrExt;
2323
pub(super) mod windows_sys {
@@ -30,7 +30,7 @@ mod doc {
3030
}
3131

3232
// NB: none of these shows up in public API, so don't document them.
33-
#[cfg(docsrs)]
33+
#[cfg(not(windows))]
3434
mod doc {
3535
pub(super) mod mio_windows {
3636
pub type NamedPipe = crate::doc::NotDefinedHere;

tokio/src/signal/windows.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ use crate::signal::RxFuture;
1212
use std::io;
1313
use std::task::{Context, Poll};
1414

15-
#[cfg(not(docsrs))]
15+
#[cfg(windows)]
1616
#[path = "windows/sys.rs"]
1717
mod imp;
18-
#[cfg(not(docsrs))]
18+
19+
#[cfg(windows)]
1920
pub(crate) use self::imp::{OsExtraData, OsStorage};
2021

21-
#[cfg(docsrs)]
22+
// For building documentation on Unix machines when the `docsrs` flag is set.
23+
#[cfg(not(windows))]
2224
#[path = "windows/stub.rs"]
2325
mod imp;
2426

0 commit comments

Comments
 (0)