Skip to content

Commit c5ec244

Browse files
committed
feat: improve feature documentation.
This should make optimizing compile time and performance easier, while assuring these options aren't pre-determined by library providers.
1 parent 6b27ffa commit c5ec244

File tree

2 files changed

+91
-52
lines changed

2 files changed

+91
-52
lines changed

gix/Cargo.toml

Lines changed: 85 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,42 @@ required-features = ["blocking-network-client"]
3232

3333
default = ["max-performance-safe", "comfort", "extras"]
3434

35-
#! ### Mutually Exclusive Network Client
36-
#! Either `async-*` or `blocking-*` versions of these toggles may be enabled at a time.
37-
38-
## Make `gix-protocol` available along with an async client.
39-
async-network-client = ["gix-protocol/async-client"]
40-
## Use this if your crate uses `async-std` as runtime, and enable basic runtime integration when connecting to remote servers.
41-
async-network-client-async-std = ["async-std", "async-network-client", "gix-transport/async-std"]
42-
## Make `gix-protocol` available along with a blocking client.
43-
blocking-network-client = ["gix-protocol/blocking-client"]
44-
## Stacks with `blocking-network-client` to provide support for HTTP/S using **curl**, and implies blocking networking as a whole.
45-
blocking-http-transport-curl = ["blocking-network-client", "gix-transport/http-client-curl"]
46-
## Stacks with `blocking-network-client` to provide support for HTTP/S using **reqwest**, and implies blocking networking as a whole.
47-
blocking-http-transport-reqwest = ["blocking-network-client", "gix-transport/http-client-reqwest"]
48-
## Stacks with `blocking-http-transport-reqwest` and enables HTTPS via the `rustls` crate. Note that https isn't available without a selection.
49-
blocking-http-transport-reqwest-rust-tls = ["blocking-http-transport-reqwest", "reqwest-for-configuration-only/rustls-tls", "reqwest-for-configuration-only/trust-dns"]
50-
## Stacks with `blocking-http-transport-reqwest` and enables HTTPS via the `native-tls` crate. Note that https isn't available without a selection.
51-
blocking-http-transport-reqwest-native-tls = ["blocking-http-transport-reqwest", "reqwest-for-configuration-only/default-tls" ]
52-
53-
54-
#! ### Other
35+
#! There are various categories of features which help to optimize performance and build times. `gix` comes with 'batteries included' and everything is
36+
#! enabled as long as it doesn't sacrifice compatibility. Most users will be fine with that but will pay with higher compile times than necessary as they
37+
#! probably don't use all of these features.
38+
#!
39+
#! **Thus it's recommended to take a moment and optimize build times by chosing only those 'Components' that you require.** *'Performance' relevant features should
40+
#! be chosen next to maximize efficiency.*
41+
#!
42+
#! #### Application Developers
43+
#!
44+
#! These are considered the end-users, all they need to tune is `Performance` features to optimize the efficiency of their app, assuming they don't use `gix`
45+
#! directly. Otherwise, see the `Library Developers` paragraph.
46+
#!
47+
#! In order to configure a crate that isn't a direct dependency, one has to make it a direct dependency. We recommend
48+
#! `gix-for-configuration = { package = "gix", version = "X.Y.Z", features = […] }` to make clear this dependency isn't used in code.
49+
#!
50+
#! #### Library Developers
51+
#!
52+
#! As a developer of a library, you should start out with `gix = { version = "X.Y.Z", default-features = false }` and add components as you see fit.
53+
#! For best compatibility, **do not activate `max-performance-safe`** or any other performance options.
54+
#!
55+
#! #### Bundles
56+
#!
57+
#! A bundle is a set of related feature toggles which can be activated with a single name that acts as a group.
58+
#! Bundles are for convenience only and bear no further meaning beyond the cargo manifest file.
5559

5660
## Various additional features and capabilities that are not necessarily part of what most users would need.
5761
extras = ["worktree-stream", "worktree-archive"]
5862

63+
## Various progress-related features that improve the look of progress message units.
64+
comfort = ["gix-features/progress-unit-bytes", "gix-features/progress-unit-human-numbers"]
65+
66+
#! #### Components
67+
#!
68+
#! A component is a distinct feature which may be comprised of one or more methods around a particular topic.
69+
#! Providers of libraries should only activate
70+
5971
## Make it possible to turn a tree into a stream of bytes, which can be decoded to entries and turned into various other formats.
6072
worktree-stream = ["gix-worktree-stream"]
6173

