Skip to content

Commit

Permalink
add navigation links to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tertsdiepraam committed Dec 19, 2023
1 parent 88019ff commit 81e988a
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 8 deletions.
35 changes: 35 additions & 0 deletions docs/guide/completions.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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 changes: 35 additions & 0 deletions docs/guide/port.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down Expand Up @@ -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 changes: 36 additions & 0 deletions docs/guide/quick.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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 changes: 35 additions & 0 deletions docs/guide/value.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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>
26 changes: 18 additions & 8 deletions src/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::port as previous;
pub use super::completions as next;
}
pub mod completions {
#![doc = include_str!("../docs/guide/completions.md")]
pub use super::value as previous;
}
}

#[doc = include_str!("../docs/design/design.md")]
Expand Down

0 comments on commit 81e988a

Please sign in to comment.