Mercurial > crates > nonstick
view 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 source
//! A place to stick documentation stuff. /// Generates text lists of reference links for docs. /// /// Use this with the other doc macros for the correct link names. /// /// # Examples /// /// ```ignore /// # use nonstick::{linklist, stdlinks}; /// /// Here is a list of links: /// /// /// #[doc = linklist!(pam_get_authtok: man7, manbsd)] /// /// /// /// The links are defined in the `stdlinks!` invocation below: /// /// /// #[doc = stdlinks!(3 pam_get_authtok)] /// # fn do_whatever() {} /// ``` macro_rules! linklist { ($func:ident: adg$(, $rest:ident)*) => { concat!( "- [Application Developers' Guide on `", stringify!($func), "`][adg]\n", $crate::linklist!($func: $($rest),*) ) }; ($func:ident: mwg$(, $rest:ident)*) => { concat!( "- [Module Writers' Guide on `", stringify!($func), "`][mwg]\n", $crate::linklist!($func: $($rest),*) ) }; ($func:ident: _std$(, $rest:ident)*) => { $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),*) ) }; ($func:ident: manbsd$(, $rest:ident)*) => { concat!( "- [OpenPAM manpage for `", stringify!($func), "`][manbsd]\n", $crate::linklist!($func: $($rest),*) ) }; ($func:ident: xsso$(, $rest:ident)*) => { concat!( "- [X/SSO spec for `", stringify!($func), "`][xsso]", $crate::linklist!($func: $($rest),*) ) }; ($func:ident:$(,)?) => { "" }; } /// Generates a Markdown link reference to one of the PAM guides. /// /// # Examples /// /// ```ignore /// # use nonstick::{guide}; /// /// See [the guide][mwg]. /// /// /// #[doc = guide!(mwg: "mwg-expected-by-module-item.html#mwg-pam_get_user")] /// # fn do_whatever() {} /// ``` macro_rules! guide { ($name:ident: $page_link:literal) => { concat!( "[", stringify!($name), "]: https://www.chiark.greenend.org.uk/doc/libpam-doc/html/", $page_link ) }; } /// Generates a Markdown link reference to the Linux man pages on man7.org. /// /// # Examples /// /// ```ignore /// # use nonstick::man7; /// /// This contains a [link to the man page for malloc][man7]. /// #[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")] /// # fn do_whatever2() {} /// ``` macro_rules! man7 { ($n:literal $fn:ident $($anchor:literal)?) => { $crate::man7!(man7: $n $fn $($anchor)?) }; ($name:ident: $n:literal $fn:ident $($anchor:literal)?) => { concat!( "[", stringify!($name), "]: ", "https://man7.org/linux/man-pages/man", $n, "/", stringify!($fn), ".", $n, ".html", $("#", $anchor)? ) }; } /// Generates a Markdown link reference to the NetBSD man pages. /// /// # Examples /// /// ```ignore /// # use nonstick::manbsd; /// // Both of these formulations create a link named `manbsd`. /// #[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")] /// # fn do_whatever() {} /// ``` macro_rules! manbsd { ($n:literal $func:ident $($anchor:literal)?) => { $crate::manbsd!(manbsd: $n $func $($anchor)?) }; ($name:ident: $n:literal $func:ident $($anchor:literal)?) => { concat!("[", stringify!($name), "]: ", "https://man.netbsd.org/", stringify!($func), ".", $n, $("#", $anchor)? ) }; } /// Generates a Markdown link reference to the X/SSO specification. /// /// # Examples /// /// ```ignore /// # use nonstick::xsso; /// /// This docstring will [link to the X/SSO spec for `pam_set_item`][xsso]. /// /// /// #[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")] /// # fn do_whatever() {} /// ``` 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) }; } /// Generates Markdown link references to Linux-PAM, OpenPAM, and X/SSO. /// /// A shortcut to `man7!`, `manbsd!`, and `xsso!`. /// /// # Examples /// /// ```ignore /// # use nonstick::stdlinks; /// /// Check out [this][man7], [that][manbsd], or [the other][xsso]. /// /// /// #[doc = stdlinks!(3 pam_get_item)] /// # fn do_whatever() {} /// ``` macro_rules! stdlinks { ($n:literal $func:ident) => { concat!($crate::man7!($n $func), "\n", $crate::manbsd!($n $func), "\n", $crate::xsso!($func)) }; } pub(crate) use {linklist, guide, man7, manbsd, xsso, stdlinks};