Skip to content

Commit

Permalink
Add docrs CI
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed Jan 31, 2025
1 parent 4a7ce31 commit 4dd0f55
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 9 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: doc

on:
push:
branches:
- main
paths-ignore:
- 'README.md'
- 'COPYRIGHT'
- 'LICENSE*'
- '**.md'
- '**.txt'
- 'art'
pull_request:
paths-ignore:
- 'README.md'
- 'COPYRIGHT'
- 'LICENSE*'
- '**.md'
- '**.txt'
- 'art'
workflow_dispatch:

env:
nightly: nightly

jobs:
docs:
name: docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache cargo build and registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ubuntu-latest-docs-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
ubuntu-latest-docs-
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.nightly }}
override: true
- name: "doc --lib --all-features"
run: cargo doc --lib --no-deps --all-features
env:
RUSTFLAGS: --cfg docsrs
RUSTDOCFLAGS: --cfg docsrs -Dwarnings
4 changes: 2 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ pub mod tests {
pub use crate::base::tests::*;
}

/// Add `test` prefix to the predefined unit test fn with a given [`Runtime`]
#[cfg(any(feature = "test", test))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "test", test))))]
#[macro_export]
#[doc(hidden)]
macro_rules! unit_tests {
($runtime:ty => $run:ident($($fn:ident), +$(,)?)) => {
$(
Expand All @@ -94,10 +94,10 @@ pub mod tests {
};
}

/// Add `test` prefix to the predefined unit test fn with a given [`Runtime`]
#[cfg(any(feature = "test", test))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "test", test))))]
#[macro_export]
#[doc(hidden)]
macro_rules! unit_tests_with_expr {
($run:ident($(
$(#[$outer:meta])*
Expand Down
6 changes: 3 additions & 3 deletions memberlist/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ pub mod quic {
pub use memberlist_quic::*;
}

/// [`Memberlist`](memberlist_core::Memberlist) for `tokio` runtime.
/// [`Memberlist`] for `tokio` runtime.
#[cfg(feature = "tokio")]
#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
pub mod tokio;

/// [`Memberlist`](memberlist_core::Memberlist) for `async-std` runtime.
/// [`Memberlist`] for `async-std` runtime.
#[cfg(feature = "async-std")]
#[cfg_attr(docsrs, doc(cfg(feature = "async-std")))]
pub mod async_std;

/// [`Memberlist`](memberlist_core::Memberlist) for `smol` runtime.
/// [`Memberlist`] for `smol` runtime.
#[cfg(feature = "smol")]
#[cfg_attr(docsrs, doc(cfg(feature = "smol")))]
pub mod smol;
2 changes: 1 addition & 1 deletion transports/net/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::net::{IpAddr, SocketAddr};
use memberlist_core::transport::{TransportError, Wire};
use nodecraft::resolver::AddressResolver;

/// Errors that can occur when using [`NetTransport`].
/// Errors that can occur when using [`NetTransport`](super::NetTransport).
#[derive(thiserror::Error)]
pub enum NetTransportError<A: AddressResolver, W: Wire> {
/// Connection error.
Expand Down
2 changes: 1 addition & 1 deletion transports/net/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::compressor::Compressor;

pub use super::promised_processor::listener_backoff;

/// Unit test for handling [`Ping`] message
/// Unit test for handling `Ping` message
pub mod handle_ping;

/// Unit test for handling compound ping message
Expand Down
5 changes: 4 additions & 1 deletion types/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<I, A> Message<I, A> {
///
/// This constant specifies a range of tag values that are reserved for internal use
/// by the [`Message`] enum variants. When implementing custom
/// with [`Wire`](crate::transport::Wire) or [`Transport`](crate::transport::Transport),
/// with [`Wire`] or [`Transport`],
/// it is important to ensure that any custom header added to the message bytes does not
/// start with a tag value within this reserved range.
///
Expand All @@ -134,6 +134,9 @@ impl<I, A> Message<I, A> {
/// Adhering to this constraint is crucial for ensuring that custom messages
/// are correctly distinguishable from the standard messages defined by the `Message` enum.
/// Failing to do so may result in incorrect message parsing and handling.
///
/// [`Wire`]: https://docs.rs/memberlist/latest/memberlist/transport/trait.Wire.html
/// [`Transport`]: https://docs.rs/memberlist/latest/memberlist/transport/trait.Transport.html
pub const RESERVED_TAG_RANGE: std::ops::RangeInclusive<u8> = (0..=128);

/// Returns the tag of the compound message type for encoding/decoding.
Expand Down
2 changes: 1 addition & 1 deletion types/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub enum State {
}

impl State {
/// Returns the [`NodeStateState`] as a `&'static str`.
/// Returns the [`State`] as a `&'static str`.
pub const fn as_str(&self) -> &'static str {
match self {
Self::Alive => "alive",
Expand Down

0 comments on commit 4dd0f55

Please sign in to comment.