From aac09b8a8fc58fe0bf8b9c4a5c1f9e63c054cf9b Mon Sep 17 00:00:00 2001 From: n4n5 <56606507+Its-Just-Nans@users.noreply.github.com> Date: Tue, 9 Jul 2024 19:43:51 +0200 Subject: [PATCH] doc: add and change documentation of uucore (#6551) --- src/uucore/src/lib/features/utmpx.rs | 2 ++ src/uucore/src/lib/macros.rs | 14 +++++++------- src/uucore/src/lib/mods/error.rs | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/uucore/src/lib/features/utmpx.rs b/src/uucore/src/lib/features/utmpx.rs index e9d1bb28a..c8e77ce4c 100644 --- a/src/uucore/src/lib/features/utmpx.rs +++ b/src/uucore/src/lib/features/utmpx.rs @@ -154,6 +154,7 @@ mod ut { pub use libc::USER_PROCESS; } +/// A login record pub struct Utmpx { inner: utmpx, } @@ -213,6 +214,7 @@ impl Utmpx { pub fn into_inner(self) -> utmpx { self.inner } + /// check if the record is a user process pub fn is_user_process(&self) -> bool { !self.user().is_empty() && self.record_type() == USER_PROCESS } diff --git a/src/uucore/src/lib/macros.rs b/src/uucore/src/lib/macros.rs index 3e5906359..6fe600538 100644 --- a/src/uucore/src/lib/macros.rs +++ b/src/uucore/src/lib/macros.rs @@ -26,12 +26,12 @@ //! Here's an overview of the macros sorted by purpose //! //! - Print errors -//! - From types implementing [`crate::error::UError`]: [`show!`], -//! [`show_if_err!`] -//! - From custom messages: [`show_error!`] -//! - Print warnings: [`show_warning!`] +//! - From types implementing [`crate::error::UError`]: [`crate::show!`], +//! [`crate::show_if_err!`] +//! - From custom messages: [`crate::show_error!`] +//! - Print warnings: [`crate::show_warning!`] //! - Terminate util execution -//! - Crash program: [`crash!`], [`crash_if_err!`] +//! - Crash program: [`crate::crash!`], [`crate::crash_if_err!`] // spell-checker:ignore sourcepath targetpath rustdoc @@ -99,8 +99,8 @@ macro_rules! show( /// Display an error and set global exit code in error case. /// -/// Wraps around [`show!`] and takes a [`crate::error::UResult`] instead of a -/// [`crate::error::UError`] type. This macro invokes [`show!`] if the +/// Wraps around [`crate::show!`] and takes a [`crate::error::UResult`] instead of a +/// [`crate::error::UError`] type. This macro invokes [`crate::show!`] if the /// [`crate::error::UResult`] is an `Err`-variant. This can be invoked directly /// on the result of a function call, like in the `install` utility: /// diff --git a/src/uucore/src/lib/mods/error.rs b/src/uucore/src/lib/mods/error.rs index de154bfb0..571ed12e2 100644 --- a/src/uucore/src/lib/mods/error.rs +++ b/src/uucore/src/lib/mods/error.rs @@ -31,7 +31,7 @@ //! * When `Err` is returned, the code corresponding with the error is used as exit code and the //! error message is displayed. //! -//! Additionally, the errors can be displayed manually with the [`show`] and [`show_if_err`] macros: +//! Additionally, the errors can be displayed manually with the [`crate::show`] and [`crate::show_if_err`] macros: //! ```ignore //! let res = Err(USimpleError::new(1, "Error!!")); //! show_if_err!(res); @@ -41,7 +41,7 @@ //! } //! ``` //! -//! **Note**: The [`show`] and [`show_if_err`] macros set the exit code of the program using +//! **Note**: The [`crate::show`] and [`crate::show_if_err`] macros set the exit code of the program using //! [`set_exit_code`]. See the documentation on that function for more information. //! //! # Guidelines