docs: fix documentation build on Windows (#6945)

This commit is contained in:
Jonas Fassbender 2024-11-13 17:28:55 +01:00 committed by GitHub
parent 3b677d1fde
commit 772e0ca8a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 32 additions and 15 deletions

View File

@ -180,7 +180,7 @@ jobs:
run: | run: |
set -euxo pipefail set -euxo pipefail
RUSTFLAGS="$RUSTFLAGS -C panic=abort -Zpanic-abort-tests" cargo nextest run --workspace --exclude tokio-macros --exclude tests-build --all-features --tests RUSTFLAGS="$RUSTFLAGS -C panic=abort -Zpanic-abort-tests" cargo nextest run --workspace --exclude tokio-macros --exclude tests-build --all-features --tests
test-integration-tests-per-feature: test-integration-tests-per-feature:
needs: basics needs: basics
name: Run integration tests for each feature name: Run integration tests for each feature
@ -768,7 +768,15 @@ jobs:
docs: docs:
name: docs name: docs
runs-on: ubuntu-latest runs-on: ${{ matrix.run.os }}
strategy:
matrix:
run:
- os: windows-latest
- os: ubuntu-latest
RUSTFLAGS: --cfg tokio_taskdump
RUSTDOCFLAGS: --cfg tokio_taskdump
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install Rust ${{ env.rust_nightly }} - name: Install Rust ${{ env.rust_nightly }}
@ -780,8 +788,8 @@ jobs:
run: | run: |
cargo doc --lib --no-deps --all-features --document-private-items cargo doc --lib --no-deps --all-features --document-private-items
env: env:
RUSTFLAGS: --cfg docsrs --cfg tokio_unstable --cfg tokio_taskdump RUSTFLAGS: --cfg docsrs --cfg tokio_unstable ${{ matrix.run.RUSTFLAGS }}
RUSTDOCFLAGS: --cfg docsrs --cfg tokio_unstable --cfg tokio_taskdump -Dwarnings RUSTDOCFLAGS: --cfg docsrs --cfg tokio_unstable -Dwarnings ${{ matrix.run.RUSTDOCFLAGS }}
loom-compile: loom-compile:
name: build loom tests name: build loom tests
@ -1106,11 +1114,11 @@ jobs:
- name: Make sure dictionary words are sorted and unique - name: Make sure dictionary words are sorted and unique
run: | run: |
# `sed` removes the first line (number of words) and # `sed` removes the first line (number of words) and
# the last line (new line). # the last line (new line).
# #
# `sort` makes sure everything in between is sorted # `sort` makes sure everything in between is sorted
# and contains no duplicates. # and contains no duplicates.
# #
# Since `sort` is sensitive to locale, we set it # Since `sort` is sensitive to locale, we set it
# using LC_ALL to en_US.UTF8 to be consistent in different # using LC_ALL to en_US.UTF8 to be consistent in different
# environments. # environments.

View File

@ -231,6 +231,9 @@ cfg_io_driver_impl! {
pub(crate) use poll_evented::PollEvented; pub(crate) use poll_evented::PollEvented;
} }
// The bsd module can't be build on Windows, so we completely ignore it, even
// when building documentation.
#[cfg(unix)]
cfg_aio! { cfg_aio! {
/// BSD-specific I/O types. /// BSD-specific I/O types.
pub mod bsd { pub mod bsd {

View File

@ -19,6 +19,7 @@
#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, allow(unused_attributes))] #![cfg_attr(docsrs, allow(unused_attributes))]
#![cfg_attr(loom, allow(dead_code, unreachable_pub))] #![cfg_attr(loom, allow(dead_code, unreachable_pub))]
#![cfg_attr(windows, allow(rustdoc::broken_intra_doc_links))]
//! A runtime for writing reliable network applications without compromising speed. //! A runtime for writing reliable network applications without compromising speed.
//! //!
@ -633,15 +634,15 @@ pub mod stream {}
// local re-exports of platform specific things, allowing for decent // local re-exports of platform specific things, allowing for decent
// documentation to be shimmed in on docs.rs // documentation to be shimmed in on docs.rs
#[cfg(docsrs)] #[cfg(all(docsrs, unix))]
pub mod doc; pub mod doc;
#[cfg(any(feature = "net", feature = "fs"))] #[cfg(any(feature = "net", feature = "fs"))]
#[cfg(docsrs)] #[cfg(all(docsrs, unix))]
#[allow(unused)] #[allow(unused)]
pub(crate) use self::doc::os; pub(crate) use self::doc::os;
#[cfg(not(docsrs))] #[cfg(not(all(docsrs, unix)))]
#[allow(unused)] #[allow(unused)]
pub(crate) use std::os; pub(crate) use std::os;

View File

@ -787,6 +787,9 @@ impl fmt::Debug for TcpSocket {
} }
} }
// These trait implementations can't be build on Windows, so we completely
// ignore them, even when building documentation.
#[cfg(unix)]
cfg_unix! { cfg_unix! {
impl AsRawFd for TcpSocket { impl AsRawFd for TcpSocket {
fn as_raw_fd(&self) -> RawFd { fn as_raw_fd(&self) -> RawFd {

View File

@ -17,7 +17,7 @@ cfg_io_util! {
} }
// Hide imports which are not used when generating documentation. // Hide imports which are not used when generating documentation.
#[cfg(not(docsrs))] #[cfg(windows)]
mod doc { mod doc {
pub(super) use crate::os::windows::ffi::OsStrExt; pub(super) use crate::os::windows::ffi::OsStrExt;
pub(super) mod windows_sys { pub(super) mod windows_sys {
@ -30,7 +30,7 @@ mod doc {
} }
// NB: none of these shows up in public API, so don't document them. // NB: none of these shows up in public API, so don't document them.
#[cfg(docsrs)] #[cfg(not(windows))]
mod doc { mod doc {
pub(super) mod mio_windows { pub(super) mod mio_windows {
pub type NamedPipe = crate::doc::NotDefinedHere; pub type NamedPipe = crate::doc::NotDefinedHere;

View File

@ -12,13 +12,15 @@ use crate::signal::RxFuture;
use std::io; use std::io;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
#[cfg(not(docsrs))] #[cfg(windows)]
#[path = "windows/sys.rs"] #[path = "windows/sys.rs"]
mod imp; mod imp;
#[cfg(not(docsrs))]
#[cfg(windows)]
pub(crate) use self::imp::{OsExtraData, OsStorage}; pub(crate) use self::imp::{OsExtraData, OsStorage};
#[cfg(docsrs)] // For building documentation on Unix machines when the `docsrs` flag is set.
#[cfg(not(windows))]
#[path = "windows/stub.rs"] #[path = "windows/stub.rs"]
mod imp; mod imp;