Skip to content

Commit

Permalink
Add docs for the new impl_* macros. (#23)
Browse files Browse the repository at this point in the history
* Add docs for the new `impl_*` macros.

* Add impl macros to example docs.
  • Loading branch information
parasyte authored Feb 10, 2024
1 parent 05a5640 commit 7bdb060
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<OsString>) -> Result<Self, CliError> {
/// let mut verbose = false;
///
Expand Down Expand Up @@ -193,6 +196,16 @@ pub fn parse<T: OnlyArgs>() -> Result<T, CliError> {
}

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 {
() => {
Expand All @@ -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 {
() => {
Expand Down

0 comments on commit 7bdb060

Please sign in to comment.