@@ -65,35 +77,32 @@ worktree-stream = ["gix-worktree-stream"]
6577
## Your application should add it as dependency and re-activate the desired features.
6678
worktree-archive = ["gix-archive", "worktree-stream"]
6779

68-
## Various progress-related features that improve the look of progress message units.
69-
comfort = ["gix-features/progress-unit-bytes", "gix-features/progress-unit-human-numbers"]
70-
71-
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
72-
serde = [ "dep:serde",
73-
"gix-pack/serde",
74-
"gix-object/serde",
75-
"gix-protocol?/serde",
76-
"gix-transport?/serde",
77-
"gix-ref/serde",
78-
"gix-odb/serde",
79-
"gix-index/serde",
80-
"gix-mailmap/serde",
81-
"gix-url/serde",
82-
"gix-attributes/serde",
83-
"gix-ignore/serde",
84-
"gix-revision/serde",
85-
"gix-worktree/serde",
86-
"gix-commitgraph/serde",
87-
"gix-credentials/serde"]
80+
#! #### Mutually Exclusive Network Client
81+
#!
82+
#! Either `async-*` or `blocking-*` versions of these toggles may be enabled at a time.
83+
#! For this reason, these must be chosen by the user of the library and can't be pre-selected.
84+
#! Making a choice here also affects which crypto-library ends up being used.
8885

89-
## Re-export the progress tree root which allows to obtain progress from various functions which take `impl gix::Progress`.
90-
## Applications which want to display progress will probably need this implementation.
91-
progress-tree = ["prodash/progress-tree"]
86+
## Make `gix-protocol` available along with an async client.
87+
async-network-client = ["gix-protocol/async-client"]
88+
## Use this if your crate uses `async-std` as runtime, and enable basic runtime integration when connecting to remote servers via the `git://` protocol.
89+
async-network-client-async-std = ["async-std", "async-network-client", "gix-transport/async-std"]
90+
## Make `gix-protocol` available along with a blocking client, providing access to the `file://`, git://` and `ssh://` transports.
91+
blocking-network-client = ["gix-protocol/blocking-client"]
92+
## Stacks with `blocking-network-client` to provide support for HTTP/S using **curl**, and implies blocking networking as a whole, making the `https://` transport avaialble.
93+
blocking-http-transport-curl = ["blocking-network-client", "gix-transport/http-client-curl"]
94+
## Stacks with `blocking-network-client` to provide support for HTTP/S using **reqwest**, and implies blocking networking as a whole, making the `https://` transport avaialble.
95+
blocking-http-transport-reqwest = ["blocking-network-client", "gix-transport/http-client-reqwest"]
96+
## Stacks with `blocking-http-transport-reqwest` and enables `https://` via the `rustls` crate.
97+
blocking-http-transport-reqwest-rust-tls = ["blocking-http-transport-reqwest", "reqwest-for-configuration-only/rustls-tls", "reqwest-for-configuration-only/trust-dns"]
98+
## Stacks with `blocking-http-transport-reqwest` and enables `https://` via the `native-tls` crate.
99+
blocking-http-transport-reqwest-native-tls = ["blocking-http-transport-reqwest", "reqwest-for-configuration-only/default-tls" ]
92100

93-
## Print debugging information about usage of object database caches, useful for tuning cache sizes.
94-
cache-efficiency-debug = ["gix-features/cache-efficiency-debug"]
95101

96-
#! ### Performance
102+
#! #### Performance
103+
#!
104+
#! The reason these features exist is to allow optimization for compile time and optimize for compatibility by default. This means that some performance options around
105+
#! SHA1 and ZIP might not compile on all platforms, so it depeneds on the end-user who compiles the application to chose these based on their needs.
97106

