@optique/core 1.4.0-dev.2631 → 1.4.0-dev.2634

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -859,6 +859,14 @@ function applyHiddenToDocEntry(entry, hidden) {
859
859
  term: mergedTerm
860
860
  };
861
861
  }
862
+ function sourceDocumentation(children, hidden) {
863
+ if (require_usage.isDocHidden(hidden)) return {};
864
+ const environmentBindings = children.flatMap((docs) => docs.environmentBindings ?? []);
865
+ return {
866
+ ...environmentBindings.length > 0 && { environmentBindings },
867
+ ...children.length > 0 && children.every((docs) => docs.sourceOnly === true) && { sourceOnly: true }
868
+ };
869
+ }
862
870
  function applyHiddenToDocFragments(fragments, hidden) {
863
871
  if (hidden == null) return fragments;
864
872
  const result = [];
@@ -1835,11 +1843,16 @@ function or(...args) {
1835
1843
  },
1836
1844
  suggest: createExclusiveSuggest(parsers, combinedMode),
1837
1845
  getDocFragments(state, _defaultValue) {
1846
+ const children = [];
1847
+ const collect = (docs) => {
1848
+ children.push(docs);
1849
+ return docs.fragments;
1850
+ };
1838
1851
  let brief;
1839
1852
  let description;
1840
1853
  let footer;
1841
1854
  let fragments;
1842
- if (state.kind === "unavailable" || state.state == null) fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }, void 0).fragments);
1855
+ if (state.kind === "unavailable" || state.state == null) fragments = parsers.flatMap((p) => collect(p.getDocFragments({ kind: "unavailable" }, void 0)));
1843
1856
  else {
1844
1857
  const [index, parserResult] = state.state;
1845
1858
  const innerState = parserResult.success ? {
@@ -1850,10 +1863,11 @@ function or(...args) {
1850
1863
  brief = docFragments.brief;
1851
1864
  description = docFragments.description;
1852
1865
  footer = docFragments.footer;
1853
- fragments = docFragments.fragments;
1866
+ fragments = collect(docFragments);
1854
1867
  }
1855
1868
  if (state.kind === "unavailable" || state.state == null) fragments = require_doc.deduplicateDocFragments(fragments);
1856
1869
  return {
1870
+ ...sourceDocumentation(children),
1857
1871
  brief,
1858
1872
  description,
1859
1873
  footer,
@@ -2044,13 +2058,18 @@ function createLongestMatch(...args) {
2044
2058
  },
2045
2059
  suggest: createExclusiveSuggest(parsers, combinedMode),
2046
2060
  getDocFragments(state, _defaultValue) {
2061
+ const children = [];
2062
+ const collect = (docs) => {
2063
+ children.push(docs);
2064
+ return docs.fragments;
2065
+ };
2047
2066
  let brief;
2048
2067
  let description;
2049
2068
  let footer;
2050
2069
  let fragments;
2051
2070
  let shouldDeduplicate;
2052
2071
  if (state.kind === "unavailable" || state.state == null) {
2053
- fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }).fragments);
2072
+ fragments = parsers.flatMap((p) => collect(p.getDocFragments({ kind: "unavailable" })));
2054
2073
  shouldDeduplicate = true;
2055
2074
  } else {
2056
2075
  const [i, result] = state.state;
@@ -2062,14 +2081,15 @@ function createLongestMatch(...args) {
2062
2081
  brief = docResult.brief;
2063
2082
  description = docResult.description;
2064
2083
  footer = docResult.footer;
2065
- fragments = docResult.fragments;
2084
+ fragments = collect(docResult);
2066
2085
  shouldDeduplicate = false;
2067
2086
  } else {
2068
- fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }).fragments);
2087
+ fragments = parsers.flatMap((p) => collect(p.getDocFragments({ kind: "unavailable" })));
2069
2088
  shouldDeduplicate = true;
2070
2089
  }
2071
2090
  }
2072
2091
  return {
2092
+ ...sourceDocumentation(children),
2073
2093
  brief,
2074
2094
  description,
2075
2095
  fragments: shouldDeduplicate ? require_doc.deduplicateDocFragments(fragments) : fragments,
@@ -3051,12 +3071,17 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
3051
3071
  }, () => suggestObjectAsync(context, prefix, parserPairs));
3052
3072
  },
3053
3073
  getDocFragments(state, defaultValue) {
3074
+ const children = [];
3075
+ const collect = (docs) => {
3076
+ children.push(docs);
3077
+ return docs.fragments;
3078
+ };
3054
3079
  const fragments = parserPairs.flatMap(([field, p]) => {
3055
3080
  const fieldState = state.kind === "unavailable" ? { kind: "unavailable" } : {
3056
3081
  kind: "available",
3057
3082
  state: state.state[field]
3058
3083
  };
3059
- return p.getDocFragments(fieldState, defaultValue?.[field]).fragments;
3084
+ return collect(p.getDocFragments(fieldState, defaultValue?.[field]));
3060
3085
  });
3061
3086
  const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
3062
3087
  const entries = hiddenAwareFragments.filter((d) => d.type === "entry");
@@ -3071,10 +3096,13 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
3071
3096
  entries
3072
3097
  };
3073
3098
  sections.push(section);
3074
- return { fragments: sections.map((s) => ({
3075
- ...s,
3076
- type: "section"
3077
- })) };
3099
+ return {
3100
+ ...sourceDocumentation(children, options.hidden),
3101
+ fragments: sections.map((s) => ({
3102
+ ...s,
3103
+ type: "section"
3104
+ }))
3105
+ };
3078
3106
  }
3079
3107
  };
3080
3108
  const fieldNormalizers = [];
@@ -4064,12 +4092,17 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
4064
4092
  return require_mode_dispatch.dispatchIterableByMode(combinedMode, () => suggestTupleSync(context, prefix, syncParsers), () => suggestTupleAsync(context, prefix, parsers));
4065
4093
  },
4066
4094
  getDocFragments(state, defaultValue) {
4095
+ const children = [];
4096
+ const collect = (docs) => {
4097
+ children.push(docs);
4098
+ return docs.fragments;
4099
+ };
4067
4100
  const fragments = syncParsers.flatMap((p, i) => {
4068
4101
  const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
4069
4102
  kind: "available",
4070
4103
  state: state.state[i]
4071
4104
  };
4072
- return p.getDocFragments(indexState, defaultValue?.[i]).fragments;
4105
+ return collect(p.getDocFragments(indexState, defaultValue?.[i]));
4073
4106
  });
4074
4107
  const entries = fragments.filter((d) => d.type === "entry");
4075
4108
  const sections = [];
@@ -4083,10 +4116,13 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
4083
4116
  entries
4084
4117
  };
4085
4118
  sections.push(section);
4086
- return { fragments: sections.map((s) => ({
4087
- ...s,
4088
- type: "section"
4089
- })) };
4119
+ return {
4120
+ ...sourceDocumentation(children),
4121
+ fragments: sections.map((s) => ({
4122
+ ...s,
4123
+ type: "section"
4124
+ }))
4125
+ };
4090
4126
  },
4091
4127
  [Symbol.for("Deno.customInspect")]() {
4092
4128
  const parsersStr = parsers.length === 1 ? `[1 parser]` : `[${parsers.length} parsers]`;
@@ -4422,12 +4458,17 @@ function seq(...rawArgs) {
4422
4458
  });
4423
4459
  },
4424
4460
  getDocFragments(state, defaultValue) {
4461
+ const children = [];
4462
+ const collect = (docs) => {
4463
+ children.push(docs);
4464
+ return docs.fragments;
4465
+ };
4425
4466
  const fragments = syncParsers.flatMap((parser, index) => {
4426
4467
  const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
4427
4468
  kind: "available",
4428
4469
  state: state.state.states[index]
4429
4470
  };
4430
- return parser.getDocFragments(indexState, defaultValue?.[index]).fragments;
4471
+ return collect(parser.getDocFragments(indexState, defaultValue?.[index]));
4431
4472
  });
