Skip to content

Commit 15ff212

Browse files
committed
feat: in-manifest and in-lib documentation of feature toggles (#329)
1 parent aa3795d commit 15ff212

File tree

4 files changed

+52
-50
lines changed

4 files changed

+52
-50
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-features.md

+1-47
Original file line numberDiff line numberDiff line change
@@ -62,53 +62,7 @@ Documented in [its documentation](https://docs.rs/git-actor).
6262

6363
### git-features
6464

65-
A crate to help controlling which capabilities are available from the top-level crate that uses `gitoxide-core` or any other
66-
`gitoxide` crate that uses `git-features`.
67-
All feature toggles are additive.
68-
69-
* **progress**
70-
* Provide traits and utilities for providing progress information. These can then be rendered using facilities provided by
71-
the `prodash` crate.
72-
* **parallel**
73-
* Use scoped threads and channels to parallelize common workloads on multiple objects. If enabled, it is used everywhere
74-
where it makes sense.
75-
* As caches are likely to be used and instantiated per thread, more memory will be used on top of the costs for threads.
76-
* The `threading` module will contain thread-safe primitives for shared ownership and mutation, otherwise these will be their single threaded counterparts.
77-
* This way, single-threaded applications don't have to pay for threaded primitives.
78-
* **crc32**
79-
* provide a proven and fast `crc32` implementation.
80-
* **io-pipe**
81-
* an in-memory unidirectional pipe using `bytes` as efficient transfer mechanism
82-
* **zlib**
83-
* Enable the usage of zlib related utilities to compress or decompress data.
84-
* By default it uses a pure rust implementation which is slower than the **zlib-ng-compat** version, but might be relevant if you prefer a pure-rust build
85-
and reduced performance is acceptable. Note that a competitive Zlib implementation is critical to `gitoxide's` performance.
86-
* Additional backends are supported, each of which overriding the default Rust backend.
87-
* _mutually-exclusive_
88-
* **zlib-ng-compat**
89-
* Use a C-based backend which can compress and decompress significantly faster.
90-
* **cloudflare-zlib**
91-
* Another incarnation of a faster-than-normal zlib backend.
92-
* **_zlib-rust-backend_**
93-
* available for completeness even though it's the default - it may be chosen for more maintainable feature flags.
94-
95-
* **walkdir**
96-
* Makes facilities of the `walkdir` crate partially available.
97-
* In conjunction with the **parallel** feature, directory walking will be parallel instead behind a compatible interface.
98-
* _mutually-exclusive_
99-
* **fast-sha1**
100-
* a multi-crate implementation that can use hardware acceleration, thus bearing the potential for up to 2Gb/s throughput on
101-
CPUs that support it, like AMD Ryzen or Intel Core i3, as well as Apple Silicon like M1.
102-
* Takes precedence over `rustsha1` if both are specified.
103-
* A fast SHA1 implementation is critical to `gitoxide's` performance
104-
* **rustsha1**
105-
* A standard and well performing pure Rust implementation of Sha1. Will significantly slow down various git operations.
106-
107-
* **cache-efficiency-debug**
108-
* Caches implement this by default, which costs nothing unless this feature is enabled
109-
* Count cache hits and misses and print that debug information on drop
110-
* **time**
111-
* Make the `time` module available with access to the local time as configured by the system.
65+
Documented in [its documentation](https://docs.rs/git-features).
11266

11367
### git-packetline
11468

Diff for: git-features/Cargo.toml

+45-3
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,55 @@ doctest = false
1212
test = false
1313

1414
[features]
15+
1516
default = []
17+
## Provide traits and utilities for providing progress information. These can then be rendered
18+
## using facilities of the `prodash` crate.
1619
progress = ["prodash"]
20+
21+
## Use scoped threads and channels to parallelize common workloads on multiple objects. If enabled, it is used everywhere
22+
## where it makes sense.
23+
## As caches are likely to be used and instantiated per thread, more memory will be used on top of the costs for threads.
24+
## The `threading` module will contain thread-safe primitives for shared ownership and mutation, otherwise these will be their single threaded counterparts.
25+
## This way, single-threaded applications don't have to pay for threaded primitives.
1726
parallel = ["crossbeam-utils", "crossbeam-channel", "num_cpus", "jwalk", "parking_lot"]
18-
fast-sha1 = ["sha-1"]
19-
rustsha1 = ["sha1_smol"]
27+
#* an in-memory unidirectional pipe using `bytes` as efficient transfer mechanism.
2028
io-pipe = ["bytes"]
29+
## provide a proven and fast `crc32` implementation.
2130
crc32 = ["crc32fast"]
31+
32+
#! ### Mutually Exclusive ZLIB
33+
34+
## Enable the usage of zlib related utilities to compress or decompress data.
35+
## By default it uses a pure rust implementation which is slower than the **zlib-ng-compat** version, but might be relevant if you prefer a pure-rust build
36+
## and reduced performance is acceptable. Note that a competitive Zlib implementation is critical to `gitoxide's` object database performance.
37+
## Additional backends are supported, each of which overriding the default Rust backend.
2238
zlib = ["flate2", "flate2/rust_backend", "quick-error"]
39+
## Use a C-based backend which can compress and decompress significantly faster.
2340
zlib-ng-compat = ["flate2/zlib-ng-compat"]
41+
## available for completeness even though it's the default - it may be chosen for more specific feature flag names, instead of a bare `zlib`.
2442
zlib-rust-backend = ["flate2/rust_backend"]
43+
44+
#! ### Mutually Exclusive SHA1
45+
## A fast SHA1 implementation is critical to `gitoxide's` object database performance
46+
## A multi-crate implementation that can use hardware acceleration, thus bearing the potential for up to 2Gb/s throughput on
47+
## CPUs that support it, like AMD Ryzen or Intel Core i3, as well as Apple Silicon like M1.
48+
## Takes precedence over `rustsha1` if both are specified.
49+
fast-sha1 = ["sha-1"]
50+
## A standard and well performing pure Rust implementation of Sha1. Will significantly slow down various git operations.
51+
rustsha1 = ["sha1_smol"]
52+
53+
#! ### Optional Dependencies
54+
#!
55+
#! - **`time`** - make the `time` module available with access to the local time as configured by the system.
56+
#! - **`walkdir`**
57+
#! - Makes facilities of the `walkdir` crate partially available.
58+
#! - In conjunction with the **parallel** feature, directory walking will be parallel instead behind a compatible interface.
59+
60+
#! ### Other
61+
62+
## Count cache hits and misses and print that debug information on drop.
63+
## Caches implement this by default, which costs nothing unless this feature is enabled
2564
cache-efficiency-debug = []
2665

2766
[[test]]
@@ -78,10 +117,13 @@ bytes = { version = "1.0.0", optional = true }
78117
flate2 = { version = "1.0.17", optional = true, default-features = false }
79118
quick-error = { version = "2.0.0", optional = true }
80119

81-
# time module
120+
# time
82121
time = { version = "0.3.2", optional = true, default-features = false, features = ["local-offset"] }
83122

123+
document-features = { version = "0.1.0", optional = true }
124+
84125
[package.metadata.docs.rs]
126+
features = ["document-features"]
85127
all-features = true
86128

87129
# Assembly doesn't yet compile on MSVC on windows, but does on GNU, see https://github.com/RustCrypto/asm-hashes/issues/17

Diff for: git-features/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
//!
99
//! Thus all features provided here commonly have a 'cheap' base implementation, with the option to pull in
1010
//! counterparts with higher performance.
11+
//! ## Feature Flags
12+
#![cfg_attr(
13+
feature = "document-features",
14+
cfg_attr(doc, doc = ::document_features::document_features!())
15+
)]
1116

1217
///
1318
pub mod cache;

0 commit comments

Comments
 (0)