98107
## Activate features that maximize performance, like usage of threads, `zlib-ng` and access to caching in object databases, skipping the ones known to cause compile failures
99108
## on some platforms.
@@ -124,6 +133,36 @@ max-performance = [ "max-performance-safe", "gix-features/zlib-ng", "fast-sha1"
124133
## This might cause compile failures as well which is why it can be turned off separately.
125134
fast-sha1 = [ "gix-features/fast-sha1" ]
126135

136+
#! #### Other
137+
#!
138+
#! The catch-all of feature toggles.
139+
140+
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
141+
serde = [ "dep:serde",
142+
"gix-pack/serde",
143+
"gix-object/serde",
144+
"gix-protocol?/serde",
145+
"gix-transport?/serde",
146+
"gix-ref/serde",
147+
"gix-odb/serde",
148+
"gix-index/serde",
149+
"gix-mailmap/serde",
150+
"gix-url/serde",
151+
"gix-attributes/serde",
152+
"gix-ignore/serde",
153+
"gix-revision/serde",
154+
"gix-worktree/serde",
155+
"gix-commitgraph/serde",
156+
"gix-credentials/serde"]
157+
158+
## Re-export the progress tree root which allows to obtain progress from various functions which take `impl gix::Progress`.
159+
## Applications which want to display progress will probably need this implementation.
160+
progress-tree = ["prodash/progress-tree"]
161+
162+
## Print debugging information about usage of object database caches, useful for tuning cache sizes.
163+
cache-efficiency-debug = ["gix-features/cache-efficiency-debug"]
164+
165+
127166

128167
[dependencies]
129168
gix-utils = { version = "^0.1.5", path = "../gix-utils" }

gix/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! individually. Sometimes it may hide complexity under the assumption that the performance difference doesn't matter
55
//! for all but the fewest tools out there, which would be using the underlying crates directly or file an issue.
66
//!
7-
//! # The prelude and extensions
7+
//! ### The prelude and extensions
88
//!
99
//! With `use git_repository::prelude::*` you should be ready to go as it pulls in various extension traits to make functionality
1010
//! available on objects that may use it.
@@ -14,13 +14,13 @@
1414
//! Most extensions to existing objects provide an `obj_with_extension.attach(&repo).an_easier_version_of_a_method()` for simpler
1515
//! call signatures.
1616
//!
17-
//! ## `ThreadSafe` Mode
17+
//! ### `ThreadSafe` Mode
1818
//!
1919
//! By default, the [`Repository`] isn't `Sync` and thus can't be used in certain contexts which require the `Sync` trait.
2020
//!
2121
//! To help with this, convert it with [`.into_sync()`][Repository::into_sync()] into a [`ThreadSafeRepository`].
2222
//!
23-
//! ## Object-Access Performance
23+
//! ### Object-Access Performance
2424
//!
2525
//! Accessing objects quickly is the bread-and-butter of working with git, right after accessing references. Hence it's vital
2626
//! to understand which cache levels exist and how to leverage them.
@@ -42,9 +42,9 @@
4242
//! When reading the documentation of the canonical gix-worktree program one gets the impression work tree and working tree are used
4343
//! interchangeably. We use the term _work tree_ only and try to do so consistently as its shorter and assumed to be the same.
4444
//!
45-
//! # Cargo-features
45+
//! ### Plumbing Crates
4646
//!
47-
//! To make using _sub-crates_ easier these are re-exported into the root of this crate. Here we list how to access nested plumbing
47+
//! To make using _sub-crates_ and their types easier, these are re-exported into the root of this crate. Here we list how to access nested plumbing
4848
//! crates which are otherwise harder to discover:
4949
//!
5050
//! **`git_repository::`**
@@ -64,7 +64,7 @@
6464
//! * [`git2::build::CheckoutBuilder::disable_filters()](https://docs.rs/git2/*/git2/build/struct.CheckoutBuilder.html#method.disable_filters) ➡ ❌ *(filters are always applied during checkouts)*
6565
//! * [`git2::Repository::submodule_status()`](https://docs.rs/git2/*/git2/struct.Repository.html#method.submodule_status) ➡ [`Submodule::state()`] - status provides more information and conveniences though, and an actual worktree status isn't performed.
6666
//!
67-
//! ## Feature Flags
67+
//! ### Feature Flags
6868
#![cfg_attr(
6969
feature = "document-features",
7070
cfg_attr(doc, doc = ::document_features::document_features!())

0 commit comments

Comments
 (0)