4432
4473
  const entries = fragments.filter((d) => d.type === "entry");
4433
4474
  const sections = [];
@@ -4440,10 +4481,13 @@ function seq(...rawArgs) {
4440
4481
  title: label,
4441
4482
  entries
4442
4483
  });
4443
- return { fragments: sections.map((s) => ({
4444
- ...s,
4445
- type: "section"
4446
- })) };
4484
+ return {
4485
+ ...sourceDocumentation(children),
4486
+ fragments: sections.map((s) => ({
4487
+ ...s,
4488
+ type: "section"
4489
+ }))
4490
+ };
4447
4491
  },
4448
4492
  [Symbol.for("Deno.customInspect")]() {
4449
4493
  const parsersStr = parsers.length === 1 ? "1 parser" : `${parsers.length} parsers`;
@@ -5414,6 +5458,11 @@ function merge(...args) {
5414
5458
  }();
5415
5459
  },
5416
5460
  getDocFragments(state, _defaultValue) {
5461
+ const children = [];
5462
+ const collect = (docs) => {
5463
+ children.push(docs);
5464
+ return docs.fragments;
5465
+ };
5417
5466
  let brief;
5418
5467
  let description;
5419
5468
  let footer;
@@ -5434,7 +5483,7 @@ function merge(...args) {
5434
5483
  brief ??= docFragments.brief;
5435
5484
  description ??= docFragments.description;
5436
5485
  footer ??= docFragments.footer;
5437
- return docFragments.fragments;
5486
+ return collect(docFragments);
5438
5487
  });
5439
5488
  const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
5440
5489
  const entries = hiddenAwareFragments.filter((f) => f.type === "entry");
@@ -5451,6 +5500,7 @@ function merge(...args) {
5451
5500
  };
5452
5501
  sections.push(labeledSection);
5453
5502
  return {
5503
+ ...sourceDocumentation(children, options.hidden),
5454
5504
  brief,
5455
5505
  description,
5456
5506
  footer,
@@ -5461,6 +5511,7 @@ function merge(...args) {
5461
5511
  };
5462
5512
  }
5463
5513
  return {
5514
+ ...sourceDocumentation(children, options.hidden),
5464
5515
  brief,
5465
5516
  description,
5466
5517
  footer,
@@ -6077,12 +6128,17 @@ function concat(...parsers) {
6077
6128
  }();
6078
6129
  },
6079
6130
  getDocFragments(state, _defaultValue) {
6131
+ const children = [];
6132
+ const collect = (docs) => {
6133
+ children.push(docs);
6134
+ return docs.fragments;
6135
+ };
6080
6136
  const fragments = syncParsers.flatMap((p, index) => {
6081
6137
  const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
6082
6138
  kind: "available",
6083
6139
  state: state.state[index]
6084
6140
  };
6085
- return p.getDocFragments(indexState, void 0).fragments;
6141
+ return collect(p.getDocFragments(indexState, void 0));
6086
6142
  });
6087
6143
  const entries = fragments.filter((f) => f.type === "entry");
6088
6144
  const sections = [];
@@ -6099,7 +6155,10 @@ function concat(...parsers) {
6099
6155
  type: "section",
6100
6156
  entries
6101
6157
  });
6102
- return { fragments: result };
6158
+ return {
6159
+ ...sourceDocumentation(children),
6160
+ fragments: result
6161
+ };
6103
6162
  }
6104
6163
  };
6105
6164
  require_internal_parser.defineInheritedAnnotationParser(concatParser);
@@ -6136,7 +6195,14 @@ function group(label, parser, options = {}) {
6136
6195
  return parser.suggest(context, prefix);
6137
6196
  },
