From 7bdb0600c20ad66ec4f1398ea276029f33d84502 Mon Sep 17 00:00:00 2001 From: Jay Oster Date: Sat, 10 Feb 2024 17:20:27 -0600 Subject: [PATCH] Add docs for the new `impl_*` macros. (#23) * Add docs for the new `impl_*` macros. * Add impl macros to example docs. --- src/lib.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 429ce5e..5b1e612 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,6 +155,9 @@ impl std::error::Error for CliError { /// } /// /// impl OnlyArgs for Args { +/// const HELP: &'static str = onlyargs::impl_help!(); +/// const VERSION: &'static str = onlyargs::impl_version!(); +/// /// fn parse(args: Vec) -> Result { /// let mut verbose = false; /// @@ -193,6 +196,16 @@ pub fn parse() -> Result { } mod macros { + /// Creates a generic `HELP` string for [`OnlyArgs`] implementations. + /// + /// The string will take the following form, filling in details from the package's `Cargo.toml`: + /// + /// ```text + /// {package-name} v{package-version} + /// {package-description} + /// ``` + /// + /// [`OnlyArgs`]: crate::OnlyArgs #[macro_export] macro_rules! impl_help { () => { @@ -207,6 +220,15 @@ mod macros { }; } + /// Creates a generic `VERSION` string for [`OnlyArgs`] implementations. + /// + /// The string will take the following form, filling in details from the package's `Cargo.toml`: + /// + /// ```text + /// {package-name} v{package-version} + /// ``` + /// + /// [`OnlyArgs`]: crate::OnlyArgs #[macro_export] macro_rules! impl_version { () => {