add navigation links to docs

This commit is contained in:
Terts Diepraam
2023-12-19 14:39:22 +01:00
parent 88019ffe4b
commit f01d94d8da
6 changed files with 160 additions and 9 deletions
+35
View File
@@ -1,3 +1,30 @@
<style>
.chapters p {
display: grid;
grid-template-columns: repeat(3, 6em);
justify-content: space-between;
}
.chapters a {
text-align: center;
font-family: "Fira Sans",Arial,NanumBarunGothic,sans-serif;
border: 1px solid var(--link-color);
border-radius: 4px;
padding: 3px 10px;
}
.chapters a[href=""] {
pointer-events: none;
color: var(--scrollbar-thumb-background-color);
border: 1px solid var(--scrollbar-thumb-background-color);
}
</style>
<div class="chapters">
[Previous](previous)
[Up](super)
[Next]()
</div>
# Completions
Shell completions and documentation can be generated automatically by this crate. The implementation for this is in the [`uutils-args-complete`] crate. The easiest way of generating completions is via the `parse-is-complete` feature flag. This feature flag hijacks the [`Options::parse`](crate::Options::parse) function to print completions. This means that there is usually no need to write any additional code to generate completions.
@@ -13,3 +40,11 @@ The `[shell]` value here can be `fish`, `zsh`, `bash`, `powershell`, `elvish` or
Additionally, the values `man` or `md` can be passed to generate man pages and markdown documentation (for `mdbook`).
If you do not want to hijack the [`Options::parse`](crate::Options::parse) function, you can instead enable the `complete` feature flag. This makes the `Options::complete` function available in addition to the [`Options::parse`](crate::Options::parse) function to generate a `String` with the completion.
<div class="chapters">
[Previous](previous)
[Up](super)
[Next]()
</div>
+35
View File
@@ -1,3 +1,30 @@
<style>
.chapters p {
display: grid;
grid-template-columns: repeat(3, 6em);
justify-content: space-between;
}
.chapters a {
text-align: center;
font-family: "Fira Sans",Arial,NanumBarunGothic,sans-serif;
border: 1px solid var(--link-color);
border-radius: 4px;
padding: 3px 10px;
}
.chapters a[href=""] {
pointer-events: none;
color: var(--scrollbar-thumb-background-color);
border: 1px solid var(--scrollbar-thumb-background-color);
}
</style>
<div class="chapters">
[Previous](previous)
[Up](super)
[Next](next)
</div>
# Porting from Clap
This chapter contains information about how common patterns in `clap` parsers can be ported to `uutils-args`.
@@ -237,3 +264,11 @@ impl Options<Arg> for Settings {
let a = Settings::default().parse(std::env::args_os()).0.a;
```
<div class="chapters">
[Previous](previous)
[Up](super)
[Next](next)
</div>
+36
View File
@@ -1,3 +1,31 @@
<style>
.chapters p {
display: grid;
grid-template-columns: repeat(3, 6em);
justify-content: space-between;
}
.chapters a {
text-align: center;
font-family: "Fira Sans",Arial,NanumBarunGothic,sans-serif;
border: 1px solid var(--link-color);
border-radius: 4px;
padding: 3px 10px;
}
.chapters p a[href=""] {
pointer-events: none;
color: var(--scrollbar-thumb-background-color);
border: 1px solid var(--scrollbar-thumb-background-color);
}
</style>
<div class="chapters">
[Previous]()
[Up](super)
[Next](next)
</div>
# Quick Start
A parser consists of two parts:
@@ -253,3 +281,11 @@ enum Arg {
# assert_eq!(Settings::default().parse(["test", "--sort=time"]).0.sort, String::from("time"));
# assert_eq!(Settings::default().parse(["test", "-t"]).0.sort, String::from("time"));
```
<div class="chapters">
[Previous]()
[Up](super)
[Next](next)
</div>
+35
View File
@@ -1,3 +1,30 @@
<style>
.chapters p {
display: grid;
grid-template-columns: repeat(3, 6em);
justify-content: space-between;
}
.chapters a {
text-align: center;
font-family: "Fira Sans",Arial,NanumBarunGothic,sans-serif;
border: 1px solid var(--link-color);
border-radius: 4px;
padding: 3px 10px;
}
.chapters a[href=""] {
pointer-events: none;
color: var(--scrollbar-thumb-background-color);
border: 1px solid var(--scrollbar-thumb-background-color);
}
</style>
<div class="chapters">
[Previous](previous)
[Up](super)
[Next](next)
</div>
# Value trait
Any field on the enum implementing [`Arguments`](trait@crate::Arguments) has to implement the [`Value`](trait@crate::Value) trait, which determines how it is derive from the text value. Normally, [`Value`](trait@crate::Value) only requires one method: [`from_value`](crate::Value::from_value), which takes an `&OsStr` and returns a `Result` with either `Self` or some boxed error.
@@ -55,3 +82,11 @@ assert_eq!(Color::from_value(&OsStr::new("never")).unwrap(), Color::Never);
assert!(Color::from_value(&OsStr::new("a")).is_err());
assert_eq!(Color::from_value(&OsStr::new("n")).unwrap(), Color::Never);
```
<div class="chapters">
[Previous](previous)
[Up](super)
[Next](next)
</div>
+18 -8
View File
@@ -5,14 +5,24 @@
#[doc = include_str!("../docs/guide/guide.md")]
pub mod guide {
#[doc = include_str!("../docs/guide/quick.md")]
pub mod quick {}
#[doc = include_str!("../docs/guide/port.md")]
pub mod port {}
#[doc = include_str!("../docs/guide/completions.md")]
pub mod completions {}
#[doc = include_str!("../docs/guide/value.md")]
pub mod value {}
pub mod quick {
#![doc = include_str!("../docs/guide/quick.md")]
pub use super::port as next;
}
pub mod port {
#![doc = include_str!("../docs/guide/port.md")]
pub use super::quick as previous;
pub use super::value as next;
}
pub mod value {
#![doc = include_str!("../docs/guide/value.md")]
pub use super::completions as next;
pub use super::port as previous;
}
pub mod completions {
#![doc = include_str!("../docs/guide/completions.md")]
pub use super::value as previous;
}
}
#[doc = include_str!("../docs/design/design.md")]
+1 -1
View File
@@ -31,7 +31,7 @@ pub use uutils_args_derive::Value;
///
/// This macro only works on `enums` and will error at compile time when it is
/// used on a `struct`.
///
///
/// /// ## Argument specifications
///
/// | specification | kind | value |