6138
6197
  getDocFragments: (state, defaultValue) => {
6139
- const { brief, description, footer, fragments } = parser.getDocFragments(state, defaultValue);
6198
+ const children = [];
6199
+ const collect = (docs$1) => {
6200
+ children.push(docs$1);
6201
+ return docs$1.fragments;
6202
+ };
6203
+ const docs = parser.getDocFragments(state, defaultValue);
6204
+ const { brief, description, footer } = docs;
6205
+ const fragments = collect(docs);
6140
6206
  const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
6141
6207
  const allEntries = [];
6142
6208
  const titledSections = [];
@@ -6160,6 +6226,7 @@ function group(label, parser, options = {}) {
6160
6226
  entries: allEntries
6161
6227
  } : { entries: allEntries };
6162
6228
  return {
6229
+ ...sourceDocumentation(children, options.hidden),
6163
6230
  brief,
6164
6231
  description,
6165
6232
  footer,
@@ -7521,11 +7588,17 @@ function conditional(discriminator, branches, defaultBranch, options) {
7521
7588
  return suggestSync(context, prefix);
7522
7589
  },
7523
7590
  getDocFragments(_state, _defaultValue) {
7591
+ const children = [];
7592
+ const collect = (docs) => {
7593
+ children.push(docs);
7594
+ return docs.fragments;
7595
+ };
7524
7596
  const fragments = [];
7525
7597
  const discriminatorFragments = discriminator.getDocFragments({ kind: "unavailable" }, void 0);
7526
- fragments.push(...discriminatorFragments.fragments);
7598
+ fragments.push(...collect(discriminatorFragments));
7527
7599
  for (const [key, branchParser] of branchParsers) {
7528
7600
  const branchFragments = branchParser.getDocFragments({ kind: "unavailable" }, void 0);
7601
+ children.push(branchFragments);
7529
7602
  const entries = branchFragments.fragments.filter((f) => f.type === "entry");
7530
7603
  for (const fragment of branchFragments.fragments) if (fragment.type === "section") entries.push(...fragment.entries);
7531
7604
  if (entries.length > 0) fragments.push({
@@ -7536,6 +7609,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
7536
7609
  }
7537
7610
  if (defaultBranch !== void 0) {
7538
7611
  const defaultFragments = defaultBranch.getDocFragments({ kind: "unavailable" }, void 0);
7612
+ children.push(defaultFragments);
7539
7613
  const entries = defaultFragments.fragments.filter((f) => f.type === "entry");
7540
7614
  for (const fragment of defaultFragments.fragments) if (fragment.type === "section") entries.push(...fragment.entries);
7541
7615
  if (entries.length > 0) fragments.push({
@@ -7544,7 +7618,10 @@ function conditional(discriminator, branches, defaultBranch, options) {
7544
7618
  entries
7545
7619
  });
7546
7620
  }
7547
- return { fragments };
7621
+ return {
7622
+ ...sourceDocumentation(children),
7623
+ fragments
7624
+ };
7548
7625
  }
7549
7626
  };
7550
7627
  require_internal_parser.defineInheritedAnnotationParser(conditionalParser);
@@ -859,6 +859,14 @@ function applyHiddenToDocEntry(entry, hidden) {
859
859
  term: mergedTerm
860
860
  };
861
861
  }
862
+ function sourceDocumentation(children, hidden) {
863
+ if (isDocHidden(hidden)) return {};
864
+ const environmentBindings = children.flatMap((docs) => docs.environmentBindings ?? []);
865
+ return {
866
+ ...environmentBindings.length > 0 && { environmentBindings },
867
+ ...children.length > 0 && children.every((docs) => docs.sourceOnly === true) && { sourceOnly: true }
868
+ };
869
+ }
862
870
  function applyHiddenToDocFragments(fragments, hidden) {
863
871
  if (hidden == null) return fragments;
864
872
  const result = [];
@@ -1835,11 +1843,16 @@ function or(...args) {
1835
1843
  },
1836
1844
  suggest: createExclusiveSuggest(parsers, combinedMode),
1837
1845
  getDocFragments(state, _defaultValue) {
1846
+ const children = [];
1847
+ const collect = (docs) => {
1848
+ children.push(docs);
1849
+ return docs.fragments;
1850
+ };
1838
1851
  let brief;
1839
1852
  let description;
1840
1853
  let footer;
1841
1854
  let fragments;
1842
- if (state.kind === "unavailable" || state.state == null) fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }, void 0).fragments);
1855
+ if (state.kind === "unavailable" || state.state == null) fragments = parsers.flatMap((p) => collect(p.getDocFragments({ kind: "unavailable" }, void 0)));
1843
1856
  else {
1844
1857
  const [index, parserResult] = state.state;
1845
1858
  const innerState = parserResult.success ? {
@@ -1850,10 +1863,11 @@ function or(...args) {
1850
1863
  brief = docFragments.brief;
1851
1864
  description = docFragments.description;
1852
1865
  footer = docFragments.footer;
1853
- fragments = docFragments.fragments;
1866
+ fragments = collect(docFragments);
1854
1867
  }
1855
1868
  if (state.kind === "unavailable" || state.state == null) fragments = deduplicateDocFragments(fragments);
1856
1869
  return {
1870
+ ...sourceDocumentation(children),
1857
1871
  brief,
1858
1872
  description,
1859
1873
  footer,
@@ -2044,13 +2058,18 @@ function createLongestMatch(...args) {
2044
2058
  },
2045
2059
  suggest: createExclusiveSuggest(parsers, combinedMode),
2046
2060
  getDocFragments(state, _defaultValue) {
2061
+ const children = [];
2062
+ const collect = (docs) => {
2063
+ children.push(docs);
2064
+ return docs.fragments;
2065
+ };
2047
2066
  let brief;
2048
2067
  let description;
2049
2068
  let footer;
2050
2069
  let fragments;
2051
2070
  let shouldDeduplicate;
2052
2071
  if (state.kind === "unavailable" || state.state == null) {
2053
- fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }).fragments);
2072
+ fragments = parsers.flatMap((p) => collect(p.getDocFragments({ kind: "unavailable" })));
2054
2073
  shouldDeduplicate = true;
2055
2074
  } else {
2056
2075
  const [i, result] = state.state;
@@ -2062,14 +2081,15 @@ function createLongestMatch(...args) {
2062
2081
  brief = docResult.brief;
2063
2082
  description = docResult.description;
2064
2083
  footer = docResult.footer;
2065
- fragments = docResult.fragments;
2084
+ fragments = collect(docResult);
2066
2085
  shouldDeduplicate = false;
2067
2086
  } else {
2068
- fragments = parsers.flatMap((p) => p.getDocFragments({ kind: "unavailable" }).fragments);
2087
+ fragments = parsers.flatMap((p) => collect(p.getDocFragments({ kind: "unavailable" })));
2069
2088
  shouldDeduplicate = true;
2070
2089
  }
2071
2090
  }
2072
2091
  return {
2092
+ ...sourceDocumentation(children),
2073
2093
  brief,
2074
2094
  description,
2075
2095
  fragments: shouldDeduplicate ? deduplicateDocFragments(fragments) : fragments,
@@ -3051,12 +3071,17 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
3051
3071
  }, () => suggestObjectAsync(context, prefix, parserPairs));
3052
3072
  },
3053
3073
  getDocFragments(state, defaultValue) {
3074
+ const children = [];
3075
+ const collect = (docs) => {
3076
+ children.push(docs);
3077
+ return docs.fragments;
3078
+ };
3054
3079
  const fragments = parserPairs.flatMap(([field, p]) => {
3055
3080
  const fieldState = state.kind === "unavailable" ? { kind: "unavailable" } : {
3056
3081
  kind: "available",
3057
3082
  state: state.state[field]
3058
3083
  };
3059
- return p.getDocFragments(fieldState, defaultValue?.[field]).fragments;
3084
+ return collect(p.getDocFragments(fieldState, defaultValue?.[field]));
3060
3085
  });
3061
3086
  const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
3062
3087
  const entries = hiddenAwareFragments.filter((d) => d.type === "entry");
@@ -3071,10 +3096,13 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
3071
3096
  entries
3072
3097
  };
3073
3098
  sections.push(section);
3074
- return { fragments: sections.map((s) => ({
3075
- ...s,
3076
- type: "section"
3077
- })) };
3099
+ return {
3100
+ ...sourceDocumentation(children, options.hidden),
3101
+ fragments: sections.map((s) => ({
3102
+ ...s,
3103
+ type: "section"
3104
+ }))
3105
+ };
3078
3106
  }
3079
3107
  };
3080
3108
  const fieldNormalizers = [];
@@ -4064,12 +4092,17 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
4064
4092
  return dispatchIterableByMode(combinedMode, () => suggestTupleSync(context, prefix, syncParsers), () => suggestTupleAsync(context, prefix, parsers));
4065
4093
  },
4066
4094
  getDocFragments(state, defaultValue) {
4095
+ const children = [];
4096
+ const collect = (docs) => {
4097
+ children.push(docs);
4098
+ return docs.fragments;
4099
+ };
4067
4100
  const fragments = syncParsers.flatMap((p, i) => {
4068
4101
  const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
4069
4102
  kind: "available",
4070
4103
  state: state.state[i]
4071
4104
  };
4072
- return p.getDocFragments(indexState, defaultValue?.[i]).fragments;
4105
+ return collect(p.getDocFragments(indexState, defaultValue?.[i]));
4073
4106
  });
4074
4107
  const entries = fragments.filter((d) => d.type === "entry");
4075
4108
  const sections = [];
@@ -4083,10 +4116,13 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
4083
4116
  entries
4084
4117
  };
4085
4118
  sections.push(section);
4086
- return { fragments: sections.map((s) => ({
4087
- ...s,
4088
- type: "section"
4089
- })) };
4119
+ return {
4120
+ ...sourceDocumentation(children),
4121
+ fragments: sections.map((s) => ({
4122
+ ...s,
4123
+ type: "section"
4124
+ }))
4125
+ };
4090
4126
  },
4091
4127
  [Symbol.for("Deno.customInspect")]() {
4092
4128
  const parsersStr = parsers.length === 1 ? `[1 parser]` : `[${parsers.length} parsers]`;
@@ -4422,12 +4458,17 @@ function seq(...rawArgs) {
4422
4458
  });
4423
4459
  },
4424
4460
  getDocFragments(state, defaultValue) {
4461
+ const children = [];
4462
+ const collect = (docs) => {
4463
+ children.push(docs);
4464
+ return docs.fragments;
4465
+ };
4425
4466
  const fragments = syncParsers.flatMap((parser, index) => {
4426
4467
  const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
4427
4468
  kind: "available",
4428
4469
  state: state.state.states[index]
4429
4470
  };
4430
- return parser.getDocFragments(indexState, defaultValue?.[index]).fragments;
4471
+ return collect(parser.getDocFragments(indexState, defaultValue?.[index]));
4431
4472
  });
4432
4473
  const entries = fragments.filter((d) => d.type === "entry");
4433
4474
  const sections = [];
@@ -4440,10 +4481,13 @@ function seq(...rawArgs) {
4440
4481
  title: label,
4441
4482
  entries
4442
4483
  });
4443
- return { fragments: sections.map((s) => ({
4444
- ...s,
4445
- type: "section"
4446
- })) };
4484
+ return {
4485
+ ...sourceDocumentation(children),
4486
+ fragments: sections.map((s) => ({
4487
+ ...s,
4488
+ type: "section"
4489
+ }))
4490
+ };
4447
4491
  },
