@optique/core 1.3.2 → 1.3.4
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/constructs.cjs +49 -23
- package/dist/constructs.js +49 -23
- package/dist/doc.cjs +11 -3
- package/dist/doc.js +12 -4
- package/dist/internal/command-doc-metadata.cjs +90 -0
- package/dist/internal/command-doc-metadata.js +87 -0
- package/dist/message.cjs +32 -5
- package/dist/message.js +33 -6
- package/dist/modifiers.cjs +3 -2
- package/dist/modifiers.js +3 -2
- package/dist/primitives.cjs +29 -22
- package/dist/primitives.js +29 -22
- package/dist/terminal-internal.cjs +4 -1
- package/dist/terminal-internal.d.cts +5 -0
- package/dist/terminal-internal.d.ts +5 -0
- package/dist/terminal-internal.js +4 -1
- package/dist/terminal-separators.cjs +13 -0
- package/dist/terminal-separators.js +12 -0
- package/dist/terminal.cjs +4 -1
- package/dist/terminal.js +5 -1
- package/dist/text-layout.cjs +14 -1
- package/dist/text-layout.d.cts +8 -1
- package/dist/text-layout.d.ts +8 -1
- package/dist/text-layout.js +13 -1
- package/package.json +2 -2
package/dist/constructs.cjs
CHANGED
|
@@ -8,6 +8,7 @@ const require_internal_dependency = require('./internal/dependency.cjs');
|
|
|
8
8
|
const require_dependency_runtime = require('./dependency-runtime.cjs');
|
|
9
9
|
const require_internal_parser = require('./internal/parser.cjs');
|
|
10
10
|
const require_annotation_state = require('./annotation-state.cjs');
|
|
11
|
+
const require_command_doc_metadata = require('./internal/command-doc-metadata.cjs');
|
|
11
12
|
const require_passthrough = require('./internal/passthrough.cjs');
|
|
12
13
|
const require_command_alias = require('./internal/command-alias.cjs');
|
|
13
14
|
const require_execution_context = require('./execution-context.cjs');
|
|
@@ -1902,6 +1903,7 @@ function or(...args) {
|
|
|
1902
1903
|
},
|
|
1903
1904
|
suggest: createExclusiveSuggest(parsers, combinedMode),
|
|
1904
1905
|
getDocFragments(state, _defaultValue) {
|
|
1906
|
+
let commandMetadata;
|
|
1905
1907
|
let brief;
|
|
1906
1908
|
let description;
|
|
1907
1909
|
let footer;
|
|
@@ -1914,18 +1916,19 @@ function or(...args) {
|
|
|
1914
1916
|
state: parserResult.next.state
|
|
1915
1917
|
} : { kind: "unavailable" };
|
|
1916
1918
|
const docFragments = parsers[index].getDocFragments(innerState, void 0);
|
|
1919
|
+
commandMetadata = require_command_doc_metadata.getCommandDocMetadata(docFragments);
|
|
1917
1920
|
brief = docFragments.brief;
|
|
1918
1921
|
description = docFragments.description;
|
|
1919
1922
|
footer = docFragments.footer;
|
|
1920
1923
|
fragments = docFragments.fragments;
|
|
1921
1924
|
}
|
|
1922
1925
|
if (state.kind === "unavailable" || state.state == null) fragments = require_doc.deduplicateDocFragments(fragments);
|
|
1923
|
-
return {
|
|
1926
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
1924
1927
|
brief,
|
|
1925
1928
|
description,
|
|
1926
1929
|
footer,
|
|
1927
1930
|
fragments
|
|
1928
|
-
};
|
|
1931
|
+
}, commandMetadata);
|
|
1929
1932
|
}
|
|
1930
1933
|
};
|
|
1931
1934
|
const singleDependencyMetadata = composeExclusiveDependencyMetadata(parsers);
|
|
@@ -2134,6 +2137,7 @@ function createLongestMatch(...args) {
|
|
|
2134
2137
|
},
|
|
2135
2138
|
suggest: createExclusiveSuggest(parsers, combinedMode),
|
|
2136
2139
|
getDocFragments(state, _defaultValue) {
|
|
2140
|
+
let commandMetadata;
|
|
2137
2141
|
let brief;
|
|
2138
2142
|
let description;
|
|
2139
2143
|
let footer;
|
|
@@ -2149,6 +2153,7 @@ function createLongestMatch(...args) {
|
|
|
2149
2153
|
kind: "available",
|
|
2150
2154
|
state: result.next.state
|
|
2151
2155
|
});
|
|
2156
|
+
commandMetadata = require_command_doc_metadata.getCommandDocMetadata(docResult);
|
|
2152
2157
|
brief = docResult.brief;
|
|
2153
2158
|
description = docResult.description;
|
|
2154
2159
|
footer = docResult.footer;
|
|
@@ -2159,12 +2164,12 @@ function createLongestMatch(...args) {
|
|
|
2159
2164
|
shouldDeduplicate = true;
|
|
2160
2165
|
}
|
|
2161
2166
|
}
|
|
2162
|
-
return {
|
|
2167
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
2163
2168
|
brief,
|
|
2164
2169
|
description,
|
|
2165
2170
|
fragments: shouldDeduplicate ? require_doc.deduplicateDocFragments(fragments) : fragments,
|
|
2166
2171
|
footer
|
|
2167
|
-
};
|
|
2172
|
+
}, commandMetadata);
|
|
2168
2173
|
}
|
|
2169
2174
|
};
|
|
2170
2175
|
const multiDependencyMetadata = composeExclusiveDependencyMetadata(parsers);
|
|
@@ -3162,12 +3167,15 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3162
3167
|
}, () => suggestObjectAsync(context, prefix, parserPairs));
|
|
3163
3168
|
},
|
|
3164
3169
|
getDocFragments(state, defaultValue) {
|
|
3170
|
+
let commandMetadata;
|
|
3165
3171
|
const fragments = parserPairs.flatMap(([field, p]) => {
|
|
3166
3172
|
const fieldState = state.kind === "unavailable" ? { kind: "unavailable" } : {
|
|
3167
3173
|
kind: "available",
|
|
3168
3174
|
state: state.state[field]
|
|
3169
3175
|
};
|
|
3170
|
-
|
|
3176
|
+
const docs = p.getDocFragments(fieldState, defaultValue?.[field]);
|
|
3177
|
+
commandMetadata = require_command_doc_metadata.collectCommandDocMetadata(commandMetadata, docs);
|
|
3178
|
+
return docs.fragments;
|
|
3171
3179
|
});
|
|
3172
3180
|
const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
|
|
3173
3181
|
const entries = hiddenAwareFragments.filter((d) => d.type === "entry");
|
|
@@ -3182,10 +3190,13 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3182
3190
|
entries
|
|
3183
3191
|
};
|
|
3184
3192
|
sections.push(section);
|
|
3185
|
-
return
|
|
3186
|
-
...
|
|
3187
|
-
|
|
3188
|
-
|
|
3193
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
3194
|
+
...commandMetadata,
|
|
3195
|
+
fragments: sections.map((s) => ({
|
|
3196
|
+
...s,
|
|
3197
|
+
type: "section"
|
|
3198
|
+
}))
|
|
3199
|
+
}, commandMetadata);
|
|
3189
3200
|
}
|
|
3190
3201
|
};
|
|
3191
3202
|
const fieldNormalizers = [];
|
|
@@ -4196,12 +4207,15 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
4196
4207
|
return require_mode_dispatch.dispatchIterableByMode(combinedMode, () => suggestTupleSync(context, prefix, syncParsers), () => suggestTupleAsync(context, prefix, parsers));
|
|
4197
4208
|
},
|
|
4198
4209
|
getDocFragments(state, defaultValue) {
|
|
4210
|
+
let commandMetadata;
|
|
4199
4211
|
const fragments = syncParsers.flatMap((p, i) => {
|
|
4200
4212
|
const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
|
|
4201
4213
|
kind: "available",
|
|
4202
4214
|
state: state.state[i]
|
|
4203
4215
|
};
|
|
4204
|
-
|
|
4216
|
+
const docs = p.getDocFragments(indexState, defaultValue?.[i]);
|
|
4217
|
+
commandMetadata = require_command_doc_metadata.collectCommandDocMetadata(commandMetadata, docs);
|
|
4218
|
+
return docs.fragments;
|
|
4205
4219
|
});
|
|
4206
4220
|
const entries = fragments.filter((d) => d.type === "entry");
|
|
4207
4221
|
const sections = [];
|
|
@@ -4215,10 +4229,13 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
4215
4229
|
entries
|
|
4216
4230
|
};
|
|
4217
4231
|
sections.push(section);
|
|
4218
|
-
return
|
|
4219
|
-
...
|
|
4220
|
-
|
|
4221
|
-
|
|
4232
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
4233
|
+
...commandMetadata,
|
|
4234
|
+
fragments: sections.map((s) => ({
|
|
4235
|
+
...s,
|
|
4236
|
+
type: "section"
|
|
4237
|
+
}))
|
|
4238
|
+
}, commandMetadata);
|
|
4222
4239
|
},
|
|
4223
4240
|
[Symbol.for("Deno.customInspect")]() {
|
|
4224
4241
|
const parsersStr = parsers.length === 1 ? `[1 parser]` : `[${parsers.length} parsers]`;
|
|
@@ -5534,6 +5551,7 @@ function merge(...args) {
|
|
|
5534
5551
|
}();
|
|
5535
5552
|
},
|
|
5536
5553
|
getDocFragments(state, _defaultValue) {
|
|
5554
|
+
let commandMetadata;
|
|
5537
5555
|
let brief;
|
|
5538
5556
|
let description;
|
|
5539
5557
|
let footer;
|
|
@@ -5551,6 +5569,7 @@ function merge(...args) {
|
|
|
5551
5569
|
state: state.state
|
|
5552
5570
|
};
|
|
5553
5571
|
const docFragments = p.getDocFragments(parserState, void 0);
|
|
5572
|
+
commandMetadata = require_command_doc_metadata.collectCommandDocMetadata(commandMetadata, docFragments, true);
|
|
5554
5573
|
brief ??= docFragments.brief;
|
|
5555
5574
|
description ??= docFragments.description;
|
|
5556
5575
|
footer ??= docFragments.footer;
|
|
@@ -5570,7 +5589,7 @@ function merge(...args) {
|
|
|
5570
5589
|
entries
|
|
5571
5590
|
};
|
|
5572
5591
|
sections.push(labeledSection);
|
|
5573
|
-
return {
|
|
5592
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
5574
5593
|
brief,
|
|
5575
5594
|
description,
|
|
5576
5595
|
footer,
|
|
@@ -5578,9 +5597,9 @@ function merge(...args) {
|
|
|
5578
5597
|
...s,
|
|
5579
5598
|
type: "section"
|
|
5580
5599
|
}))
|
|
5581
|
-
};
|
|
5600
|
+
}, commandMetadata);
|
|
5582
5601
|
}
|
|
5583
|
-
return {
|
|
5602
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
5584
5603
|
brief,
|
|
5585
5604
|
description,
|
|
5586
5605
|
footer,
|
|
@@ -5591,7 +5610,7 @@ function merge(...args) {
|
|
|
5591
5610
|
type: "section",
|
|
5592
5611
|
entries
|
|
5593
5612
|
}]
|
|
5594
|
-
};
|
|
5613
|
+
}, commandMetadata);
|
|
5595
5614
|
}
|
|
5596
5615
|
};
|
|
5597
5616
|
require_internal_parser.defineParseLanes(mergeParser, mergeParseLanes);
|
|
@@ -6220,12 +6239,15 @@ function concat(...parsers) {
|
|
|
6220
6239
|
}();
|
|
6221
6240
|
},
|
|
6222
6241
|
getDocFragments(state, _defaultValue) {
|
|
6242
|
+
let commandMetadata;
|
|
6223
6243
|
const fragments = syncParsers.flatMap((p, index) => {
|
|
6224
6244
|
const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
|
|
6225
6245
|
kind: "available",
|
|
6226
6246
|
state: state.state[index]
|
|
6227
6247
|
};
|
|
6228
|
-
|
|
6248
|
+
const docs = p.getDocFragments(indexState, void 0);
|
|
6249
|
+
commandMetadata = require_command_doc_metadata.collectCommandDocMetadata(commandMetadata, docs);
|
|
6250
|
+
return docs.fragments;
|
|
6229
6251
|
});
|
|
6230
6252
|
const entries = fragments.filter((f) => f.type === "entry");
|
|
6231
6253
|
const sections = [];
|
|
@@ -6242,7 +6264,10 @@ function concat(...parsers) {
|
|
|
6242
6264
|
type: "section",
|
|
6243
6265
|
entries
|
|
6244
6266
|
});
|
|
6245
|
-
return {
|
|
6267
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
6268
|
+
...commandMetadata,
|
|
6269
|
+
fragments: result
|
|
6270
|
+
}, commandMetadata);
|
|
6246
6271
|
}
|
|
6247
6272
|
};
|
|
6248
6273
|
require_internal_parser.defineInheritedAnnotationParser(concatParser);
|
|
@@ -6281,7 +6306,8 @@ function group(label, parser, options = {}) {
|
|
|
6281
6306
|
return parser.suggest(context, prefix);
|
|
6282
6307
|
},
|
|
6283
6308
|
getDocFragments: (state, defaultValue) => {
|
|
6284
|
-
const
|
|
6309
|
+
const docs = parser.getDocFragments(state, defaultValue);
|
|
6310
|
+
const { brief, description, footer, fragments } = docs;
|
|
6285
6311
|
const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
|
|
6286
6312
|
const allEntries = [];
|
|
6287
6313
|
const titledSections = [];
|
|
@@ -6304,7 +6330,7 @@ function group(label, parser, options = {}) {
|
|
|
6304
6330
|
title: label,
|
|
6305
6331
|
entries: allEntries
|
|
6306
6332
|
} : { entries: allEntries };
|
|
6307
|
-
return {
|
|
6333
|
+
return require_command_doc_metadata.withCommandDocMetadata({
|
|
6308
6334
|
brief,
|
|
6309
6335
|
description,
|
|
6310
6336
|
footer,
|
|
@@ -6315,7 +6341,7 @@ function group(label, parser, options = {}) {
|
|
|
6315
6341
|
type: "section",
|
|
6316
6342
|
...labeledSection
|
|
6317
6343
|
}]
|
|
6318
|
-
};
|
|
6344
|
+
}, require_command_doc_metadata.getCommandDocMetadata(docs));
|
|
6319
6345
|
}
|
|
6320
6346
|
};
|
|
6321
6347
|
require_internal_parser.defineParseLanes(groupParser, require_internal_parser.getOwnParseLanes(parser));
|
package/dist/constructs.js
CHANGED
|
@@ -8,6 +8,7 @@ import { createDependencySourceState, dependencyId, isDependencySourceState, isP
|
|
|
8
8
|
import { buildRuntimeNodesFromArray, buildRuntimeNodesFromPairs, collectExplicitSourceValues, collectExplicitSourceValuesAsync, collectSourcesFromState, completeEffectfulSourcesAsync, createDependencyRuntimeContext, effectfulSchedulingNodesKey, exclusiveSourceScopeKey, extractRawInputFromState, fillMissingSourceDefaults, fillMissingSourceDefaultsAsync, forkRuntimeForCommittedSubtree, getDefaultDependencySnapshot, guaranteedStaticSourceIdsKey, hasInactiveCompletion, isMatchedState, recordSourceScope, releaseUncollectedSourceValues, replaceCachedBarrierFailure, resolveDerivedSourceValues, resolveDerivedSourceValuesAsync, resolveStateWithRuntime, resolveStateWithRuntimeAsync, serializeSchedulingPath, sourceCollectionExpansionKey, staticSourceScopeKey } from "./dependency-runtime.js";
|
|
9
9
|
import { defineInheritedAnnotationParser, defineParseLanes, getOwnParseLanes, getParserSuggestRuntimeNodes, unmatchedNonCliDependencySourceStateMarker } from "./internal/parser.js";
|
|
10
10
|
import { annotationViewTargets, getWrappedChildParseState, getWrappedChildState, reconcileObjectChildState, unwrapAnnotationView } from "./annotation-state.js";
|
|
11
|
+
import { collectCommandDocMetadata, getCommandDocMetadata, withCommandDocMetadata } from "./internal/command-doc-metadata.js";
|
|
11
12
|
import { combineOptionMatches, combinePassThroughPriorities, defineOptionMatch, definePassThroughPriority, delegateKnownCompletion, getKnownCompletion, getOptionMatch, getPassThroughFailureHint, getPassThroughPriority, hasPassThroughUsage, matchesOptionToken, retainConsumingFailure, retainConsumingFailureHint, withPassThroughFailure } from "./internal/passthrough.js";
|
|
12
13
|
import { allowDuplicateLeadingCommandNamesKey } from "./internal/command-alias.js";
|
|
13
14
|
import { mergeChildExec, withChildContext, withChildExecPath } from "./execution-context.js";
|
|
@@ -1902,6 +1903,7 @@ function or(...args) {
|
|
|
1902
1903
|
},
|
|
1903
1904
|
suggest: createExclusiveSuggest(parsers, combinedMode),
|
|
1904
1905
|
getDocFragments(state, _defaultValue) {
|
|
1906
|
+
let commandMetadata;
|
|
1905
1907
|
let brief;
|
|
1906
1908
|
let description;
|
|
1907
1909
|
let footer;
|
|
@@ -1914,18 +1916,19 @@ function or(...args) {
|
|
|
1914
1916
|
state: parserResult.next.state
|
|
1915
1917
|
} : { kind: "unavailable" };
|
|
1916
1918
|
const docFragments = parsers[index].getDocFragments(innerState, void 0);
|
|
1919
|
+
commandMetadata = getCommandDocMetadata(docFragments);
|
|
1917
1920
|
brief = docFragments.brief;
|
|
1918
1921
|
description = docFragments.description;
|
|
1919
1922
|
footer = docFragments.footer;
|
|
1920
1923
|
fragments = docFragments.fragments;
|
|
1921
1924
|
}
|
|
1922
1925
|
if (state.kind === "unavailable" || state.state == null) fragments = deduplicateDocFragments(fragments);
|
|
1923
|
-
return {
|
|
1926
|
+
return withCommandDocMetadata({
|
|
1924
1927
|
brief,
|
|
1925
1928
|
description,
|
|
1926
1929
|
footer,
|
|
1927
1930
|
fragments
|
|
1928
|
-
};
|
|
1931
|
+
}, commandMetadata);
|
|
1929
1932
|
}
|
|
1930
1933
|
};
|
|
1931
1934
|
const singleDependencyMetadata = composeExclusiveDependencyMetadata(parsers);
|
|
@@ -2134,6 +2137,7 @@ function createLongestMatch(...args) {
|
|
|
2134
2137
|
},
|
|
2135
2138
|
suggest: createExclusiveSuggest(parsers, combinedMode),
|
|
2136
2139
|
getDocFragments(state, _defaultValue) {
|
|
2140
|
+
let commandMetadata;
|
|
2137
2141
|
let brief;
|
|
2138
2142
|
let description;
|
|
2139
2143
|
let footer;
|
|
@@ -2149,6 +2153,7 @@ function createLongestMatch(...args) {
|
|
|
2149
2153
|
kind: "available",
|
|
2150
2154
|
state: result.next.state
|
|
2151
2155
|
});
|
|
2156
|
+
commandMetadata = getCommandDocMetadata(docResult);
|
|
2152
2157
|
brief = docResult.brief;
|
|
2153
2158
|
description = docResult.description;
|
|
2154
2159
|
footer = docResult.footer;
|
|
@@ -2159,12 +2164,12 @@ function createLongestMatch(...args) {
|
|
|
2159
2164
|
shouldDeduplicate = true;
|
|
2160
2165
|
}
|
|
2161
2166
|
}
|
|
2162
|
-
return {
|
|
2167
|
+
return withCommandDocMetadata({
|
|
2163
2168
|
brief,
|
|
2164
2169
|
description,
|
|
2165
2170
|
fragments: shouldDeduplicate ? deduplicateDocFragments(fragments) : fragments,
|
|
2166
2171
|
footer
|
|
2167
|
-
};
|
|
2172
|
+
}, commandMetadata);
|
|
2168
2173
|
}
|
|
2169
2174
|
};
|
|
2170
2175
|
const multiDependencyMetadata = composeExclusiveDependencyMetadata(parsers);
|
|
@@ -3162,12 +3167,15 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3162
3167
|
}, () => suggestObjectAsync(context, prefix, parserPairs));
|
|
3163
3168
|
},
|
|
3164
3169
|
getDocFragments(state, defaultValue) {
|
|
3170
|
+
let commandMetadata;
|
|
3165
3171
|
const fragments = parserPairs.flatMap(([field, p]) => {
|
|
3166
3172
|
const fieldState = state.kind === "unavailable" ? { kind: "unavailable" } : {
|
|
3167
3173
|
kind: "available",
|
|
3168
3174
|
state: state.state[field]
|
|
3169
3175
|
};
|
|
3170
|
-
|
|
3176
|
+
const docs = p.getDocFragments(fieldState, defaultValue?.[field]);
|
|
3177
|
+
commandMetadata = collectCommandDocMetadata(commandMetadata, docs);
|
|
3178
|
+
return docs.fragments;
|
|
3171
3179
|
});
|
|
3172
3180
|
const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
|
|
3173
3181
|
const entries = hiddenAwareFragments.filter((d) => d.type === "entry");
|
|
@@ -3182,10 +3190,13 @@ function object(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
3182
3190
|
entries
|
|
3183
3191
|
};
|
|
3184
3192
|
sections.push(section);
|
|
3185
|
-
return
|
|
3186
|
-
...
|
|
3187
|
-
|
|
3188
|
-
|
|
3193
|
+
return withCommandDocMetadata({
|
|
3194
|
+
...commandMetadata,
|
|
3195
|
+
fragments: sections.map((s) => ({
|
|
3196
|
+
...s,
|
|
3197
|
+
type: "section"
|
|
3198
|
+
}))
|
|
3199
|
+
}, commandMetadata);
|
|
3189
3200
|
}
|
|
3190
3201
|
};
|
|
3191
3202
|
const fieldNormalizers = [];
|
|
@@ -4196,12 +4207,15 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
4196
4207
|
return dispatchIterableByMode(combinedMode, () => suggestTupleSync(context, prefix, syncParsers), () => suggestTupleAsync(context, prefix, parsers));
|
|
4197
4208
|
},
|
|
4198
4209
|
getDocFragments(state, defaultValue) {
|
|
4210
|
+
let commandMetadata;
|
|
4199
4211
|
const fragments = syncParsers.flatMap((p, i) => {
|
|
4200
4212
|
const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
|
|
4201
4213
|
kind: "available",
|
|
4202
4214
|
state: state.state[i]
|
|
4203
4215
|
};
|
|
4204
|
-
|
|
4216
|
+
const docs = p.getDocFragments(indexState, defaultValue?.[i]);
|
|
4217
|
+
commandMetadata = collectCommandDocMetadata(commandMetadata, docs);
|
|
4218
|
+
return docs.fragments;
|
|
4205
4219
|
});
|
|
4206
4220
|
const entries = fragments.filter((d) => d.type === "entry");
|
|
4207
4221
|
const sections = [];
|
|
@@ -4215,10 +4229,13 @@ function tuple(labelOrParsers, maybeParsersOrOptions, maybeOptions) {
|
|
|
4215
4229
|
entries
|
|
4216
4230
|
};
|
|
4217
4231
|
sections.push(section);
|
|
4218
|
-
return
|
|
4219
|
-
...
|
|
4220
|
-
|
|
4221
|
-
|
|
4232
|
+
return withCommandDocMetadata({
|
|
4233
|
+
...commandMetadata,
|
|
4234
|
+
fragments: sections.map((s) => ({
|
|
4235
|
+
...s,
|
|
4236
|
+
type: "section"
|
|
4237
|
+
}))
|
|
4238
|
+
}, commandMetadata);
|
|
4222
4239
|
},
|
|
4223
4240
|
[Symbol.for("Deno.customInspect")]() {
|
|
4224
4241
|
const parsersStr = parsers.length === 1 ? `[1 parser]` : `[${parsers.length} parsers]`;
|
|
@@ -5534,6 +5551,7 @@ function merge(...args) {
|
|
|
5534
5551
|
}();
|
|
5535
5552
|
},
|
|
5536
5553
|
getDocFragments(state, _defaultValue) {
|
|
5554
|
+
let commandMetadata;
|
|
5537
5555
|
let brief;
|
|
5538
5556
|
let description;
|
|
5539
5557
|
let footer;
|
|
@@ -5551,6 +5569,7 @@ function merge(...args) {
|
|
|
5551
5569
|
state: state.state
|
|
5552
5570
|
};
|
|
5553
5571
|
const docFragments = p.getDocFragments(parserState, void 0);
|
|
5572
|
+
commandMetadata = collectCommandDocMetadata(commandMetadata, docFragments, true);
|
|
5554
5573
|
brief ??= docFragments.brief;
|
|
5555
5574
|
description ??= docFragments.description;
|
|
5556
5575
|
footer ??= docFragments.footer;
|
|
@@ -5570,7 +5589,7 @@ function merge(...args) {
|
|
|
5570
5589
|
entries
|
|
5571
5590
|
};
|
|
5572
5591
|
sections.push(labeledSection);
|
|
5573
|
-
return {
|
|
5592
|
+
return withCommandDocMetadata({
|
|
5574
5593
|
brief,
|
|
5575
5594
|
description,
|
|
5576
5595
|
footer,
|
|
@@ -5578,9 +5597,9 @@ function merge(...args) {
|
|
|
5578
5597
|
...s,
|
|
5579
5598
|
type: "section"
|
|
5580
5599
|
}))
|
|
5581
|
-
};
|
|
5600
|
+
}, commandMetadata);
|
|
5582
5601
|
}
|
|
5583
|
-
return {
|
|
5602
|
+
return withCommandDocMetadata({
|
|
5584
5603
|
brief,
|
|
5585
5604
|
description,
|
|
5586
5605
|
footer,
|
|
@@ -5591,7 +5610,7 @@ function merge(...args) {
|
|
|
5591
5610
|
type: "section",
|
|
5592
5611
|
entries
|
|
5593
5612
|
}]
|
|
5594
|
-
};
|
|
5613
|
+
}, commandMetadata);
|
|
5595
5614
|
}
|
|
5596
5615
|
};
|
|
5597
5616
|
defineParseLanes(mergeParser, mergeParseLanes);
|
|
@@ -6220,12 +6239,15 @@ function concat(...parsers) {
|
|
|
6220
6239
|
}();
|
|
6221
6240
|
},
|
|
6222
6241
|
getDocFragments(state, _defaultValue) {
|
|
6242
|
+
let commandMetadata;
|
|
6223
6243
|
const fragments = syncParsers.flatMap((p, index) => {
|
|
6224
6244
|
const indexState = state.kind === "unavailable" ? { kind: "unavailable" } : {
|
|
6225
6245
|
kind: "available",
|
|
6226
6246
|
state: state.state[index]
|
|
6227
6247
|
};
|
|
6228
|
-
|
|
6248
|
+
const docs = p.getDocFragments(indexState, void 0);
|
|
6249
|
+
commandMetadata = collectCommandDocMetadata(commandMetadata, docs);
|
|
6250
|
+
return docs.fragments;
|
|
6229
6251
|
});
|
|
6230
6252
|
const entries = fragments.filter((f) => f.type === "entry");
|
|
6231
6253
|
const sections = [];
|
|
@@ -6242,7 +6264,10 @@ function concat(...parsers) {
|
|
|
6242
6264
|
type: "section",
|
|
6243
6265
|
entries
|
|
6244
6266
|
});
|
|
6245
|
-
return {
|
|
6267
|
+
return withCommandDocMetadata({
|
|
6268
|
+
...commandMetadata,
|
|
6269
|
+
fragments: result
|
|
6270
|
+
}, commandMetadata);
|
|
6246
6271
|
}
|
|
6247
6272
|
};
|
|
6248
6273
|
defineInheritedAnnotationParser(concatParser);
|
|
@@ -6281,7 +6306,8 @@ function group(label, parser, options = {}) {
|
|
|
6281
6306
|
return parser.suggest(context, prefix);
|
|
6282
6307
|
},
|
|
6283
6308
|
getDocFragments: (state, defaultValue) => {
|
|
6284
|
-
const
|
|
6309
|
+
const docs = parser.getDocFragments(state, defaultValue);
|
|
6310
|
+
const { brief, description, footer, fragments } = docs;
|
|
6285
6311
|
const hiddenAwareFragments = applyHiddenToDocFragments(fragments, options.hidden);
|
|
6286
6312
|
const allEntries = [];
|
|
6287
6313
|
const titledSections = [];
|
|
@@ -6304,7 +6330,7 @@ function group(label, parser, options = {}) {
|
|
|
6304
6330
|
title: label,
|
|
6305
6331
|
entries: allEntries
|
|
6306
6332
|
} : { entries: allEntries };
|
|
6307
|
-
return {
|
|
6333
|
+
return withCommandDocMetadata({
|
|
6308
6334
|
brief,
|
|
6309
6335
|
description,
|
|
6310
6336
|
footer,
|
|
@@ -6315,7 +6341,7 @@ function group(label, parser, options = {}) {
|
|
|
6315
6341
|
type: "section",
|
|
6316
6342
|
...labeledSection
|
|
6317
6343
|
}]
|
|
6318
|
-
};
|
|
6344
|
+
}, getCommandDocMetadata(docs));
|
|
6319
6345
|
}
|
|
6320
6346
|
};
|
|
6321
6347
|
defineParseLanes(groupParser, getOwnParseLanes(parser));
|
package/dist/doc.cjs
CHANGED
|
@@ -431,8 +431,16 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
431
431
|
column: extraTermOffset
|
|
432
432
|
}).cursor;
|
|
433
433
|
const appendAnnotation = (content, layout, style, ambient, quotes) => {
|
|
434
|
-
|
|
435
|
-
|
|
434
|
+
let prefixText = layout.prefix;
|
|
435
|
+
let prefix = require_text_layout.placeText(prefixText, cursor, descColumnWidth, 1);
|
|
436
|
+
if (prefix.text !== layout.prefix) {
|
|
437
|
+
description += "\n";
|
|
438
|
+
prefixText = require_text_layout.trimLeadingSpace(layout.prefix);
|
|
439
|
+
prefix = require_text_layout.placeText(prefixText, {
|
|
440
|
+
line: "",
|
|
441
|
+
column: 0
|
|
442
|
+
});
|
|
443
|
+
}
|
|
436
444
|
const rendered = formatMessage(content, {
|
|
437
445
|
colors: options.colors ? { resetSuffix: style } : false,
|
|
438
446
|
quotes,
|
|
@@ -440,7 +448,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
440
448
|
initialWidth: descColumnWidth != null || layout.prefixMetrics.lineCount > 1 ? prefix.cursor.column : void 0
|
|
441
449
|
}, ambient);
|
|
442
450
|
const suffix = require_text_layout.placeText(layout.suffix, require_text_layout.placeText(rendered, prefix.cursor).cursor, descColumnWidth);
|
|
443
|
-
const annotationText = `${
|
|
451
|
+
const annotationText = `${prefixText}${rendered}${opaqueFormatter && options.colors ? style : ""}${suffix.text}`;
|
|
444
452
|
description += options.colors ? `${style}${annotationText}${style ? "\x1B[0m" : ""}` : annotationText;
|
|
445
453
|
cursor = suffix.cursor;
|
|
446
454
|
};
|
package/dist/doc.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cacheTerminalTheme, renderTerminalTerm, styleCode } from "./terminal-internal.js";
|
|
2
|
-
import { measureAnnotation, measureText, placeText, spaceAfterLabel } from "./text-layout.js";
|
|
2
|
+
import { measureAnnotation, measureText, placeText, spaceAfterLabel, trimLeadingSpace } from "./text-layout.js";
|
|
3
3
|
import { validateLabel, validateProgramName } from "./validate.js";
|
|
4
4
|
import { cloneUsageTerm, formatUsage, formatUsageTerm, isDocHidden } from "./usage.js";
|
|
5
5
|
import { hasAutomaticWidth, minimumUsageWidth, reportAutomaticWidth } from "./terminal-width.js";
|
|
@@ -431,8 +431,16 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
431
431
|
column: extraTermOffset
|
|
432
432
|
}).cursor;
|
|
433
433
|
const appendAnnotation = (content, layout, style, ambient, quotes) => {
|
|
434
|
-
|
|
435
|
-
|
|
434
|
+
let prefixText = layout.prefix;
|
|
435
|
+
let prefix = placeText(prefixText, cursor, descColumnWidth, 1);
|
|
436
|
+
if (prefix.text !== layout.prefix) {
|
|
437
|
+
description += "\n";
|
|
438
|
+
prefixText = trimLeadingSpace(layout.prefix);
|
|
439
|
+
prefix = placeText(prefixText, {
|
|
440
|
+
line: "",
|
|
441
|
+
column: 0
|
|
442
|
+
});
|
|
443
|
+
}
|
|
436
444
|
const rendered = formatMessage(content, {
|
|
437
445
|
colors: options.colors ? { resetSuffix: style } : false,
|
|
438
446
|
quotes,
|
|
@@ -440,7 +448,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
440
448
|
initialWidth: descColumnWidth != null || layout.prefixMetrics.lineCount > 1 ? prefix.cursor.column : void 0
|
|
441
449
|
}, ambient);
|
|
442
450
|
const suffix = placeText(layout.suffix, placeText(rendered, prefix.cursor).cursor, descColumnWidth);
|
|
443
|
-
const annotationText = `${
|
|
451
|
+
const annotationText = `${prefixText}${rendered}${opaqueFormatter && options.colors ? style : ""}${suffix.text}`;
|
|
444
452
|
description += options.colors ? `${style}${annotationText}${style ? "\x1B[0m" : ""}` : annotationText;
|
|
445
453
|
cursor = suffix.cursor;
|
|
446
454
|
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/internal/command-doc-metadata.ts
|
|
3
|
+
function withOrigin(metadata, origin) {
|
|
4
|
+
const result = { ...metadata };
|
|
5
|
+
Object.defineProperty(result, "origin", {
|
|
6
|
+
value: origin,
|
|
7
|
+
enumerable: false
|
|
8
|
+
});
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
const commandDocMetadata = Symbol.for("@optique/core/commandDocMetadata");
|
|
12
|
+
const commandDocCarrier = Symbol.for("@optique/core/commandDocMetadataCarrier");
|
|
13
|
+
/**
|
|
14
|
+
* Reads effective page metadata, including custom collection-level fields.
|
|
15
|
+
* @param docs The child's documentation.
|
|
16
|
+
* @returns Its selected-command metadata, if any.
|
|
17
|
+
*/
|
|
18
|
+
function getCommandDocMetadata(docs) {
|
|
19
|
+
const carrier = docs.fragments[commandDocCarrier];
|
|
20
|
+
if (carrier != null) {
|
|
21
|
+
const brief = docs.brief === carrier.brief ? carrier.metadata.brief : docs.brief;
|
|
22
|
+
const origin = carrier.metadata.origin ?? "entry";
|
|
23
|
+
const customPage = origin === "entry" && (docs.brief !== carrier.brief || docs.footer !== carrier.footer);
|
|
24
|
+
const description = origin === "entry" && !customPage || docs.description === carrier.description ? carrier.metadata.description : docs.description;
|
|
25
|
+
const footer = docs.footer === carrier.footer ? carrier.metadata.footer : docs.footer;
|
|
26
|
+
return withOrigin({
|
|
27
|
+
...brief == null ? {} : { brief },
|
|
28
|
+
...description == null ? {} : { description },
|
|
29
|
+
...footer == null ? {} : { footer }
|
|
30
|
+
}, customPage ? "custom" : origin);
|
|
31
|
+
}
|
|
32
|
+
const metadata = docs[commandDocMetadata];
|
|
33
|
+
if (metadata != null) return metadata;
|
|
34
|
+
return docs.brief != null || docs.description != null || docs.footer != null ? withOrigin({
|
|
35
|
+
brief: docs.brief,
|
|
36
|
+
description: docs.description,
|
|
37
|
+
footer: docs.footer
|
|
38
|
+
}, "custom") : void 0;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Preserves selected-command metadata when rebuilding documentation fragments.
|
|
42
|
+
* @param docs The rebuilt documentation.
|
|
43
|
+
* @param metadata The selected-command metadata to preserve.
|
|
44
|
+
* @returns Documentation with the internal metadata attached.
|
|
45
|
+
*/
|
|
46
|
+
function withCommandDocMetadata(docs, metadata) {
|
|
47
|
+
if (metadata == null) return docs;
|
|
48
|
+
metadata = withOrigin(metadata, metadata.origin ?? "entry");
|
|
49
|
+
const fragments = [...docs.fragments];
|
|
50
|
+
Object.defineProperty(fragments, commandDocCarrier, { value: {
|
|
51
|
+
metadata,
|
|
52
|
+
brief: docs.brief,
|
|
53
|
+
description: docs.description,
|
|
54
|
+
footer: docs.footer
|
|
55
|
+
} });
|
|
56
|
+
const result = {
|
|
57
|
+
...docs,
|
|
58
|
+
fragments
|
|
59
|
+
};
|
|
60
|
+
Object.defineProperty(result, commandDocMetadata, { value: metadata });
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Collects selected-command metadata in documentation traversal order.
|
|
65
|
+
* @param current Metadata from earlier children.
|
|
66
|
+
* @param docs The next child's documentation.
|
|
67
|
+
* @param includeCustom Whether to retain custom page fields inside merge().
|
|
68
|
+
* @returns The first defined value from children with the same origin.
|
|
69
|
+
*/
|
|
70
|
+
function collectCommandDocMetadata(current, docs, includeCustom = false) {
|
|
71
|
+
const next = getCommandDocMetadata(docs);
|
|
72
|
+
if (next == null) return current;
|
|
73
|
+
const origin = next.origin ?? "entry";
|
|
74
|
+
if (origin === "entry" || origin === "custom" && !includeCustom) return current ?? withOrigin({}, "entry");
|
|
75
|
+
if (current?.origin === "command" && origin !== "command") return current;
|
|
76
|
+
if (current?.origin !== origin) current = void 0;
|
|
77
|
+
const brief = current?.brief ?? next.brief;
|
|
78
|
+
const description = current?.description ?? next.description;
|
|
79
|
+
const footer = current?.footer ?? next.footer;
|
|
80
|
+
return withOrigin({
|
|
81
|
+
...brief == null ? {} : { brief },
|
|
82
|
+
...description == null ? {} : { description },
|
|
83
|
+
...footer == null ? {} : { footer }
|
|
84
|
+
}, origin);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
exports.collectCommandDocMetadata = collectCommandDocMetadata;
|
|
89
|
+
exports.getCommandDocMetadata = getCommandDocMetadata;
|
|
90
|
+
exports.withCommandDocMetadata = withCommandDocMetadata;
|