@optique/core 1.0.0-dev.1452 → 1.0.0-dev.1461

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.
package/dist/doc.cjs CHANGED
@@ -2,6 +2,20 @@ const require_message = require('./message.cjs');
2
2
  const require_usage = require('./usage.cjs');
3
3
 
4
4
  //#region src/doc.ts
5
+ /**
6
+ * Returns whether a doc entry's term is hidden from documentation.
7
+ * Only term types with a `hidden` field (argument, option, command,
8
+ * passthrough) are checked; other types always return `false`.
9
+ *
10
+ * @param entry The doc entry to check.
11
+ * @returns `true` if the entry should be hidden from documentation.
12
+ * @since 1.0.0
13
+ */
14
+ function isDocEntryHidden(entry) {
15
+ const term = entry.term;
16
+ if (term.type === "argument" || term.type === "option" || term.type === "command" || term.type === "passthrough") return require_usage.isDocHidden(term.hidden);
17
+ return false;
18
+ }
5
19
  function getDocEntryKey(entry) {
6
20
  const term = entry.term;
7
21
  switch (term.type) {
@@ -13,21 +27,25 @@ function getDocEntryKey(entry) {
13
27
  }
14
28
  /**
15
29
  * Removes duplicate {@link DocEntry} values that share the same surface
16
- * syntax (same term type and identifying names). When duplicates exist,
17
- * the first occurrence is kept and later ones are discarded.
30
+ * syntax (same term type and identifying names). Doc-hidden entries are
31
+ * filtered out first so they cannot influence the ordering of visible
32
+ * entries. Among the remaining visible entries, the first occurrence is
33
+ * kept and later duplicates are discarded.
18
34
  *
19
35
  * Positional argument entries are never deduplicated because they are
20
36
  * distinguished by position, not by metavar, and {@link DocEntry} does
21
37
  * not carry position information.
22
38
  *
23
39
  * @param entries The entries to deduplicate.
24
- * @returns A new array with duplicates removed, preserving insertion order.
40
+ * @returns A new array with hidden entries removed and duplicates
41
+ * collapsed, preserving insertion order of visible entries.
25
42
  * @since 1.0.0
26
43
  */
27
44
  function deduplicateDocEntries(entries) {
28
45
  const seen = /* @__PURE__ */ new Set();
29
46
  const result = [];
30
47
  for (const entry of entries) {
48
+ if (isDocEntryHidden(entry)) continue;
31
49
  if (entry.term.type === "argument") {
32
50
  result.push(entry);
33
51
  continue;
@@ -52,18 +70,22 @@ function deduplicateDocEntries(entries) {
52
70
  function deduplicateDocFragments(fragments) {
53
71
  const untitledSeen = /* @__PURE__ */ new Set();
54
72
  const titledSectionMap = /* @__PURE__ */ new Map();
73
+ const titledSectionPositioned = /* @__PURE__ */ new Set();
55
74
  const slots = [];
56
- for (const fragment of fragments) if (fragment.type === "entry") if (fragment.term.type === "argument") slots.push(fragment);
57
- else {
58
- const key = getDocEntryKey(fragment);
59
- if (!untitledSeen.has(key)) {
60
- untitledSeen.add(key);
61
- slots.push(fragment);
75
+ for (const fragment of fragments) if (fragment.type === "entry") {
76
+ if (isDocEntryHidden(fragment)) continue;
77
+ if (fragment.term.type === "argument") slots.push(fragment);
78
+ else {
79
+ const key = getDocEntryKey(fragment);
80
+ if (!untitledSeen.has(key)) {
81
+ untitledSeen.add(key);
82
+ slots.push(fragment);
83
+ }
62
84
  }
63
- }
64
- else if (fragment.title == null) {
85
+ } else if (fragment.title == null) {
65
86
  const dedupedEntries = [];
66
87
  for (const entry of fragment.entries) {
88
+ if (isDocEntryHidden(entry)) continue;
67
89
  if (entry.term.type === "argument") {
68
90
  dedupedEntries.push(entry);
69
91
  continue;
@@ -80,8 +102,9 @@ function deduplicateDocFragments(fragments) {
80
102
  entries: dedupedEntries
81
103
  });
82
104
  } else {
83
- if (!titledSectionMap.has(fragment.title)) {
84
- titledSectionMap.set(fragment.title, []);
105
+ if (!titledSectionMap.has(fragment.title)) titledSectionMap.set(fragment.title, []);
106
+ if (!titledSectionPositioned.has(fragment.title) && fragment.entries.some((e) => !isDocEntryHidden(e))) {
107
+ titledSectionPositioned.add(fragment.title);
85
108
  slots.push(fragment.title);
86
109
  }
87
110
  titledSectionMap.get(fragment.title).push(...fragment.entries);
@@ -442,4 +465,5 @@ function lastLineVisibleLength(text$1) {
442
465
  exports.cloneDocEntry = cloneDocEntry;
443
466
  exports.deduplicateDocEntries = deduplicateDocEntries;
444
467
  exports.deduplicateDocFragments = deduplicateDocFragments;
445
- exports.formatDocPage = formatDocPage;
468
+ exports.formatDocPage = formatDocPage;
469
+ exports.isDocEntryHidden = isDocEntryHidden;
package/dist/doc.d.cts CHANGED
@@ -103,17 +103,30 @@ interface DocFragments {
103
103
  */
104
104
  readonly footer?: Message;
105
105
  }
106
+ /**
107
+ * Returns whether a doc entry's term is hidden from documentation.
108
+ * Only term types with a `hidden` field (argument, option, command,
109
+ * passthrough) are checked; other types always return `false`.
110
+ *
111
+ * @param entry The doc entry to check.
112
+ * @returns `true` if the entry should be hidden from documentation.
113
+ * @since 1.0.0
114
+ */
115
+ declare function isDocEntryHidden(entry: DocEntry): boolean;
106
116
  /**
107
117
  * Removes duplicate {@link DocEntry} values that share the same surface
108
- * syntax (same term type and identifying names). When duplicates exist,
109
- * the first occurrence is kept and later ones are discarded.
118
+ * syntax (same term type and identifying names). Doc-hidden entries are
119
+ * filtered out first so they cannot influence the ordering of visible
120
+ * entries. Among the remaining visible entries, the first occurrence is
121
+ * kept and later duplicates are discarded.
110
122
  *
111
123
  * Positional argument entries are never deduplicated because they are
112
124
  * distinguished by position, not by metavar, and {@link DocEntry} does
113
125
  * not carry position information.
114
126
  *
115
127
  * @param entries The entries to deduplicate.
116
- * @returns A new array with duplicates removed, preserving insertion order.
128
+ * @returns A new array with hidden entries removed and duplicates
129
+ * collapsed, preserving insertion order of visible entries.
117
130
  * @since 1.0.0
118
131
  */
119
132
  declare function deduplicateDocEntries(entries: readonly DocEntry[]): DocEntry[];
@@ -325,4 +338,4 @@ interface DocPageFormatOptions {
325
338
  */
326
339
  declare function formatDocPage(programName: string, page: DocPage, options?: DocPageFormatOptions): string;
327
340
  //#endregion
328
- export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage };
341
+ export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden };
package/dist/doc.d.ts CHANGED
@@ -103,17 +103,30 @@ interface DocFragments {
103
103
  */
104
104
  readonly footer?: Message;
105
105
  }
106
+ /**
107
+ * Returns whether a doc entry's term is hidden from documentation.
108
+ * Only term types with a `hidden` field (argument, option, command,
109
+ * passthrough) are checked; other types always return `false`.
110
+ *
111
+ * @param entry The doc entry to check.
112
+ * @returns `true` if the entry should be hidden from documentation.
113
+ * @since 1.0.0
114
+ */
115
+ declare function isDocEntryHidden(entry: DocEntry): boolean;
106
116
  /**
107
117
  * Removes duplicate {@link DocEntry} values that share the same surface
108
- * syntax (same term type and identifying names). When duplicates exist,
109
- * the first occurrence is kept and later ones are discarded.
118
+ * syntax (same term type and identifying names). Doc-hidden entries are
119
+ * filtered out first so they cannot influence the ordering of visible
120
+ * entries. Among the remaining visible entries, the first occurrence is
121
+ * kept and later duplicates are discarded.
110
122
  *
111
123
  * Positional argument entries are never deduplicated because they are
112
124
  * distinguished by position, not by metavar, and {@link DocEntry} does
113
125
  * not carry position information.
114
126
  *
115
127
  * @param entries The entries to deduplicate.
116
- * @returns A new array with duplicates removed, preserving insertion order.
128
+ * @returns A new array with hidden entries removed and duplicates
129
+ * collapsed, preserving insertion order of visible entries.
117
130
  * @since 1.0.0
118
131
  */
119
132
  declare function deduplicateDocEntries(entries: readonly DocEntry[]): DocEntry[];
@@ -325,4 +338,4 @@ interface DocPageFormatOptions {
325
338
  */
326
339
  declare function formatDocPage(programName: string, page: DocPage, options?: DocPageFormatOptions): string;
327
340
  //#endregion
328
- export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage };
341
+ export { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden };
package/dist/doc.js CHANGED
@@ -1,7 +1,21 @@
1
1
  import { cloneMessage, formatMessage, text } from "./message.js";
2
- import { cloneUsageTerm, formatUsage, formatUsageTerm } from "./usage.js";
2
+ import { cloneUsageTerm, formatUsage, formatUsageTerm, isDocHidden } from "./usage.js";
3
3
 
4
4
  //#region src/doc.ts
5
+ /**
6
+ * Returns whether a doc entry's term is hidden from documentation.
7
+ * Only term types with a `hidden` field (argument, option, command,
8
+ * passthrough) are checked; other types always return `false`.
9
+ *
10
+ * @param entry The doc entry to check.
11
+ * @returns `true` if the entry should be hidden from documentation.
12
+ * @since 1.0.0
13
+ */
14
+ function isDocEntryHidden(entry) {
15
+ const term = entry.term;
16
+ if (term.type === "argument" || term.type === "option" || term.type === "command" || term.type === "passthrough") return isDocHidden(term.hidden);
17
+ return false;
18
+ }
5
19
  function getDocEntryKey(entry) {
6
20
  const term = entry.term;
7
21
  switch (term.type) {
@@ -13,21 +27,25 @@ function getDocEntryKey(entry) {
13
27
  }
14
28
  /**
15
29
  * Removes duplicate {@link DocEntry} values that share the same surface
16
- * syntax (same term type and identifying names). When duplicates exist,
17
- * the first occurrence is kept and later ones are discarded.
30
+ * syntax (same term type and identifying names). Doc-hidden entries are
31
+ * filtered out first so they cannot influence the ordering of visible
32
+ * entries. Among the remaining visible entries, the first occurrence is
33
+ * kept and later duplicates are discarded.
18
34
  *
19
35
  * Positional argument entries are never deduplicated because they are
20
36
  * distinguished by position, not by metavar, and {@link DocEntry} does
21
37
  * not carry position information.
22
38
  *
23
39
  * @param entries The entries to deduplicate.
24
- * @returns A new array with duplicates removed, preserving insertion order.
40
+ * @returns A new array with hidden entries removed and duplicates
41
+ * collapsed, preserving insertion order of visible entries.
25
42
  * @since 1.0.0
26
43
  */
27
44
  function deduplicateDocEntries(entries) {
28
45
  const seen = /* @__PURE__ */ new Set();
29
46
  const result = [];
30
47
  for (const entry of entries) {
48
+ if (isDocEntryHidden(entry)) continue;
31
49
  if (entry.term.type === "argument") {
32
50
  result.push(entry);
33
51
  continue;
@@ -52,18 +70,22 @@ function deduplicateDocEntries(entries) {
52
70
  function deduplicateDocFragments(fragments) {
53
71
  const untitledSeen = /* @__PURE__ */ new Set();
54
72
  const titledSectionMap = /* @__PURE__ */ new Map();
73
+ const titledSectionPositioned = /* @__PURE__ */ new Set();
55
74
  const slots = [];
56
- for (const fragment of fragments) if (fragment.type === "entry") if (fragment.term.type === "argument") slots.push(fragment);
57
- else {
58
- const key = getDocEntryKey(fragment);
59
- if (!untitledSeen.has(key)) {
60
- untitledSeen.add(key);
61
- slots.push(fragment);
75
+ for (const fragment of fragments) if (fragment.type === "entry") {
76
+ if (isDocEntryHidden(fragment)) continue;
77
+ if (fragment.term.type === "argument") slots.push(fragment);
78
+ else {
79
+ const key = getDocEntryKey(fragment);
80
+ if (!untitledSeen.has(key)) {
81
+ untitledSeen.add(key);
82
+ slots.push(fragment);
83
+ }
62
84
  }
63
- }
64
- else if (fragment.title == null) {
85
+ } else if (fragment.title == null) {
65
86
  const dedupedEntries = [];
66
87
  for (const entry of fragment.entries) {
88
+ if (isDocEntryHidden(entry)) continue;
67
89
  if (entry.term.type === "argument") {
68
90
  dedupedEntries.push(entry);
69
91
  continue;
@@ -80,8 +102,9 @@ function deduplicateDocFragments(fragments) {
80
102
  entries: dedupedEntries
81
103
  });
82
104
  } else {
83
- if (!titledSectionMap.has(fragment.title)) {
84
- titledSectionMap.set(fragment.title, []);
105
+ if (!titledSectionMap.has(fragment.title)) titledSectionMap.set(fragment.title, []);
106
+ if (!titledSectionPositioned.has(fragment.title) && fragment.entries.some((e) => !isDocEntryHidden(e))) {
107
+ titledSectionPositioned.add(fragment.title);
85
108
  slots.push(fragment.title);
86
109
  }
87
110
  titledSectionMap.get(fragment.title).push(...fragment.entries);
@@ -439,4 +462,4 @@ function lastLineVisibleLength(text$1) {
439
462
  }
440
463
 
441
464
  //#endregion
442
- export { cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage };
465
+ export { cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden };
package/dist/index.cjs CHANGED
@@ -79,6 +79,7 @@ exports.isDeferredParseState = require_dependency.isDeferredParseState;
79
79
  exports.isDependencySource = require_dependency.isDependencySource;
80
80
  exports.isDependencySourceState = require_dependency.isDependencySourceState;
81
81
  exports.isDerivedValueParser = require_dependency.isDerivedValueParser;
82
+ exports.isDocEntryHidden = require_doc.isDocEntryHidden;
82
83
  exports.isDocHidden = require_usage.isDocHidden;
83
84
  exports.isNonEmptyString = require_nonempty.isNonEmptyString;
84
85
  exports.isPendingDependencySourceState = require_dependency.isPendingDependencySourceState;
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@ import { Annotations, ParseOptions, annotationKey, getAnnotations } from "./anno
2
2
  import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonempty.cjs";
3
3
  import { Message, MessageFormatOptions, MessageTerm, ValueSetOptions, commandLine, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.cjs";
4
4
  import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.cjs";
5
- import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage } from "./doc.cjs";
5
+ import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.cjs";
6
6
  import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, DomainOptions, EmailOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, checkBooleanOption, checkEnumOption, choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.cjs";
7
7
  import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.cjs";
8
8
  import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.cjs";
@@ -12,4 +12,4 @@ import { CombineModes, DocState, InferMode, InferValue, Mode, ModeIterable, Mode
12
12
  import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.cjs";
13
13
  import { ParserValuePlaceholder, SourceContext } from "./context.cjs";
14
14
  import { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.cjs";
15
- export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
15
+ export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Annotations, ParseOptions, annotationKey, getAnnotations } from "./anno
2
2
  import { NonEmptyString, ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
3
3
  import { Message, MessageFormatOptions, MessageTerm, ValueSetOptions, commandLine, envVar, formatMessage, lineBreak, link, message, metavar, optionName, optionNames, text, value, valueSet, values } from "./message.js";
4
4
  import { HiddenVisibility, OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
5
- import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage } from "./doc.js";
5
+ import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowChoicesOptions, ShowDefaultOptions, cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.js";
6
6
  import { ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, DomainOptions, EmailOptions, FloatOptions, HostnameOptions, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, MacAddressOptions, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, SocketAddressOptions, SocketAddressValue, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, checkBooleanOption, checkEnumOption, choice, cidr, domain, email, float, hostname, integer, ip, ipv4, ipv6, isValueParser, locale, macAddress, port, portRange, socketAddress, string, url, uuid } from "./valueparser.js";
7
7
  import { ConditionalErrorOptions, ConditionalOptions, DuplicateOptionError, GroupOptions, LongestMatchErrorOptions, LongestMatchOptions, MergeOptions, NoMatchContext, ObjectErrorOptions, ObjectOptions, OrErrorOptions, OrOptions, TupleOptions, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.js";
8
8
  import { MultipleErrorOptions, MultipleOptions, WithDefaultError, WithDefaultOptions, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
@@ -12,4 +12,4 @@ import { CombineModes, DocState, InferMode, InferValue, Mode, ModeIterable, Mode
12
12
  import { ShellCompletion, bash, fish, nu, pwsh, zsh } from "./completion.js";
13
13
  import { ParserValuePlaceholder, SourceContext } from "./context.js";
14
14
  import { CommandSubConfig, ContextOptionsParam, ExtractRequiredOptions, OptionSubConfig, RunOptions, RunParserError, RunWithOptions, SubstituteParserValue, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
15
- export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
15
+ export { type Annotations, AnyDependencySource, ArgumentErrorOptions, ArgumentOptions, ChoiceOptions, ChoiceOptionsBase, ChoiceOptionsNumber, ChoiceOptionsString, CidrOptions, CidrValue, CombineMode, CombineModes, CombinedDependencyMode, CommandErrorOptions, CommandOptions, CommandSubConfig, ConditionalErrorOptions, ConditionalOptions, ContextOptionsParam, DeferredParseState, DependencyError, DependencyMode, DependencyRegistry, DependencySource, DependencySourceState, DependencyValue, DependencyValues, DeriveAsyncOptions, DeriveFromAsyncOptions, DeriveFromOptions, DeriveFromSyncOptions, DeriveOptions, DeriveSyncOptions, DerivedValueParser, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, DomainOptions, DuplicateOptionError, EmailOptions, ExtractRequiredOptions, FlagErrorOptions, FlagOptions, FloatOptions, GroupOptions, HiddenVisibility, HostnameOptions, InferMode, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, IpOptions, Ipv4Options, Ipv6Options, LocaleOptions, LongestMatchErrorOptions, LongestMatchOptions, MacAddressOptions, MergeOptions, type Message, type MessageFormatOptions, type MessageTerm, Mode, ModeIterable, ModeValue, MultipleErrorOptions, MultipleOptions, NoMatchContext, NonEmptyString, ObjectErrorOptions, ObjectOptions, OptionErrorOptions, OptionName, OptionOptions, OptionState, OptionSubConfig, OrErrorOptions, OrOptions, type ParseOptions, Parser, ParserContext, ParserResult, ParserValuePlaceholder, PassThroughFormat, PassThroughOptions, PendingDependencySourceState, PortOptionsBigInt, PortOptionsNumber, PortRangeOptionsBigInt, PortRangeOptionsNumber, PortRangeValueBigInt, PortRangeValueNumber, ResolvedDependency, Result, RunOptions, RunParserError, RunWithOptions, ShellCompletion, ShowChoicesOptions, ShowDefaultOptions, SocketAddressOptions, SocketAddressValue, SourceContext, StringOptions, SubstituteParserValue, Suggestion, TupleOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, type ValueSetOptions, WithDefaultError, WithDefaultOptions, annotationKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { commandLine, envVar, formatMessage, lineBreak, link, message, metavar,
3
3
  import { bash, fish, nu, pwsh, zsh } from "./completion.js";
4
4
  import { DependencyRegistry, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, formatDependencyError, getDefaultValuesFunction, getDependencyIds, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, isWrappedDependencySource, parseWithDependency, pendingDependencySourceStateMarker, suggestWithDependency, transformsDependencyValue, transformsDependencyValueMarker, wrappedDependencySourceMarker } from "./dependency.js";
5
5
  import { cloneUsage, cloneUsageTerm, extractArgumentMetavars, extractCommandNames, extractOptionNames, formatUsage, formatUsageTerm, isDocHidden, isSuggestionHidden, isUsageHidden, mergeHidden, normalizeUsage } from "./usage.js";
6
- import { cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage } from "./doc.js";
6
+ import { cloneDocEntry, deduplicateDocEntries, deduplicateDocFragments, formatDocPage, isDocEntryHidden } from "./doc.js";
7
7
  import { DuplicateOptionError, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.js";
8
8
  import { WithDefaultError, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
9
9
  import { ensureNonEmptyString, isNonEmptyString } from "./nonempty.js";
@@ -12,4 +12,4 @@ import { argument, command, constant, fail, flag, option, passThrough } from "./
12
12
  import { getDocPage, getDocPageAsync, getDocPageSync, parse, parseAsync, parseSync, suggest, suggestAsync, suggestSync } from "./parser.js";
13
13
  import { RunParserError, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync } from "./facade.js";
14
14
 
15
- export { DependencyRegistry, DuplicateOptionError, RunParserError, WithDefaultError, annotationKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
15
+ export { DependencyRegistry, DuplicateOptionError, RunParserError, WithDefaultError, annotationKey, argument, bash, checkBooleanOption, checkEnumOption, choice, cidr, cloneDocEntry, cloneUsage, cloneUsageTerm, command, commandLine, concat, conditional, constant, createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, deduplicateDocEntries, deduplicateDocFragments, defaultValues, deferredParseMarker, dependency, dependencyId, dependencyIds, dependencySourceMarker, dependencySourceStateMarker, deriveFrom, deriveFromAsync, deriveFromSync, derivedValueParserMarker, domain, email, ensureNonEmptyString, envVar, extractArgumentMetavars, extractCommandNames, extractOptionNames, fail, fish, flag, float, formatDependencyError, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getAnnotations, getDefaultValuesFunction, getDependencyIds, getDocPage, getDocPageAsync, getDocPageSync, group, hostname, integer, ip, ipv4, ipv6, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isDocEntryHidden, isDocHidden, isNonEmptyString, isPendingDependencySourceState, isSuggestionHidden, isUsageHidden, isValueParser, isWrappedDependencySource, lineBreak, link, locale, longestMatch, macAddress, map, merge, mergeHidden, message, metavar, multiple, nonEmpty, normalizeUsage, nu, object, option, optionName, optionNames, optional, or, parse, parseAsync, parseSync, parseWithDependency, passThrough, pendingDependencySourceStateMarker, port, portRange, pwsh, runParser, runParserAsync, runParserSync, runWith, runWithAsync, runWithSync, socketAddress, string, suggest, suggestAsync, suggestSync, suggestWithDependency, text, transformsDependencyValue, transformsDependencyValueMarker, tuple, url, uuid, value, valueSet, values, withDefault, wrappedDependencySourceMarker, zsh };
package/dist/parser.cjs CHANGED
@@ -385,28 +385,33 @@ function buildDocPage(parser, context, args) {
385
385
  let untitledSection = null;
386
386
  const titledSectionMap = /* @__PURE__ */ new Map();
387
387
  for (const fragment of fragments) if (fragment.type === "entry") {
388
+ if (require_doc.isDocEntryHidden(fragment)) continue;
388
389
  if (untitledSection == null) {
389
390
  untitledSection = { entries: [] };
390
391
  buildingSections.push(untitledSection);
391
392
  }
392
393
  untitledSection.entries.push(require_doc.cloneDocEntry(fragment));
393
- } else if (fragment.type === "section") if (fragment.title == null) {
394
- if (untitledSection == null) {
395
- untitledSection = { entries: [] };
396
- buildingSections.push(untitledSection);
397
- }
398
- untitledSection.entries.push(...fragment.entries.map(require_doc.cloneDocEntry));
399
- } else {
400
- let section = titledSectionMap.get(fragment.title);
401
- if (section == null) {
402
- section = {
403
- title: fragment.title,
404
- entries: []
405
- };
406
- titledSectionMap.set(fragment.title, section);
407
- buildingSections.push(section);
394
+ } else if (fragment.type === "section") {
395
+ const visible = fragment.entries.filter((e) => !require_doc.isDocEntryHidden(e));
396
+ if (visible.length === 0) continue;
397
+ if (fragment.title == null) {
398
+ if (untitledSection == null) {
399
+ untitledSection = { entries: [] };
400
+ buildingSections.push(untitledSection);
401
+ }
402
+ untitledSection.entries.push(...visible.map(require_doc.cloneDocEntry));
403
+ } else {
404
+ let section = titledSectionMap.get(fragment.title);
405
+ if (section == null) {
406
+ section = {
407
+ title: fragment.title,
408
+ entries: []
409
+ };
410
+ titledSectionMap.set(fragment.title, section);
411
+ buildingSections.push(section);
412
+ }
413
+ section.entries.push(...visible.map(require_doc.cloneDocEntry));
408
414
  }
409
- section.entries.push(...fragment.entries.map(require_doc.cloneDocEntry));
410
415
  }
411
416
  const sections = buildingSections;
412
417
  const usage = require_usage.cloneUsage(require_usage.normalizeUsage(parser.usage));
package/dist/parser.js CHANGED
@@ -2,7 +2,7 @@ import { injectAnnotations, isInjectedAnnotationWrapper, unwrapInjectedAnnotatio
2
2
  import { cloneMessage, message } from "./message.js";
3
3
  import { dispatchByMode } from "./mode-dispatch.js";
4
4
  import { cloneUsage, normalizeUsage } from "./usage.js";
5
- import { cloneDocEntry } from "./doc.js";
5
+ import { cloneDocEntry, isDocEntryHidden } from "./doc.js";
6
6
  import { DuplicateOptionError, concat, conditional, group, longestMatch, merge, object, or, tuple } from "./constructs.js";
7
7
  import { WithDefaultError, map, multiple, nonEmpty, optional, withDefault } from "./modifiers.js";
8
8
  import { argument, command, constant, fail, flag, option, passThrough } from "./primitives.js";
@@ -385,28 +385,33 @@ function buildDocPage(parser, context, args) {
385
385
  let untitledSection = null;
386
386
  const titledSectionMap = /* @__PURE__ */ new Map();
387
387
  for (const fragment of fragments) if (fragment.type === "entry") {
388
+ if (isDocEntryHidden(fragment)) continue;
388
389
  if (untitledSection == null) {
389
390
  untitledSection = { entries: [] };
390
391
  buildingSections.push(untitledSection);
391
392
  }
392
393
  untitledSection.entries.push(cloneDocEntry(fragment));
393
- } else if (fragment.type === "section") if (fragment.title == null) {
394
- if (untitledSection == null) {
395
- untitledSection = { entries: [] };
396
- buildingSections.push(untitledSection);
397
- }
398
- untitledSection.entries.push(...fragment.entries.map(cloneDocEntry));
399
- } else {
400
- let section = titledSectionMap.get(fragment.title);
401
- if (section == null) {
402
- section = {
403
- title: fragment.title,
404
- entries: []
405
- };
406
- titledSectionMap.set(fragment.title, section);
407
- buildingSections.push(section);
394
+ } else if (fragment.type === "section") {
395
+ const visible = fragment.entries.filter((e) => !isDocEntryHidden(e));
396
+ if (visible.length === 0) continue;
397
+ if (fragment.title == null) {
398
+ if (untitledSection == null) {
399
+ untitledSection = { entries: [] };
400
+ buildingSections.push(untitledSection);
401
+ }
402
+ untitledSection.entries.push(...visible.map(cloneDocEntry));
403
+ } else {
404
+ let section = titledSectionMap.get(fragment.title);
405
+ if (section == null) {
406
+ section = {
407
+ title: fragment.title,
408
+ entries: []
409
+ };
410
+ titledSectionMap.set(fragment.title, section);
411
+ buildingSections.push(section);
412
+ }
413
+ section.entries.push(...visible.map(cloneDocEntry));
408
414
  }
409
- section.entries.push(...fragment.entries.map(cloneDocEntry));
410
415
  }
411
416
  const sections = buildingSections;
412
417
  const usage = cloneUsage(normalizeUsage(parser.usage));
@@ -2636,6 +2636,90 @@ function compressIpv6(groups) {
2636
2636
  else return before.join(":") + "::" + after.join(":");
2637
2637
  }
2638
2638
  /**
2639
+ * Extracts IPv4 octets from an IPv4-mapped IPv6 address.
2640
+ * Returns null if the address is not an IPv4-mapped address
2641
+ * (i.e., not in the `::ffff:x.x.x.x` range).
2642
+ */
2643
+ function extractIpv4FromMapped(normalizedIpv6) {
2644
+ const groups = expandIpv6(normalizedIpv6);
2645
+ if (groups === null) return null;
2646
+ for (let i = 0; i < 5; i++) if (parseInt(groups[i], 16) !== 0) return null;
2647
+ if (parseInt(groups[5], 16) !== 65535) return null;
2648
+ const high = parseInt(groups[6], 16);
2649
+ const low = parseInt(groups[7], 16);
2650
+ return [
2651
+ high >> 8 & 255,
2652
+ high & 255,
2653
+ low >> 8 & 255,
2654
+ low & 255
2655
+ ];
2656
+ }
2657
+ /**
2658
+ * Checks IPv4 restrictions against octets extracted from an IPv4-mapped
2659
+ * IPv6 address. The check uses the base address, consistent with how
2660
+ * the `ipv4()` parser validates the address part of a regular IPv4 CIDR.
2661
+ *
2662
+ * Returns an error result if a restriction is violated, or null if all
2663
+ * checks pass.
2664
+ */
2665
+ function checkIpv4MappedRestrictions(octets, normalizedIpv6, ipv4Opts, errors) {
2666
+ const allowPrivate = ipv4Opts?.allowPrivate ?? true;
2667
+ const allowLoopback = ipv4Opts?.allowLoopback ?? true;
2668
+ const allowLinkLocal = ipv4Opts?.allowLinkLocal ?? true;
2669
+ const allowMulticast = ipv4Opts?.allowMulticast ?? true;
2670
+ const allowBroadcast = ipv4Opts?.allowBroadcast ?? true;
2671
+ const allowZero = ipv4Opts?.allowZero ?? true;
2672
+ if (!allowPrivate && isPrivateIp(octets)) {
2673
+ const errorMsg = errors?.privateNotAllowed;
2674
+ const msg = typeof errorMsg === "function" ? errorMsg(normalizedIpv6) : errorMsg ?? require_message.message`${normalizedIpv6} is a private IP address.`;
2675
+ return {
2676
+ success: false,
2677
+ error: msg
2678
+ };
2679
+ }
2680
+ if (!allowLoopback && isLoopbackIp(octets)) {
2681
+ const errorMsg = errors?.loopbackNotAllowed;
2682
+ const msg = typeof errorMsg === "function" ? errorMsg(normalizedIpv6) : errorMsg ?? require_message.message`${normalizedIpv6} is a loopback address.`;
2683
+ return {
2684
+ success: false,
2685
+ error: msg
2686
+ };
2687
+ }
2688
+ if (!allowLinkLocal && isLinkLocalIp(octets)) {
2689
+ const errorMsg = errors?.linkLocalNotAllowed;
2690
+ const msg = typeof errorMsg === "function" ? errorMsg(normalizedIpv6) : errorMsg ?? require_message.message`${normalizedIpv6} is a link-local address.`;
2691
+ return {
2692
+ success: false,
2693
+ error: msg
2694
+ };
2695
+ }
2696
+ if (!allowMulticast && isMulticastIp(octets)) {
2697
+ const errorMsg = errors?.multicastNotAllowed;
2698
+ const msg = typeof errorMsg === "function" ? errorMsg(normalizedIpv6) : errorMsg ?? require_message.message`${normalizedIpv6} is a multicast address.`;
2699
+ return {
2700
+ success: false,
2701
+ error: msg
2702
+ };
2703
+ }
2704
+ if (!allowBroadcast && isBroadcastIp(octets)) {
2705
+ const errorMsg = errors?.broadcastNotAllowed;
2706
+ const msg = typeof errorMsg === "function" ? errorMsg(normalizedIpv6) : errorMsg ?? require_message.message`${normalizedIpv6} is the broadcast address.`;
2707
+ return {
2708
+ success: false,
2709
+ error: msg
2710
+ };
2711
+ }
2712
+ if (!allowZero && isZeroIp(octets)) {
2713
+ const errorMsg = errors?.zeroNotAllowed;
2714
+ const msg = typeof errorMsg === "function" ? errorMsg(normalizedIpv6) : errorMsg ?? require_message.message`${normalizedIpv6} is the zero address.`;
2715
+ return {
2716
+ success: false,
2717
+ error: msg
2718
+ };
2719
+ }
2720
+ return null;
2721
+ }
2722
+ /**
2639
2723
  * Creates a value parser that accepts both IPv4 and IPv6 addresses.
2640
2724
  *
2641
2725
  * By default, accepts both IPv4 and IPv6 addresses. Use the `version` option
@@ -2688,6 +2772,22 @@ function ip(options) {
2688
2772
  zeroNotAllowed: errors?.zeroNotAllowed
2689
2773
  }
2690
2774
  }) : null;
2775
+ const mappedIpv4Opts = version === "both" ? {
2776
+ allowPrivate: options?.ipv4?.allowPrivate,
2777
+ allowLoopback: options?.ipv4?.allowLoopback,
2778
+ allowLinkLocal: options?.ipv4?.allowLinkLocal,
2779
+ allowMulticast: options?.ipv4?.allowMulticast,
2780
+ allowBroadcast: options?.ipv4?.allowBroadcast,
2781
+ allowZero: options?.ipv4?.allowZero
2782
+ } : void 0;
2783
+ const mappedIpv4Errors = version === "both" ? {
2784
+ privateNotAllowed: errors?.privateNotAllowed,
2785
+ loopbackNotAllowed: errors?.loopbackNotAllowed,
2786
+ linkLocalNotAllowed: errors?.linkLocalNotAllowed,
2787
+ multicastNotAllowed: errors?.multicastNotAllowed,
2788
+ broadcastNotAllowed: errors?.broadcastNotAllowed,
2789
+ zeroNotAllowed: errors?.zeroNotAllowed
2790
+ } : void 0;
2691
2791
  return {
2692
2792
  $mode: "sync",
2693
2793
  metavar,
@@ -2702,7 +2802,16 @@ function ip(options) {
2702
2802
  }
2703
2803
  if (ipv6Parser !== null) {
2704
2804
  const result = ipv6Parser.parse(input);
2705
- if (result.success) return result;
2805
+ if (result.success) {
2806
+ if (version === "both") {
2807
+ const mappedOctets = extractIpv4FromMapped(result.value);
2808
+ if (mappedOctets !== null) {
2809
+ const restrictionError = checkIpv4MappedRestrictions(mappedOctets, result.value, mappedIpv4Opts, mappedIpv4Errors);
2810
+ if (restrictionError !== null) return restrictionError;
2811
+ }
2812
+ }
2813
+ return result;
2814
+ }
2706
2815
  ipv6Error = result;
2707
2816
  if (version === 6) return result;
2708
2817
  }
@@ -2804,6 +2913,22 @@ function cidr(options) {
2804
2913
  uniqueLocalNotAllowed: errors?.uniqueLocalNotAllowed
2805
2914
  }
2806
2915
  }) : null;
2916
+ const mappedIpv4Opts = version === "both" ? {
2917
+ allowPrivate: options?.ipv4?.allowPrivate,
2918
+ allowLoopback: options?.ipv4?.allowLoopback,
2919
+ allowLinkLocal: options?.ipv4?.allowLinkLocal,
2920
+ allowMulticast: options?.ipv4?.allowMulticast,
2921
+ allowBroadcast: options?.ipv4?.allowBroadcast,
2922
+ allowZero: options?.ipv4?.allowZero
2923
+ } : void 0;
2924
+ const mappedIpv4Errors = version === "both" ? {
2925
+ privateNotAllowed: errors?.privateNotAllowed,
2926
+ loopbackNotAllowed: errors?.loopbackNotAllowed,
2927
+ linkLocalNotAllowed: errors?.linkLocalNotAllowed,
2928
+ multicastNotAllowed: errors?.multicastNotAllowed,
2929
+ broadcastNotAllowed: errors?.broadcastNotAllowed,
2930
+ zeroNotAllowed: errors?.zeroNotAllowed
2931
+ } : void 0;
2807
2932
  return {
2808
2933
  $mode: "sync",
2809
2934
  metavar,
@@ -3148,6 +3273,13 @@ function cidr(options) {
3148
3273
  error: msg
3149
3274
  };
3150
3275
  }
3276
+ if (version === "both" && ipVersion === 6 && normalizedIp !== null) {
3277
+ const mappedOctets = extractIpv4FromMapped(normalizedIp);
3278
+ if (mappedOctets !== null) {
3279
+ const restrictionError = checkIpv4MappedRestrictions(mappedOctets, normalizedIp, mappedIpv4Opts, mappedIpv4Errors);
3280
+ if (restrictionError !== null) return restrictionError;
3281
+ }
3282
+ }
3151
3283
  return {
3152
3284
  success: true,
3153
3285
  value: {
@@ -2636,6 +2636,90 @@ function compressIpv6(groups) {
2636
2636
  else return before.join(":") + "::" + after.join(":");
2637
2637
  }
2638
2638
  /**
2639
+ * Extracts IPv4 octets from an IPv4-mapped IPv6 address.
2640
+ * Returns null if the address is not an IPv4-mapped address
2641
+ * (i.e., not in the `::ffff:x.x.x.x` range).
2642
+ */
2643
+ function extractIpv4FromMapped(normalizedIpv6) {
2644
+ const groups = expandIpv6(normalizedIpv6);
2645
+ if (groups === null) return null;
2646
+ for (let i = 0; i < 5; i++) if (parseInt(groups[i], 16) !== 0) return null;
2647
+ if (parseInt(groups[5], 16) !== 65535) return null;
2648
+ const high = parseInt(groups[6], 16);
2649
+ const low = parseInt(groups[7], 16);
2650
+ return [
2651
+ high >> 8 & 255,
2652
+ high & 255,
2653
+ low >> 8 & 255,
2654
+ low & 255
2655
+ ];
2656
+ }
2657
+ /**
2658
+ * Checks IPv4 restrictions against octets extracted from an IPv4-mapped
2659
+ * IPv6 address. The check uses the base address, consistent with how
2660
+ * the `ipv4()` parser validates the address part of a regular IPv4 CIDR.
2661
+ *
2662
+ * Returns an error result if a restriction is violated, or null if all
2663
+ * checks pass.
2664
+ */
2665
+ function checkIpv4MappedRestrictions(octets, normalizedIpv6, ipv4Opts, errors) {
2666
+ const allowPrivate = ipv4Opts?.allowPrivate ?? true;
2667
+ const allowLoopback = ipv4Opts?.allowLoopback ?? true;
2668
+ const allowLinkLocal = ipv4Opts?.allowLinkLocal ?? true;
2669
+ const allowMulticast = ipv4Opts?.allowMulticast ?? true;
2670
+ const allowBroadcast = ipv4Opts?.allowBroadcast ?? true;
2671
+ const allowZero = ipv4Opts?.allowZero ?? true;
2672
+ if (!allowPrivate && isPrivateIp(octets)) {
2673
+ const errorMsg = errors?.privateNotAllowed;
2674
+ const msg = typeof errorMsg === "function" ? errorMsg(normalizedIpv6) : errorMsg ?? message`${normalizedIpv6} is a private IP address.`;
2675
+ return {
2676
+ success: false,
2677
+ error: msg
2678
+ };
2679
+ }
2680
+ if (!allowLoopback && isLoopbackIp(octets)) {
2681
+ const errorMsg = errors?.loopbackNotAllowed;
2682
+ const msg = typeof errorMsg === "function" ? errorMsg(normalizedIpv6) : errorMsg ?? message`${normalizedIpv6} is a loopback address.`;
2683
+ return {
2684
+ success: false,
2685
+ error: msg
2686
+ };
2687
+ }
2688
+ if (!allowLinkLocal && isLinkLocalIp(octets)) {
2689
+ const errorMsg = errors?.linkLocalNotAllowed;
2690
+ const msg = typeof errorMsg === "function" ? errorMsg(normalizedIpv6) : errorMsg ?? message`${normalizedIpv6} is a link-local address.`;
2691
+ return {
2692
+ success: false,
2693
+ error: msg
2694
+ };
2695
+ }
2696
+ if (!allowMulticast && isMulticastIp(octets)) {
2697
+ const errorMsg = errors?.multicastNotAllowed;
2698
+ const msg = typeof errorMsg === "function" ? errorMsg(normalizedIpv6) : errorMsg ?? message`${normalizedIpv6} is a multicast address.`;
2699
+ return {
2700
+ success: false,
2701
+ error: msg
2702
+ };
2703
+ }
2704
+ if (!allowBroadcast && isBroadcastIp(octets)) {
2705
+ const errorMsg = errors?.broadcastNotAllowed;
2706
+ const msg = typeof errorMsg === "function" ? errorMsg(normalizedIpv6) : errorMsg ?? message`${normalizedIpv6} is the broadcast address.`;
2707
+ return {
2708
+ success: false,
2709
+ error: msg
2710
+ };
2711
+ }
2712
+ if (!allowZero && isZeroIp(octets)) {
2713
+ const errorMsg = errors?.zeroNotAllowed;
2714
+ const msg = typeof errorMsg === "function" ? errorMsg(normalizedIpv6) : errorMsg ?? message`${normalizedIpv6} is the zero address.`;
2715
+ return {
2716
+ success: false,
2717
+ error: msg
2718
+ };
2719
+ }
2720
+ return null;
2721
+ }
2722
+ /**
2639
2723
  * Creates a value parser that accepts both IPv4 and IPv6 addresses.
2640
2724
  *
2641
2725
  * By default, accepts both IPv4 and IPv6 addresses. Use the `version` option
@@ -2688,6 +2772,22 @@ function ip(options) {
2688
2772
  zeroNotAllowed: errors?.zeroNotAllowed
2689
2773
  }
2690
2774
  }) : null;
2775
+ const mappedIpv4Opts = version === "both" ? {
2776
+ allowPrivate: options?.ipv4?.allowPrivate,
2777
+ allowLoopback: options?.ipv4?.allowLoopback,
2778
+ allowLinkLocal: options?.ipv4?.allowLinkLocal,
2779
+ allowMulticast: options?.ipv4?.allowMulticast,
2780
+ allowBroadcast: options?.ipv4?.allowBroadcast,
2781
+ allowZero: options?.ipv4?.allowZero
2782
+ } : void 0;
2783
+ const mappedIpv4Errors = version === "both" ? {
2784
+ privateNotAllowed: errors?.privateNotAllowed,
2785
+ loopbackNotAllowed: errors?.loopbackNotAllowed,
2786
+ linkLocalNotAllowed: errors?.linkLocalNotAllowed,
2787
+ multicastNotAllowed: errors?.multicastNotAllowed,
2788
+ broadcastNotAllowed: errors?.broadcastNotAllowed,
2789
+ zeroNotAllowed: errors?.zeroNotAllowed
2790
+ } : void 0;
2691
2791
  return {
2692
2792
  $mode: "sync",
2693
2793
  metavar,
@@ -2702,7 +2802,16 @@ function ip(options) {
2702
2802
  }
2703
2803
  if (ipv6Parser !== null) {
2704
2804
  const result = ipv6Parser.parse(input);
2705
- if (result.success) return result;
2805
+ if (result.success) {
2806
+ if (version === "both") {
2807
+ const mappedOctets = extractIpv4FromMapped(result.value);
2808
+ if (mappedOctets !== null) {
2809
+ const restrictionError = checkIpv4MappedRestrictions(mappedOctets, result.value, mappedIpv4Opts, mappedIpv4Errors);
2810
+ if (restrictionError !== null) return restrictionError;
2811
+ }
2812
+ }
2813
+ return result;
2814
+ }
2706
2815
  ipv6Error = result;
2707
2816
  if (version === 6) return result;
2708
2817
  }
@@ -2804,6 +2913,22 @@ function cidr(options) {
2804
2913
  uniqueLocalNotAllowed: errors?.uniqueLocalNotAllowed
2805
2914
  }
2806
2915
  }) : null;
2916
+ const mappedIpv4Opts = version === "both" ? {
2917
+ allowPrivate: options?.ipv4?.allowPrivate,
2918
+ allowLoopback: options?.ipv4?.allowLoopback,
2919
+ allowLinkLocal: options?.ipv4?.allowLinkLocal,
2920
+ allowMulticast: options?.ipv4?.allowMulticast,
2921
+ allowBroadcast: options?.ipv4?.allowBroadcast,
2922
+ allowZero: options?.ipv4?.allowZero
2923
+ } : void 0;
2924
+ const mappedIpv4Errors = version === "both" ? {
2925
+ privateNotAllowed: errors?.privateNotAllowed,
2926
+ loopbackNotAllowed: errors?.loopbackNotAllowed,
2927
+ linkLocalNotAllowed: errors?.linkLocalNotAllowed,
2928
+ multicastNotAllowed: errors?.multicastNotAllowed,
2929
+ broadcastNotAllowed: errors?.broadcastNotAllowed,
2930
+ zeroNotAllowed: errors?.zeroNotAllowed
2931
+ } : void 0;
2807
2932
  return {
2808
2933
  $mode: "sync",
2809
2934
  metavar,
@@ -3148,6 +3273,13 @@ function cidr(options) {
3148
3273
  error: msg
3149
3274
  };
3150
3275
  }
3276
+ if (version === "both" && ipVersion === 6 && normalizedIp !== null) {
3277
+ const mappedOctets = extractIpv4FromMapped(normalizedIp);
3278
+ if (mappedOctets !== null) {
3279
+ const restrictionError = checkIpv4MappedRestrictions(mappedOctets, normalizedIp, mappedIpv4Opts, mappedIpv4Errors);
3280
+ if (restrictionError !== null) return restrictionError;
3281
+ }
3282
+ }
3151
3283
  return {
3152
3284
  success: true,
3153
3285
  value: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1452+b060cbd3",
3
+ "version": "1.0.0-dev.1461+fd58e837",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",