4448
4492
  [Symbol.for("Deno.customInspect")]() {
4449
4493
  const parsersStr = parsers.length === 1 ? "1 parser" : `${parsers.length} parsers`;
@@ -5414,6 +5458,11 @@ function merge(...args) {
5414
5458
  }();
5415
5459
  },
5416
5460
  getDocFragments(state, _defaultValue) {
5461
+ const children = [];
5462
+ const collect = (docs) => {
5463
+ children.push(docs);
5464
+ return docs.fragments;
5465
+ };
5417
5466
  let brief;
5418
5467
  let description;
5419
5468
  let footer;
@@ -5434,7 +5483,7 @@ function merge(...args) {
5434
5483
  brief ??= docFragments.brief;
5435
5484
  description ??= docFragments.description;
5436
5485
  footer ??= docFragments.footer;
5437
- return docFragments.fragments;
5486
+ return collect(docFragments);
5438
5487
  });
5439
5488
  const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
5440
5489
  const entries = hiddenAwareFragments.filter((f) => f.type === "entry");
@@ -5451,6 +5500,7 @@ function merge(...args) {
5451
5500
  };
5452
5501
  sections.push(labeledSection);
5453
5502
  return {
5503
+ ...sourceDocumentation(children, options.hidden),
5454
5504
  brief,
5455
5505
  description,
5456
5506
  footer,
@@ -5461,6 +5511,7 @@ function merge(...args) {
5461
5511
  };
5462
5512
  }
5463
5513
  return {
5514
+ ...sourceDocumentation(children, options.hidden),
5464
5515
  brief,
5465
5516
  description,
5466
5517
  footer,
@@ -6077,12 +6128,17 @@ function concat(...parsers) {
6077
6128
  }();
6078
6129
  },
6079
6130
  getDocFragments(state, _defaultValue) {
6131
+ const children = [];
6132
+ const collect = (docs) => {
6133
+ children.push(docs);
6134
+ return docs.fragments;
6135
+ };
6080
6136
  const fragments = syncParsers.flatMap((p, index) => {
6081
6137
  const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
6082
6138
  kind: "available",
6083
6139
  state: state.state[index]
6084
6140
  };
6085
- return p.getDocFragments(indexState, void 0).fragments;
6141
+ return collect(p.getDocFragments(indexState, void 0));
6086
6142
  });
6087
6143
  const entries = fragments.filter((f) => f.type === "entry");
6088
6144
  const sections = [];
@@ -6099,7 +6155,10 @@ function concat(...parsers) {
6099
6155
  type: "section",
6100
6156
  entries
6101
6157
  });
6102
- return { fragments: result };
6158
+ return {
6159
+ ...sourceDocumentation(children),
6160
+ fragments: result
6161
+ };
6103
6162
  }
6104
6163
  };
6105
6164
  defineInheritedAnnotationParser(concatParser);
@@ -6136,7 +6195,14 @@ function group(label, parser, options = {}) {
6136
6195
  return parser.suggest(context, prefix);
6137
6196
  },
