Skip to content

Commit 25da30f

Browse files
committed
feat: in-manifest and in-bin documentation of feature toggles (#329)
Unfortunately, these don't show up on docs.rs due to it being a abinary only crate. One could consider throwing in a lib just for good measure.
1 parent 15ff212 commit 25da30f

File tree

5 files changed

+56
-60
lines changed

5 files changed

+56
-60
lines changed

Diff for: Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+44-19
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,52 @@ doctest = false
2727
[features]
2828
default = ["max"]
2929

30-
max = ["fast", "pretty-cli", "http-client-curl", "gitoxide-core-tools", "gitoxide-core-blocking-client",
31-
"prodash-render-line", "prodash-render-tui",
32-
"prodash/render-line-autoconfigure" ]
30+
## Makes the crate execute as fast as possible by supporting parallel computation of otherwise long-running functions
31+
## as well as fast, hardware accelerated hashing, along with a faster zlib backend.
32+
## If disabled, the binary will be visibly smaller.
33+
fast = ["git-features/parallel", "git-features/fast-sha1", "git-features/zlib-ng-compat"]
34+
35+
## Use `clap` 3.0 to build the prettiest, best documented and most user-friendly CLI at the expense of binary size.
36+
## Provides a terminal user interface for detailed and exhaustive progress.
37+
## Provides a line renderer for leaner progress display, without the need for a full-blown TUI.
38+
pretty-cli = [ "gitoxide-core/serde1", "prodash/progress-tree", "prodash/progress-tree-log", "prodash/local-time", "gitoxide-core/local-time-support", "env_logger" ]
39+
40+
## The `--verbose` flag will be powered by an interactive progress mechanism that doubles as log as well as interactive progress
41+
## that appears after a short duration.
42+
prodash-render-line-crossterm = ["prodash-render-line", "prodash/render-line-crossterm", "atty", "crosstermion"]
43+
3344

34-
lean = ["fast", "pretty-cli", "http-client-curl", "gitoxide-core-tools", "gitoxide-core-blocking-client",
35-
"prodash-render-line" ]
36-
lean-async = ["fast", "pretty-cli", "gitoxide-core-tools", "gitoxide-core-async-client",
37-
"prodash-render-line"]
45+
#! ### Convenience Features
46+
#! These combine common choices of the above features to represent typical builds
3847

48+
## *fast* + *prodash-render-tui-crossterm* + *prodash-render-line-crossterm* + *http* + *gitoxide-core-tools* + *client-networking*
49+
max = ["fast", "pretty-cli", "http-client-curl", "gitoxide-core-tools", "gitoxide-core-blocking-client", "prodash-render-line", "prodash-render-tui", "prodash/render-line-autoconfigure" ]
50+
51+
## *fast* + *prodash-render-line-crossterm* + *gitoxide-core-tools* + *client-networking*.
52+
lean = ["fast", "pretty-cli", "http-client-curl", "gitoxide-core-tools", "gitoxide-core-blocking-client", "prodash-render-line" ]
53+
## fast* + *prodash-render-line-crossterm* + *gitoxide-core-tools* + *client-async-networking*.
54+
## Due to async client-networking not being implemented for most transports, this one supports only the 'git' transport.
55+
## It uses, however, a fully asynchronous networking implementation which can serve a real-world example on how to implement custom async transports.
56+
lean-async = ["fast", "pretty-cli", "gitoxide-core-tools", "gitoxide-core-async-client", "prodash-render-line"]
57+
58+
## As small as it can possibly be, no threading, no fast sha1, log based progress only, rust based zlib implementation.
59+
## no networking, local operations only.
3960
small = ["pretty-cli", "git-features/rustsha1", "git-features/zlib-rust-backend", "prodash/progress-log", "atty"]
4061

62+
#! ### `gitoxide-core` Configuration
63+
64+
## A way to enable all `gitoxide-core` tools found in `gix tools`
4165
gitoxide-core-tools = ["gitoxide-core/organize", "gitoxide-core/estimate-hours"]
42-
gitoxide-core-blocking-client = ["gitoxide-core/blocking-client"]
43-
gitoxide-core-async-client = ["gitoxide-core/async-client", "futures-lite"]
44-
http-client-curl = ["git-transport-for-configuration-only/http-client-curl"]
45-
fast = ["git-features/parallel", "git-features/fast-sha1", "git-features/zlib-ng-compat"]
4666

47-
pretty-cli = [
48-
"gitoxide-core/serde1",
49-
"prodash/progress-tree",
50-
"prodash/progress-tree-log",
51-
"prodash/local-time",
52-
"gitoxide-core/local-time-support",
53-
"env_logger" ]
67+
#! #### Mutually Exclusive Networking
68+
#! If both are set a compile error is triggered. This also means that `cargo … --all-features` will fail.
5469

55-
prodash-render-line-crossterm = ["prodash-render-line", "prodash/render-line-crossterm", "atty", "crosstermion"]
70+
## Use blocking client networking.
71+
gitoxide-core-blocking-client = ["gitoxide-core/blocking-client"]
72+
## Support synchronous 'http' and 'https' transports (e.g. for clone, fetch and push) at the expense of compile times and binary size.
73+
http-client-curl = ["git-transport-for-configuration-only/http-client-curl"]
74+
## Use async client networking.
75+
gitoxide-core-async-client = ["gitoxide-core/async-client", "futures-lite"]
5676

5777
# internal
5878
prodash-render-tui = ["prodash/render-tui", "prodash/render-tui-crossterm", "prodash/progress-tree", "futures-lite"]
@@ -75,6 +95,8 @@ env_logger = { version = "0.9.0", optional = true, default-features = false, fea
7595
crosstermion = { version = "0.9.0", optional = true, default-features = false }
7696
futures-lite = { version = "1.12.0", optional = true, default-features = false, features = ["std"] }
7797

98+
document-features = { version = "0.1.0", optional = true }
99+
78100
[profile.dev.package]
79101
git-object = { opt-level = 3 }
80102
git-ref = { opt-level = 3 }
@@ -140,3 +162,6 @@ members = [
140162
exclude = ["cargo-smart-release/tests/fixtures/tri-depth-workspace/a",
141163
"cargo-smart-release/tests/fixtures/tri-depth-workspace/b",
142164
"cargo-smart-release/tests/fixtures/tri-depth-workspace/c"]
165+
166+
[package.metadata.docs.rs]
167+
features = ["document-features", "max"]

Diff for: cargo-features.md

+1-41
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,7 @@ This guide documents which features are available for each of the crates provide
66

77
### gitoxide
88

9-
The top-level command-line interface.
10-
11-
* **fast**
12-
* Makes the crate execute as fast as possible by supporting parallel computation of otherwise long-running functions
13-
as well as fast, hardware accelerated hashing, along with a faster zlib backend.
14-
* If disabled, the binary will be visibly smaller.
15-
* **http**
16-
* support synchronous 'http' and 'https' transports (e.g. for clone, fetch and push) at the expense of compile times and binary size
17-
* _(mutually exclusive)_
18-
* **pretty-cli**
19-
* Use `clap` 3.0 to build the prettiest, best documented and most user-friendly CLI at the expense of binary size.
20-
* provides a terminal user interface for detailed and exhaustive progress.
21-
* provides a line renderer for leaner progress
22-
* **lean-cli**
23-
* Use `argh` to produce a usable binary with decent documentation that is smallest in size, usually 300kb less than `pretty-cli`.
24-
* If `pretty-cli` is enabled as well, `lean-cli` will take precedence, and you pay for building unnecessary dependencies.
25-
* provides a line renderer for lean but pretty progress
26-
* **prodash-render-line-crossterm**
27-
* The `--verbose` flag will be powered by an interactive progress mechanism that doubles as log as well as interactive progress
28-
that appears after a short duration.
29-
* **gitoxide-core-tools**
30-
* A way to enable all `gitoxide-core` tools found in `gix tools`
31-
* _mutually exclusive_
32-
* If both are set a compile error is triggered. This also means that `cargo … --all-features` will fail.
33-
* **gitoxide-core-blocking-client**
34-
* Use blocking client networking.
35-
* **gitoxide-core-async-client**
36-
* Use async client networking.
37-
38-
There are **convenience features**, which combine common choices of the above into one name
39-
40-
* **max** = *fast* + *prodash-render-tui-crossterm* + *prodash-render-line-crossterm* + *http* + *gitoxide-core-tools* + *client-networking*
41-
* _default_, for unix and windows
42-
* **lean** = *fast* + *prodash-render-line-crossterm* + *gitoxide-core-tools* + *client-networking*
43-
* cross-platform by nature as this comes with simplified log based progress
44-
* **lean-async** = *fast* + *prodash-render-line-crossterm* + *gitoxide-core-tools* + *client-async-networking*
45-
* Due to async client-networking not being implemented for most transports, this one supports only the 'git' transport. It uses, however, a fully asynchronous
46-
networking implementation which can serve a real-world example on how to implement custom async transports.
47-
* **small**
48-
* As small as it can possibly be, no threading, no fast sha1, log based progress only, rust based zlib implementation.
49-
* no networking, local operations only.
9+
Documented in [its documentation](https://docs.rs/gitoxide-core).
5010

5111
### gitoxide-core
5212

Diff for: src/plumbing-cli.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
//! ## Feature Flags
2+
#![cfg_attr(
3+
feature = "document-features",
4+
cfg_attr(doc, doc = ::document_features::document_features!())
5+
)]
16
#![forbid(unsafe_code)]
27
#![deny(rust_2018_idioms)]
38

Diff for: src/porcelain-cli.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
//! ## Feature Flags
2+
#![cfg_attr(
3+
feature = "document-features",
4+
cfg_attr(doc, doc = ::document_features::document_features!())
5+
)]
16
#![forbid(unsafe_code)]
27
#![deny(rust_2018_idioms)]
38

0 commit comments

Comments
 (0)