Skip to content

Commit b64297e

Browse files
committed
docs(gctx): doc for each schema table type
1 parent cce83db commit b64297e

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

src/cargo/util/context/schema.rs

Lines changed: 96 additions & 0 deletions
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
#[serde(rename_all = "kebab-case")]
3144
pub struct CargoHttpConfig {
@@ -41,6 +54,14 @@ pub struct CargoHttpConfig {
4154
pub ssl_version: Option<SslVersionConfig>,
4255
}
4356

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

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

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

303+
/// The `[resolver]` table.
304+
///
305+
/// Example configuration:
306+
///
307+
/// ```toml
308+
/// [resolver]
309+
/// incompatible-rust-versions = "fallback"
310+
/// feature-unification = "workspace"
311+
/// ```
260312
#[derive(Debug, Deserialize)]
261313
#[serde(rename_all = "kebab-case")]
262314
pub struct CargoResolverConfig {
@@ -279,6 +331,17 @@ pub enum FeatureUnification {
279331
Workspace,
280332
}
281333

334+
/// The `[term]` table.
335+
///
336+
/// Example configuration:
337+
///
338+
/// ```toml
339+
/// [term]
340+
/// verbose = false
341+
/// quiet = false
342+
/// color = "auto"
343+
/// progress.when = "auto"
344+
/// ```
282345
#[derive(Deserialize, Default)]
283346
#[serde(rename_all = "kebab-case")]
284347
pub struct TermConfig {
@@ -292,6 +355,20 @@ pub struct TermConfig {
292355
pub progress: Option<ProgressConfig>,
293356
}
294357

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

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

420511
impl EnvConfigValue {
512+
/// Whether this value should override existing environment variables.
421513
pub fn is_force(&self) -> bool {
422514
match self.inner.val {
423515
EnvConfigValueInner::Simple(_) => false,
424516
EnvConfigValueInner::WithOptions { force, .. } => force,
425517
}
426518
}
427519

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

0 commit comments

Comments
 (0)