Mercurial > crates > nonstick
diff src/_doc.rs @ 116:a12706e42c9d default tip
Logging, macros, and building:
- Changes logging API to accept the `Location` of the log statement.
Fixes OpenPAM implementation.
- Stops publicly exporting doc macros.
- Uses dlopen to detect the PAM library rather than header jankery.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sun, 29 Jun 2025 18:27:51 -0400 |
parents | 49d9e2b5c189 |
children |
line wrap: on
line diff
--- a/src/_doc.rs Sun Jun 29 03:35:59 2025 -0400 +++ b/src/_doc.rs Sun Jun 29 18:27:51 2025 -0400 @@ -6,51 +6,49 @@ /// /// # Examples /// -/// ``` -/// # use nonstick::{_linklist, _stdlinks}; +/// ```ignore +/// # use nonstick::{linklist, stdlinks}; /// /// Here is a list of links: /// /// -/// #[doc = _linklist!(pam_get_authtok: man7, manbsd)] +/// #[doc = linklist!(pam_get_authtok: man7, manbsd)] /// /// /// /// The links are defined in the `stdlinks!` invocation below: /// /// -/// #[doc = _stdlinks!(3 pam_get_authtok)] +/// #[doc = stdlinks!(3 pam_get_authtok)] /// # fn do_whatever() {} /// ``` -#[macro_export] -#[doc(hidden)] -macro_rules! _linklist { +macro_rules! linklist { ($func:ident: adg$(, $rest:ident)*) => { concat!( "- [Application Developers' Guide on `", stringify!($func), "`][adg]\n", - $crate::_linklist!($func: $($rest),*) + $crate::linklist!($func: $($rest),*) ) }; ($func:ident: mwg$(, $rest:ident)*) => { concat!( "- [Module Writers' Guide on `", stringify!($func), "`][mwg]\n", - $crate::_linklist!($func: $($rest),*) + $crate::linklist!($func: $($rest),*) ) }; ($func:ident: _std$(, $rest:ident)*) => { - $crate::_linklist!($func: man7, manbsd, xsso$(, $rest)*) + $crate::linklist!($func: man7, manbsd, xsso$(, $rest)*) }; ($func:ident: man7$(, $rest:ident)*) => { concat!( "- [Linux-PAM manpage for `", stringify!($func), "`][man7]\n", - $crate::_linklist!($func: $($rest),*) + $crate::linklist!($func: $($rest),*) ) }; ($func:ident: manbsd$(, $rest:ident)*) => { concat!( "- [OpenPAM manpage for `", stringify!($func), "`][manbsd]\n", - $crate::_linklist!($func: $($rest),*) + $crate::linklist!($func: $($rest),*) ) }; ($func:ident: xsso$(, $rest:ident)*) => { concat!( "- [X/SSO spec for `", stringify!($func), "`][xsso]", - $crate::_linklist!($func: $($rest),*) + $crate::linklist!($func: $($rest),*) ) }; ($func:ident:$(,)?) => { "" }; @@ -60,16 +58,14 @@ /// /// # Examples /// -/// ``` -/// # use nonstick::{_guide}; +/// ```ignore +/// # use nonstick::{guide}; /// /// See [the guide][mwg]. /// /// -/// #[doc = _guide!(mwg: "mwg-expected-by-module-item.html#mwg-pam_get_user")] +/// #[doc = guide!(mwg: "mwg-expected-by-module-item.html#mwg-pam_get_user")] /// # fn do_whatever() {} /// ``` -#[macro_export] -#[doc(hidden)] -macro_rules! _guide { +macro_rules! guide { ($name:ident: $page_link:literal) => { concat!( "[", @@ -84,24 +80,22 @@ /// /// # Examples /// -/// ``` -/// # use nonstick::_man7; +/// ```ignore +/// # use nonstick::man7; /// /// This contains a [link to the man page for malloc][man7]. -/// #[doc = _man7!(3 malloc)] +/// #[doc = man7!(3 malloc)] /// # fn do_whatever() {} /// /// /// This contains both a link to the ["structure" section of `hgrc`][man7] /// /// and a link to the ["environment" section of `systemd`][sysd_env]. /// /// -/// #[doc = _man7!(5 hgrc "STRUCTURE")] -/// #[doc = _man7!(sysd_env: 1 systemd "ENVIRONMENT")] +/// #[doc = man7!(5 hgrc "STRUCTURE")] +/// #[doc = man7!(sysd_env: 1 systemd "ENVIRONMENT")] /// # fn do_whatever2() {} /// ``` -#[macro_export] -#[doc(hidden)] -macro_rules! _man7 { +macro_rules! man7 { ($n:literal $fn:ident $($anchor:literal)?) => { - $crate::_man7!(man7: $n $fn $($anchor)?) + $crate::man7!(man7: $n $fn $($anchor)?) }; ($name:ident: $n:literal $fn:ident $($anchor:literal)?) => { concat!( @@ -116,20 +110,18 @@ /// /// # Examples /// -/// ``` -/// # use nonstick::_manbsd; +/// ```ignore +/// # use nonstick::manbsd; /// // Both of these formulations create a link named `manbsd`. -/// #[doc = _manbsd!(3 fn_name)] -/// #[doc = _manbsd!(5 thing_name "SECTION")] +/// #[doc = manbsd!(3 fn_name)] +/// #[doc = manbsd!(5 thing_name "SECTION")] /// // This one creates a link named `link_name`. -/// #[doc = _manbsd!(link_name: 1 prog_name "SECTION")] +/// #[doc = manbsd!(link_name: 1 prog_name "SECTION")] /// # fn do_whatever() {} /// ``` -#[macro_export] -#[doc(hidden)] -macro_rules! _manbsd { +macro_rules! manbsd { ($n:literal $func:ident $($anchor:literal)?) => { - $crate::_manbsd!(manbsd: $n $func $($anchor)?) + $crate::manbsd!(manbsd: $n $func $($anchor)?) }; ($name:ident: $n:literal $func:ident $($anchor:literal)?) => { concat!("[", stringify!($name), "]: ", @@ -143,25 +135,23 @@ /// /// # Examples /// -/// ``` -/// # use nonstick::_xsso; +/// ```ignore +/// # use nonstick::xsso; /// /// This docstring will [link to the X/SSO spec for `pam_set_item`][xsso]. /// /// -/// #[doc = _xsso!(pam_set_item)] +/// #[doc = xsso!(pam_set_item)] /// # fn link_one() {} /// /// /// This docstring will link to [`some_page`][xsso]. /// /// I can also link to [the table of contents][spec_toc]. /// /// -/// #[doc = _xsso!("some_page.htm#section-id")] -/// #[doc = _xsso!(spec_toc: "toc.htm")] +/// #[doc = xsso!("some_page.htm#section-id")] +/// #[doc = xsso!(spec_toc: "toc.htm")] /// # fn do_whatever() {} /// ``` -#[macro_export] -#[doc(hidden)] -macro_rules! _xsso { - ($func:ident) => { $crate::_xsso!(xsso: concat!(stringify!($func), ".htm")) }; - ($page:literal) => { $crate::_xsso!(xsso: $page) }; +macro_rules! xsso { + ($func:ident) => { $crate::xsso!(xsso: concat!(stringify!($func), ".htm")) }; + ($page:literal) => { $crate::xsso!(xsso: $page) }; ($name:ident: $page:expr) => { concat!("[", stringify!($name), "]: https://pubs.opengroup.org/onlinepubs/8329799/", $page) }; @@ -169,21 +159,21 @@ /// Generates Markdown link references to Linux-PAM, OpenPAM, and X/SSO. /// -/// A shortcut to `_man7!`, `_manbsd!`, and `_xsso!`. +/// A shortcut to `man7!`, `manbsd!`, and `xsso!`. /// /// # Examples /// -/// ``` -/// # use nonstick::_stdlinks; +/// ```ignore +/// # use nonstick::stdlinks; /// /// Check out [this][man7], [that][manbsd], or [the other][xsso]. /// /// -/// #[doc = _stdlinks!(3 pam_get_item)] +/// #[doc = stdlinks!(3 pam_get_item)] /// # fn do_whatever() {} /// ``` -#[macro_export] -#[doc(hidden)] -macro_rules! _stdlinks { +macro_rules! stdlinks { ($n:literal $func:ident) => { - concat!($crate::_man7!($n $func), "\n", $crate::_manbsd!($n $func), "\n", $crate::_xsso!($func)) + concat!($crate::man7!($n $func), "\n", $crate::manbsd!($n $func), "\n", $crate::xsso!($func)) }; } + +pub(crate) use {linklist, guide, man7, manbsd, xsso, stdlinks}; \ No newline at end of file