Skip to content

Commit 89d97f3

Browse files
committed
docs(gctx): doc for each schema table type
1 parent efca7b6 commit 89d97f3

File tree

1 file changed

+96
-1
lines changed

1 file changed

+96
-1
lines changed

src/cargo/util/context/schema.rs

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ use super::StringList;
2626
use super::Value;
2727
use super::path::ConfigRelativePath;
2828

29+
/// The `[http]` table.
30+
///
31+
/// Example configuration:
32+
///
33+
/// ```toml
34+
/// [http]
35+
/// proxy = "host:port"
36+
/// timeout = 30
37+
/// cainfo = "/path/to/ca-bundle.crt"
38+
/// check-revoke = true
39+
/// multiplexing = true
40+
/// ssl-version = "tlsv1.3"
41+
/// ```
2942
#[derive(Debug, Default, Deserialize, PartialEq)]
3043
pub struct CargoHttpConfig {
3144
pub proxy: Option<String>,
@@ -40,6 +53,14 @@ pub struct CargoHttpConfig {
4053
pub ssl_version: Option<SslVersionConfig>,
4154
}
4255

56+
/// The `[future-incompat-report]` stable
57+
///
58+
/// Example configuration:
59+
///
60+
/// ```toml
61+
/// [future-incompat-report]
62+
/// frequency = "always"
63+
/// ```
4364
#[derive(Debug, Default, Deserialize, PartialEq)]
4465
#[serde(rename_all = "kebab-case")]
4566
pub struct CargoFutureIncompatConfig {
@@ -104,6 +125,16 @@ pub struct SslVersionConfigRange {
104125
pub max: Option<String>,
105126
}
106127

128+
/// The `[net]` table.
129+
///
130+
/// Example configuration:
131+
///
132+
/// ```toml
133+
/// [net]
134+
/// retry = 2
135+
/// offline = false
136+
/// git-fetch-with-cli = true
137+
/// ```
107138
#[derive(Debug, Deserialize)]
108139
#[serde(rename_all = "kebab-case")]
109140
pub struct CargoNetConfig {
@@ -149,6 +180,18 @@ impl<'de> Deserialize<'de> for JobsConfig {
149180
}
150181
}
151182

183+
/// The `[build]` table.
184+
///
185+
/// Example configuration:
186+
///
187+
/// ```toml
188+
/// [build]
189+
/// jobs = 4
190+
/// target = "x86_64-unknown-linux-gnu"
191+
/// target-dir = "target"
192+
/// rustflags = ["-C", "link-arg=-fuse-ld=lld"]
193+
/// incremental = true
194+
/// ```
152195
#[derive(Debug, Deserialize)]
153196
#[serde(rename_all = "kebab-case")]
154197
pub struct CargoBuildConfig {
@@ -256,7 +299,15 @@ impl BuildTargetConfig {
256299
}
257300
}
258301

259-
/// Resolver configuration settings.
302+
/// The `[resolver]` table.
303+
///
304+
/// Example configuration:
305+
///
306+
/// ```toml
307+
/// [resolver]
308+
/// incompatible-rust-versions = "fallback"
309+
/// feature-unification = "workspace"
310+
/// ```
260311
#[derive(Debug, Deserialize)]
261312
#[serde(rename_all = "kebab-case")]
262313
pub struct CargoResolverConfig {
@@ -279,6 +330,17 @@ pub enum FeatureUnification {
279330
Workspace,
280331
}
281332

333+
/// The `[term]` table.
334+
///
335+
/// Example configuration:
336+
///
337+
/// ```toml
338+
/// [term]
339+
/// verbose = false
340+
/// quiet = false
341+
/// color = "auto"
342+
/// progress.when = "auto"
343+
/// ```
282344
#[derive(Deserialize, Default)]
283345
#[serde(rename_all = "kebab-case")]
284346
pub struct TermConfig {
@@ -292,6 +354,20 @@ pub struct TermConfig {
292354
pub progress: Option<ProgressConfig>,
293355
}
294356

357+
/// The `term.progress` configuration.
358+
///
359+
/// Example configuration:
360+
///
361+
/// ```toml
362+
/// [term]
363+
/// progress.when = "never" # or "auto"
364+
/// ```
365+
///
366+
/// ```toml
367+
/// # `when = "always"` requires a `width` field
368+
/// [term]
369+
/// progress = { when = "always", width = 80 }
370+
/// ```
295371
#[derive(Debug, Default, Deserialize)]
296372
#[serde(rename_all = "kebab-case")]
297373
pub struct ProgressConfig {
@@ -411,20 +487,39 @@ impl<'de> Deserialize<'de> for EnvConfigValueInner {
411487
}
412488
}
413489

490+
/// Configuration value for environment variables in `[env]` section.
491+
///
492+
/// Supports two formats: simple string and with options.
493+
///
494+
/// ```toml
495+
/// [env]
496+
/// FOO = "value"
497+
/// ```
498+
///
499+
/// ```toml
500+
/// [env]
501+
/// BAR = { value = "relative/path", relative = true }
502+
/// BAZ = { value = "override", force = true }
503+
/// ```
414504
#[derive(Debug, Deserialize)]
415505
#[serde(transparent)]
416506
pub struct EnvConfigValue {
417507
inner: Value<EnvConfigValueInner>,
418508
}
419509

420510
impl EnvConfigValue {
511+
/// Whether this value should override existing environment variables.
421512
pub fn is_force(&self) -> bool {
422513
match self.inner.val {
423514
EnvConfigValueInner::Simple(_) => false,
424515
EnvConfigValueInner::WithOptions { force, .. } => force,
425516
}
426517
}
427518

519+
/// Resolves the environment variable value.
520+
///
521+
/// If `relative = true`,
522+
/// the value is interpreted as a [`ConfigRelativePath`]-like path.
428523
pub fn resolve<'a>(&'a self, cwd: &Path) -> Cow<'a, OsStr> {
429524
match self.inner.val {
430525
EnvConfigValueInner::Simple(ref s) => Cow::Borrowed(OsStr::new(s.as_str())),

0 commit comments

Comments
 (0)