6138
6197
  getDocFragments: (state, defaultValue) => {
6139
- const { brief, description, footer, fragments } = parser.getDocFragments(state, defaultValue);
6198
+ const children = [];
6199
+ const collect = (docs$1) => {
6200
+ children.push(docs$1);
6201
+ return docs$1.fragments;
6202
+ };
6203
+ const docs = parser.getDocFragments(state, defaultValue);
6204
+ const { brief, description, footer } = docs;
6205
+ const fragments = collect(docs);
6140
6206
  const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
6141
6207
  const allEntries = [];
6142
6208
  const titledSections = [];
@@ -6160,6 +6226,7 @@ function group(label, parser, options = {}) {
6160
6226
  entries: allEntries
6161
6227
  } : { entries: allEntries };
6162
6228
  return {
6229
+ ...sourceDocumentation(children, options.hidden),
6163
6230
  brief,
6164
6231
  description,
6165
6232
  footer,
@@ -7521,11 +7588,17 @@ function conditional(discriminator, branches, defaultBranch, options) {
7521
7588
  return suggestSync(context, prefix);
7522
7589
  },
7523
7590
  getDocFragments(_state, _defaultValue) {
7591
+ const children = [];
7592
+ const collect = (docs) => {
7593
+ children.push(docs);
7594
+ return docs.fragments;
7595
+ };
7524
7596
  const fragments = [];
7525
7597
  const discriminatorFragments = discriminator.getDocFragments({ kind: "unavailable" }, void 0);
7526
- fragments.push(...discriminatorFragments.fragments);
7598
+ fragments.push(...collect(discriminatorFragments));
7527
7599
  for (const [key, branchParser] of branchParsers) {
7528
7600
  const branchFragments = branchParser.getDocFragments({ kind: "unavailable" }, void 0);
7601
+ children.push(branchFragments);
7529
7602
  const entries = branchFragments.fragments.filter((f) => f.type === "entry");
7530
7603
  for (const fragment of branchFragments.fragments) if (fragment.type === "section") entries.push(...fragment.entries);
7531
7604
  if (entries.length > 0) fragments.push({
@@ -7536,6 +7609,7 @@ function conditional(discriminator, branches, defaultBranch, options) {
7536
7609
  }
7537
7610
  if (defaultBranch !== void 0) {
7538
7611
  const defaultFragments = defaultBranch.getDocFragments({ kind: "unavailable" }, void 0);
7612
+ children.push(defaultFragments);
7539
7613
  const entries = defaultFragments.fragments.filter((f) => f.type === "entry");
7540
7614
  for (const fragment of defaultFragments.fragments) if (fragment.type === "section") entries.push(...fragment.entries);
7541
7615
  if (entries.length > 0) fragments.push({
@@ -7544,7 +7618,10 @@ function conditional(discriminator, branches, defaultBranch, options) {
7544
7618
  entries
7545
7619
  });
7546
7620
  }
7547
- return { fragments };
7621
+ return {
7622
+ ...sourceDocumentation(children),
7623
+ fragments
7624
+ };
7548
7625
  }
7549
7626
  };
7550
7627
  defineInheritedAnnotationParser(conditionalParser);
package/dist/doc.cjs CHANGED
@@ -149,16 +149,17 @@ function cloneDocEntry(entry) {
149
149
  * Names are grouped in first-appearance order with references to their
150
150
  * associated entries. Empty names and hidden or empty terms are ignored.
151
151
  * This does not read environment values or modify the page. Entries without
152
- * CLI documentation, such as `bindEnv(fail(), ...)`, are not collected.
152
+ * CLI documentation are collected through `environmentBindings`.
153
153
  *
154
154
  * @param page The documentation page to inspect.
155
- * @param options An optional heading for the generated section.
155
+ * @param options A heading and optional filter for names without CLI references.
156
156
  * @returns A new section, or `undefined` when there are no visible names.
157
157
  * @throws {TypeError} If a used title is empty or contains control characters.
158
158
  * @since 1.4.0
159
159
  */
160
160
  function deriveEnvironmentSection(page, options = {}) {
161
161
  const bindings = /* @__PURE__ */ new Map();
162
+ const purposes = /* @__PURE__ */ new Map();
162
163
  for (const section of page.sections) for (const entry of section.entries) {
163
164
  if (isDocEntryHidden(entry)) continue;
164
165
  const rendered = require_usage.formatUsageTerm(entry.term, { context: "doc" });
@@ -175,18 +176,55 @@ function deriveEnvironmentSection(page, options = {}) {
175
176
  references.set(rendered, reference);
176
177
  }
177
178
  }
178
- if (bindings.size === 0) return void 0;
179
+ for (const binding of page.environmentBindings ?? []) {
180
+ if (binding.name === "" || require_usage.isDocHidden(binding.hidden)) continue;
181
+ if (!bindings.has(binding.name)) bindings.set(binding.name, /* @__PURE__ */ new Map());
182
+ const description = binding.description;
183
+ if (description == null || description.length === 0) continue;
184
+ let descriptions = purposes.get(binding.name);
185
+ if (descriptions == null) {
186
+ descriptions = /* @__PURE__ */ new Map();
187
+ purposes.set(binding.name, descriptions);
188
+ }
189
+ const key = JSON.stringify(description.map((term) => {
190
+ switch (term.type) {
191
+ case "text": return [term.type, term.text];
192
+ case "optionName": return [term.type, term.optionName];
193
+ case "optionNames": return [term.type, term.optionNames];
194
+ case "metavar": return [term.type, term.metavar];
195
+ case "value": return [term.type, term.value];
196
+ case "values": return [term.type, term.values];
197
+ case "envVar": return [term.type, term.envVar];
198
+ case "commandLine": return [term.type, term.commandLine];
199
+ case "lineBreak": return [term.type];
200
+ case "url": return [term.type, term.url.href];
201
+ }
202
+ }));
203
+ descriptions.set(key, description);
204
+ }
205
+ const collected = Array.from(bindings).filter(([, references]) => !options.onlyUnreferenced || references.size === 0);
206
+ if (collected.length === 0) return void 0;
179
207
  const title = options.title ?? "Environment";
180
208
  require_validate.validateLabel(title);
181
209
  return {
182
210
  title,
183
- entries: Array.from(bindings, ([name, references]) => ({
184
- term: {
185
- type: "literal",
186
- value: name
187
- },
188
- description: Array.from(references.values()).flatMap((reference, i) => i === 0 ? reference : [require_message.text(", "), ...reference])
189
- }))
211
+ entries: collected.map(([name, references]) => {
212
+ const purpose = Array.from(purposes.get(name)?.values() ?? []).flatMap((description$1, i) => i === 0 ? description$1 : [{ type: "lineBreak" }, ...description$1]);
213
+ const refs = Array.from(references.values()).flatMap((ref, i) => i === 0 ? ref : [require_message.text(", "), ...ref]);
214
+ const description = purpose.length === 0 ? refs : refs.length === 0 ? purpose : [
215
+ ...purpose,
216
+ { type: "lineBreak" },
217
+ require_message.text("CLI: "),
218
+ ...refs
219
+ ];
220
+ return {
221
+ term: {
222
+ type: "literal",
223
+ value: name
224
+ },
225
+ ...description.length > 0 && { description }
226
+ };
227
+ })
190
228
  };
191
229
  }
192
230
  /**
@@ -318,10 +356,13 @@ function formatDocPage(programName, page, options = {}) {
318
356
  return rendered.trim() !== "";
319
357
  })
320
358
  }));
321
- const environmentSection = environmentPlacement === "section" || environmentPlacement === "both" ? deriveEnvironmentSection({
359
+ const environmentSection = environmentPlacement != null ? deriveEnvironmentSection({
322
360
  ...page,
323
361
  sections: filteredSections
324
- }, { title: typeof options.showEnvironment === "object" ? options.showEnvironment.sectionTitle : void 0 }) : void 0;
362
+ }, {
363
+ onlyUnreferenced: environmentPlacement === "inline",
364
+ title: typeof options.showEnvironment === "object" ? options.showEnvironment.sectionTitle : void 0
365
+ }) : void 0;
325
366
  page = {
326
367
  ...page,
327
368
  sections: environmentSection == null ? filteredSections : [...filteredSections, environmentSection]
package/dist/doc.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Message, MessageFormatter } from "./message.cjs";
2
2
  import { TerminalTheme } from "./terminal.cjs";
3
- import { Usage, UsageTerm } from "./usage.cjs";
3
+ import { HiddenVisibility, Usage, UsageTerm } from "./usage.cjs";
4
4
 
5
5
  //#region src/doc.d.ts
6
6
 
@@ -49,12 +49,27 @@ interface DocSection {
49
49
  readonly title?: string;
50
50
  readonly entries: readonly DocEntry[];
51
51
  }
52
+ /**
53
+ * A declared environment binding, independent of CLI documentation entries.
54
+ * Names describe possible sources, not whether they are read during parsing.
55
+ * @since 1.4.0
56
+ */
57
+ interface EnvironmentBindingDoc {
58
+ /** The full variable name, including any prefix. */
59
+ readonly name: string;
60
+ /** Purpose text supplied by the binding author, without inferred values. */
61
+ readonly description?: Message;
62
+ /** Visibility in documentation; `"usage"` remains visible. */
63
+ readonly hidden?: HiddenVisibility;
64
+ }
52
65
  /**
53
66
  * A document page that contains multiple sections, each with its own brief
54
67
  * and a list of entries. This structure is used to organize documentation
55
68
  * for commands, options, and other related information.
56
69
  */
57
70
  interface DocPage {
71
+ /** Independent environment documentation in this page's scope. @since 1.4.0 */
72
+ readonly environmentBindings?: readonly EnvironmentBindingDoc[];
58
73
  readonly brief?: Message;
59
74
  readonly usage?: Usage;
60
75
  readonly description?: Message;
@@ -91,6 +106,15 @@ type DocFragment = {
91
106
  * a final document page.
92
107
  */
93
108
  interface DocFragments {
109
+ /** Independent environment documentation in this scope. @since 1.4.0 */
110
+ readonly environmentBindings?: readonly EnvironmentBindingDoc[];
111
+ /**
112
+ * Positive permission for source-only bindings to document this scope.
113
+ * Empty fragments alone do not imply this capability. Custom combinators
114
+ * must preserve it deliberately, respecting scope and hidden parents.
115
+ * @since 1.4.0
116
+ */
117
+ readonly sourceOnly?: true;
94
118
  /**
95
119
  * An optional brief that provides a short summary for the collection
96
120
  * of fragments.
@@ -173,16 +197,17 @@ interface ShowEnvironmentOptions {
173
197
  * Names are grouped in first-appearance order with references to their
174
198
  * associated entries. Empty names and hidden or empty terms are ignored.
175
199
  * This does not read environment values or modify the page. Entries without
176
- * CLI documentation, such as `bindEnv(fail(), ...)`, are not collected.
200
+ * CLI documentation are collected through `environmentBindings`.
177
201
  *
178
202
  * @param page The documentation page to inspect.
179
- * @param options An optional heading for the generated section.
203
+ * @param options A heading and optional filter for names without CLI references.
180
204
  * @returns A new section, or `undefined` when there are no visible names.
181
205
  * @throws {TypeError} If a used title is empty or contains control characters.
182
206
  * @since 1.4.0
183
207
  */
184
208
  declare function deriveEnvironmentSection(page: DocPage, options?: {
185
209
  readonly title?: string;
210
+ readonly onlyUnreferenced?: boolean;
186
211
  }): DocSection | undefined;
187
212
  /**
188
213
  * Configuration for customizing default value display formatting.
@@ -242,7 +267,8 @@ interface ShowChoicesOptions {
242
267
  interface DocPageFormatOptions {
243
268
  /**
244
269
  * Displays declared environment bindings. `true` or `{}` selects inline
245
- * annotations; `placement` can select a section or both. Defaults to `false`.
270
+ * annotations; `placement` can select a section or both. Unreferenced names
271
+ * get a fallback section in inline mode. Defaults to `false`.
246
272
  * Generated sections follow the regular sections, before examples, and are
247
273
  * not passed to `sectionOrder`. The original page is not modified.
248
274
  * @since 1.4.0
@@ -403,4 +429,4 @@ interface DocPageFormatOptions {
403
429
  */
404
430
  declare function formatDocPage(programName: string, page: DocPage, options?: DocPageFormatOptions): string;
405
431
  //#endregion
406
- export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden };
432
+ export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, EnvironmentBindingDoc, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden };
package/dist/doc.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Message, MessageFormatter } from "./message.js";
2
2
  import { TerminalTheme } from "./terminal.js";
3
- import { Usage, UsageTerm } from "./usage.js";
3
+ import { HiddenVisibility, Usage, UsageTerm } from "./usage.js";
4
4
 
5
5
  //#region src/doc.d.ts
6
6
 
@@ -49,12 +49,27 @@ interface DocSection {
49
49
  readonly title?: string;
50
50
  readonly entries: readonly DocEntry[];
51
51
  }
52
+ /**
53
+ * A declared environment binding, independent of CLI documentation entries.
54
+ * Names describe possible sources, not whether they are read during parsing.
55
+ * @since 1.4.0
56
+ */
57
+ interface EnvironmentBindingDoc {
58
+ /** The full variable name, including any prefix. */
59
+ readonly name: string;
60
+ /** Purpose text supplied by the binding author, without inferred values. */
61
+ readonly description?: Message;
62
+ /** Visibility in documentation; `"usage"` remains visible. */
63
+ readonly hidden?: HiddenVisibility;
64
+ }
52
65
  /**
53
66
  * A document page that contains multiple sections, each with its own brief
54
67
  * and a list of entries. This structure is used to organize documentation
55
68
  * for commands, options, and other related information.
56
69
  */
57
70
  interface DocPage {
71
+ /** Independent environment documentation in this page's scope. @since 1.4.0 */
72
+ readonly environmentBindings?: readonly EnvironmentBindingDoc[];
58
73
  readonly brief?: Message;
59
74
  readonly usage?: Usage;
60
75
  readonly description?: Message;
@@ -91,6 +106,15 @@ type DocFragment = {
91
106
  * a final document page.
92
107
  */
93
108
  interface DocFragments {
109
+ /** Independent environment documentation in this scope. @since 1.4.0 */
110
+ readonly environmentBindings?: readonly EnvironmentBindingDoc[];
111
+ /**
112
+ * Positive permission for source-only bindings to document this scope.
113
+ * Empty fragments alone do not imply this capability. Custom combinators
114
+ * must preserve it deliberately, respecting scope and hidden parents.
115
+ * @since 1.4.0
116
+ */
117
+ readonly sourceOnly?: true;
94
118
  /**
95
119
  * An optional brief that provides a short summary for the collection
96
120
  * of fragments.
@@ -173,16 +197,17 @@ interface ShowEnvironmentOptions {
173
197
  * Names are grouped in first-appearance order with references to their
174
198
  * associated entries. Empty names and hidden or empty terms are ignored.
175
199
  * This does not read environment values or modify the page. Entries without
176
- * CLI documentation, such as `bindEnv(fail(), ...)`, are not collected.
200
+ * CLI documentation are collected through `environmentBindings`.
177
201
  *
178
202
  * @param page The documentation page to inspect.
179
- * @param options An optional heading for the generated section.
203
+ * @param options A heading and optional filter for names without CLI references.
180
204
  * @returns A new section, or `undefined` when there are no visible names.
181
205
  * @throws {TypeError} If a used title is empty or contains control characters.
182
206
  * @since 1.4.0
183
207
  */
184
208
  declare function deriveEnvironmentSection(page: DocPage, options?: {
185
209
  readonly title?: string;
210
+ readonly onlyUnreferenced?: boolean;
186
211
  }): DocSection | undefined;
187
212
  /**
188
213
  * Configuration for customizing default value display formatting.
@@ -242,7 +267,8 @@ interface ShowChoicesOptions {
242
267
  interface DocPageFormatOptions {
243
268
  /**
244
269
  * Displays declared environment bindings. `true` or `{}` selects inline
245
- * annotations; `placement` can select a section or both. Defaults to `false`.
270
+ * annotations; `placement` can select a section or both. Unreferenced names
271
+ * get a fallback section in inline mode. Defaults to `false`.
246
272
  * Generated sections follow the regular sections, before examples, and are
247
273
  * not passed to `sectionOrder`. The original page is not modified.
248
274
  * @since 1.4.0
@@ -403,4 +429,4 @@ interface DocPageFormatOptions {
403
429
  */
404
430
  declare function formatDocPage(programName: string, page: DocPage, options?: DocPageFormatOptions): string;
405
431
  //#endregion
406
- export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden };
432
+ export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, EnvironmentBindingDoc, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden };
package/dist/doc.js CHANGED
@@ -149,16 +149,17 @@ function cloneDocEntry(entry) {
149
149
  * Names are grouped in first-appearance order with references to their
150
150
  * associated entries. Empty names and hidden or empty terms are ignored.
151
151
  * This does not read environment values or modify the page. Entries without
152
- * CLI documentation, such as `bindEnv(fail(), ...)`, are not collected.
152
+ * CLI documentation are collected through `environmentBindings`.
153
153
  *
154
154
  * @param page The documentation page to inspect.
155
- * @param options An optional heading for the generated section.
155
+ * @param options A heading and optional filter for names without CLI references.
156
156
  * @returns A new section, or `undefined` when there are no visible names.
157
157
  * @throws {TypeError} If a used title is empty or contains control characters.
158
158
  * @since 1.4.0
159
159
  */
160
160
  function deriveEnvironmentSection(page, options = {}) {
161
161
  const bindings = /* @__PURE__ */ new Map();
162
+ const purposes = /* @__PURE__ */ new Map();
162
163
  for (const section of page.sections) for (const entry of section.entries) {
163
164
  if (isDocEntryHidden(entry)) continue;
164
165
  const rendered = formatUsageTerm(entry.term, { context: "doc" });
@@ -175,18 +176,55 @@ function deriveEnvironmentSection(page, options = {}) {
175
176
  references.set(rendered, reference);
176
177
  }
177
178
  }
178
- if (bindings.size === 0) return void 0;
179
+ for (const binding of page.environmentBindings ?? []) {
180
+ if (binding.name === "" || isDocHidden(binding.hidden)) continue;
181
+ if (!bindings.has(binding.name)) bindings.set(binding.name, /* @__PURE__ */ new Map());
182
+ const description = binding.description;
183
+ if (description == null || description.length === 0) continue;
184
+ let descriptions = purposes.get(binding.name);
185
+ if (descriptions == null) {
186
+ descriptions = /* @__PURE__ */ new Map();
187
+ purposes.set(binding.name, descriptions);
188
+ }
189
+ const key = JSON.stringify(description.map((term) => {
190
+ switch (term.type) {
191
+ case "text": return [term.type, term.text];
192
+ case "optionName": return [term.type, term.optionName];
193
+ case "optionNames": return [term.type, term.optionNames];
194
+ case "metavar": return [term.type, term.metavar];
195
+ case "value": return [term.type, term.value];
196
+ case "values": return [term.type, term.values];
197
+ case "envVar": return [term.type, term.envVar];
198
+ case "commandLine": return [term.type, term.commandLine];
199
+ case "lineBreak": return [term.type];
200
+ case "url": return [term.type, term.url.href];
201
+ }
202
+ }));
203
+ descriptions.set(key, description);
204
+ }
205
+ const collected = Array.from(bindings).filter(([, references]) => !options.onlyUnreferenced || references.size === 0);
206
+ if (collected.length === 0) return void 0;
179
207
  const title = options.title ?? "Environment";
180
208
  validateLabel(title);
181
209
  return {
182
210
  title,
183
- entries: Array.from(bindings, ([name, references]) => ({
184
- term: {
185
- type: "literal",
186
- value: name
187
- },
188
- description: Array.from(references.values()).flatMap((reference, i) => i === 0 ? reference : [text(", "), ...reference])
189
- }))
211
+ entries: collected.map(([name, references]) => {
212
+ const purpose = Array.from(purposes.get(name)?.values() ?? []).flatMap((description$1, i) => i === 0 ? description$1 : [{ type: "lineBreak" }, ...description$1]);
213
+ const refs = Array.from(references.values()).flatMap((ref, i) => i === 0 ? ref : [text(", "), ...ref]);
214
+ const description = purpose.length === 0 ? refs : refs.length === 0 ? purpose : [
215
+ ...purpose,
216
+ { type: "lineBreak" },
217
+ text("CLI: "),
218
+ ...refs
219
+ ];
220
+ return {
221
+ term: {
222
+ type: "literal",
223
+ value: name
224
+ },
225
+ ...description.length > 0 && { description }
226
+ };
227
+ })
190
228
  };
191
229
  }
192
230
  /**
@@ -318,10 +356,13 @@ function formatDocPage(programName, page, options = {}) {
318
356
  return rendered.trim() !== "";
319
357
  })
320
358
  }));
321
- const environmentSection = environmentPlacement === "section" || environmentPlacement === "both" ? deriveEnvironmentSection({
359
+ const environmentSection = environmentPlacement != null ? deriveEnvironmentSection({
322
360
  ...page,
323
361
  sections: filteredSections
324
- }, { title: typeof options.showEnvironment === "object" ? options.showEnvironment.sectionTitle : void 0 }) : void 0;
362
+ }, {
363
+ onlyUnreferenced: environmentPlacement === "inline",
364
+ title: typeof options.showEnvironment === "object" ? options.showEnvironment.sectionTitle : void 0
365
+ }) : void 0;
325
366
  page = {
326
367
  ...page,
327
368
  sections: environmentSection == null ? filteredSections : [...filteredSections, environmentSection]
package/dist/facade.d.cts CHANGED
@@ -150,7 +150,8 @@ interface RunOptions<THelp, TError> {
150
150
  readonly showChoices?: boolean | ShowChoicesOptions;
151
151
  /**
152
152
  * Displays declared environment bindings in help. `true` selects inline
153
- * annotations; an object can select a section or both. Defaults to `false`.
153
+ * annotations; an object can select a section or both. Names without visible
154
+ * CLI references get a fallback section even in inline mode. Defaults to `false`.
154
155
  * Also applies to full help above errors. @since 1.4.0
155
156
  */
156
157
  readonly showEnvironment?: boolean | ShowEnvironmentOptions;
package/dist/facade.d.ts CHANGED
@@ -150,7 +150,8 @@ interface RunOptions<THelp, TError> {
150
150
  readonly showChoices?: boolean | ShowChoicesOptions;
151
151
  /**
152
152
  * Displays declared environment bindings in help. `true` selects inline
153
- * annotations; an object can select a section or both. Defaults to `false`.
153
+ * annotations; an object can select a section or both. Names without visible
154
+ * CLI references get a fallback section even in inline mode. Defaults to `false`.
154
155
  * Also applies to full help above errors. @since 1.4.0
155
156
  */
156
157
  readonly showEnvironment?: boolean | ShowEnvironmentOptions;
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonemp
3
3
  import { Message, MessageFormatOptions, MessageFormatter, MessageFormatterOptions, MessageTerm, ValueSetOptions, commandLine, createMessageFormatter, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.cjs";
4
4
  import { ErrorLabelTerm, LabelTerm, ProgramNameTerm, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, defaultTerminalTheme } from "./terminal.cjs";
5
5
  import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.cjs";
6
- import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden } from "./doc.cjs";
6
+ import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, EnvironmentBindingDoc, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden } from "./doc.cjs";
7
7
  import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, OriginOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, origin, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.cjs";
8
8
  import { CombineModes, DetailedParseResult, DocState, EffectfulCompletionSession, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseDetailed, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.cjs";
9
9
  import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.cjs";
@@ -13,4 +13,4 @@ import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./c
13
13
  import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.cjs";
14
14
  import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, HelpSectionsOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.cjs";
15
15
  import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.cjs";
16
- export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HelpSectionsOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveEnvironmentSection, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
16
+ export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, EnvironmentBindingDoc, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HelpSectionsOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveEnvironmentSection, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonemp
3
3
  import { Message, MessageFormatOptions, MessageFormatter, MessageFormatterOptions, MessageTerm, ValueSetOptions, commandLine, createMessageFormatter, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.js";
4
4
  import { ErrorLabelTerm, LabelTerm, ProgramNameTerm, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, defaultTerminalTheme } from "./terminal.js";
5
5
  import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
6
- import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden } from "./doc.js";
6
+ import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, EnvironmentBindingDoc, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, deriveEnvironmentSection, formatDocPage, isDocEntryHidden } from "./doc.js";
7
7
  import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DomainOptions, EmailOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LocaleOptions, MacAddressOptions, OriginOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, RegExpOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SocketAddressOptions, SocketAddressValue, StringOptions, TransformMapping, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, biject, checkBooleanOption, checkEnumOption, choice, cidr, color, cron, domain, email, fileSize, firstOf, float, hostname, integer, ip, ipv4, ipv6, isValueParser, json, keyValue, locale, macAddress, origin, port, portRange, regExp, semVer, socketAddress, string, transform, url, uuid } from "./valueparser.js";
8
8
  import { CombineModes, DetailedParseResult, DocState, EffectfulCompletionSession, ExecutionContext, ExecutionPhase, InferMode, InferValue, Mode, ModeIterable, ModeValue, ParseFrame, Parser, ParserContext, ParserResult, Result, Suggestion, createParserContext, getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseDetailed, parseSync, suggest, suggestAsync, suggestSync } from "./internal/parser.js";
9
9
  import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.js";
@@ -13,4 +13,4 @@ import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./c
13
13
  import { AnyDependencySource, CombineMode, CombinedDependencyMode, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, dependency, deriveFrom, deriveFromAsync, deriveFromSync, getDependencySourceInfo, isDependencySource, isDerivedValueParser } from "./internal/dependency.js";
14
14
  import { CommandListMode, CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, HelpSectionsOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
15
15
  import { ArgumentErrorOptions, ArgumentOptions, CommandErrorOptions, CommandOptions, FlagErrorOptions, FlagOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, OptionErrorOptions, OptionOptions, OptionState, PassThroughFormat, PassThroughOptions, argument, command, constant, fail, flag, negatableFlag, option, passThrough } from "./primitives.js";
16
- export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HelpSectionsOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveEnvironmentSection, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
16
+ export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, Color, ColorFormat, ColorOptions, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandListMode, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, CronExpression, CronExpressionForOptions, CronOptions, DeferredMap, DeferredValue, DeferredValueOptions, DeferredValueSource, DependencyMode, DependencySource, DependencySourceInfo, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DetailedParseResult, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EffectfulCompletionSession, EmailOptions, EnvironmentBindingDoc, ErrorLabelTerm, ExecutionContext, ExecutionPhase, ExtractRequiredOptions, FileSizeOptions, FileSizeOptionsBigInt, FileSizeOptionsNumber, FileSizeUnit, FirstOfOptions, FlagErrorOptions, FlagOptions, FloatOptions, FluentParser, GroupOptions, HelpSectionsOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, Json, JsonOptions, KeyValueOptions, LabelTerm, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageFormatter, type MessageFormatterOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NegatableFlagErrorOptions, NegatableFlagNameList, NegatableFlagNames, NegatableFlagOptions, NegatableFlagState, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, OriginOptions, ParseFrame, type ParseOptions, Parser, ParserContext, ParserModifiers, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ProgramNameTerm, RegExpOptions, Result, RunOptions, RunParserError, RunWithOptions, SemVer, SemVerOptionsObject, SemVerOptionsString, SemVerString, SeqOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, ShowEnvironmentOptions, SocketAddressOptions, SocketAddressValue, SourceContext, SourceContextRequest, StringOptions, SubstituteParserValue, Suggestion, SyntaxPunctuationTerm, TerminalColor, TerminalFormatContext, TerminalFormatter, TerminalFragment, TerminalStyle, TerminalTerm, TerminalTheme, TransformMapping, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, argument, bash, biject, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, color, command, commandLine, concat, conditional, constant, createMessageFormatter, createParserContext, cron, deduplicateDocEntries, deduplicateDocFragments, defaultTerminalTheme, deferredValue, dependency, deriveEnvironmentSection, deriveFrom, deriveFromAsync, deriveFromSync, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractLiteralValues, extractOptionNames, fail, fileSize, firstOf, fish, flag, float, fluent, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDependencySourceInfo, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredValue, isDependencySource, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isSuggestionHidden, isUsageHidden, isValueParser, json, keyValue, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, negatableFlag, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, origin, parse, parseAsync, parseDetailed, parseSync, passThrough, port, portRange, pwsh, regExp, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, semVer, seq, socketAddress, string, suggest, suggestAsync, suggestSync, text, transform, tuple, url, uuid, value, valueSet, values, withDefault, zsh };
@@ -859,7 +859,7 @@ async function getDocPageAsyncImpl(parser, args, options) {
859
859
  */
860
860
  function buildDocPage(parser, context, args, matchedCommandArgIndices) {
861
861
  let effectiveArgs = args;
862
- let { brief, description, fragments, footer } = parser.getDocFragments({
862
+ let { brief, description, fragments, footer, environmentBindings } = parser.getDocFragments({
863
863
  kind: "available",
864
864
  state: context.state
865
865
  }, void 0);
@@ -870,7 +870,7 @@ function buildDocPage(parser, context, args, matchedCommandArgIndices) {
870
870
  kind: "available",
871
871
  state: matchedState
872
872
  }, void 0);
873
- ({brief, description, fragments, footer} = matched);
873
+ ({brief, description, fragments, footer, environmentBindings} = matched);
874
874
  effectiveArgs = [cmdName];
875
875
  }
876
876
  const buildingSections = [];
@@ -944,7 +944,12 @@ function buildDocPage(parser, context, args, matchedCommandArgIndices) {
944
944
  usage.splice(1, usage.length - 1, ...normalizedCustomUsageLine);
945
945
  }
946
946
  }
947
+ const visibleBindings = environmentBindings?.filter((binding) => !require_usage.isDocHidden(binding.hidden)).map((binding) => ({
948
+ ...binding,
949
+ ...binding.description != null && { description: require_message.cloneMessage(binding.description) }
950
+ }));
947
951
  return {
952
+ ...visibleBindings != null && visibleBindings.length > 0 && { environmentBindings: visibleBindings },
948
953
  usage: revealMatchedCommandUsage(usage, effectiveArgs, commandArgIndices ?? null),
949
954
  sections,
950
955
  ...brief != null && { brief: require_message.cloneMessage(brief) },
@@ -1,5 +1,5 @@
1
1
  import { hasMeaningfulAnnotations, inheritAnnotations, injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotationWrapper } from "./annotations.js";
2
- import { cloneUsage, normalizeUsage } from "../usage.js";
2
+ import { cloneUsage, isDocHidden, normalizeUsage } from "../usage.js";
3
3
  import { cloneMessage, message } from "../message.js";
4
4
  import { cloneDocEntry, isDocEntryHidden } from "../doc.js";
5
5
  import { dispatchByMode, dispatchParserByMode } from "./mode-dispatch.js";
@@ -859,7 +859,7 @@ async function getDocPageAsyncImpl(parser, args, options) {
859
859
  */
860
860
  function buildDocPage(parser, context, args, matchedCommandArgIndices) {
861
861
  let effectiveArgs = args;
862
- let { brief, description, fragments, footer } = parser.getDocFragments({
862
+ let { brief, description, fragments, footer, environmentBindings } = parser.getDocFragments({
863
863
  kind: "available",
864
864
  state: context.state
865
865
  }, void 0);
@@ -870,7 +870,7 @@ function buildDocPage(parser, context, args, matchedCommandArgIndices) {
870
870
  kind: "available",
871
871
  state: matchedState
872
872
  }, void 0);
873
- ({brief, description, fragments, footer} = matched);
873
+ ({brief, description, fragments, footer, environmentBindings} = matched);
874
874
  effectiveArgs = [cmdName];
875
875
  }
876
876
  const buildingSections = [];
@@ -944,7 +944,12 @@ function buildDocPage(parser, context, args, matchedCommandArgIndices) {
944
944
  usage.splice(1, usage.length - 1, ...normalizedCustomUsageLine);
945
945
  }
946
946
  }
947
+ const visibleBindings = environmentBindings?.filter((binding) => !isDocHidden(binding.hidden)).map((binding) => ({
948
+ ...binding,
949
+ ...binding.description != null && { description: cloneMessage(binding.description) }
950
+ }));
947
951
  return {
952
+ ...visibleBindings != null && visibleBindings.length > 0 && { environmentBindings: visibleBindings },
948
953
  usage: revealMatchedCommandUsage(usage, effectiveArgs, commandArgIndices ?? null),
949
954
  sections,
950
955
  ...brief != null && { brief: cloneMessage(brief) },
@@ -149,7 +149,10 @@ function constant(value) {
149
149
  return [];
150
150
  },
151
151
  getDocFragments(_state, _defaultValue) {
152
- return { fragments: [] };
152
+ return {
153
+ fragments: [],
154
+ sourceOnly: true
155
+ };
153
156
  }
154
157
  };
155
158
  Object.defineProperty(result, "placeholder", {
@@ -209,7 +212,10 @@ function fail() {
209
212
  return [];
210
213
  },
211
214
  getDocFragments(_state, _defaultValue) {
212
- return { fragments: [] };
215
+ return {
216
+ fragments: [],
217
+ sourceOnly: true
218
+ };
213
219
  }
214
220
  });
215
221
  }
@@ -149,7 +149,10 @@ function constant(value) {
149
149
  return [];
150
150
  },
151
151
  getDocFragments(_state, _defaultValue) {
152
- return { fragments: [] };
152
+ return {
153
+ fragments: [],
154
+ sourceOnly: true
155
+ };
153
156
  }
154
157
  };
155
158
  Object.defineProperty(result, "placeholder", {
@@ -209,7 +212,10 @@ function fail() {
209
212
  return [];
210
213
  },
211
214
  getDocFragments(_state, _defaultValue) {
212
- return { fragments: [] };
215
+ return {
216
+ fragments: [],
217
+ sourceOnly: true
218
+ };
213
219
  }
214
220
  });
215
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.4.0-dev.2631",
3
+ "version": "1.4.0-dev.2634",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",
@@ -237,7 +237,7 @@
237
237
  },
238
238
  "sideEffects": false,
239
239
  "devDependencies": {
240
- "@optique/env": "1.4.0-dev.2631+0f2bd6a0",
240
+ "@optique/env": "1.4.0-dev.2634+1d7c26e6",
241
241
  "@types/node": "^24.0.0",
242
242
  "fast-check": "^4.7.0",
243
243
  "tsdown": "^0.13.0",
@@ -248,7 +248,7 @@ Common mistakes checklist
248
248
  - Use structured `message` values for errors and descriptions.
249
249
  - Register contexts for `bindEnv()`, `bindConfig()`, `bindDerivedDefault()`,
250
250
  and `bindKeyring()` in the runner's `contexts` option.
251
- - Show `bindEnv()` names in help with `showEnvironment: true`.
251
+ - Enable `showEnvironment` for env-only help; set `documentation.description`.
252
252
  - Do not flatten a multi-level dependency graph into duplicated one-level
253
253
  factories. Wrap each derived value that becomes a later source with
254
254
  `dependency()` and derive the next parser from it.