@optique/core 0.8.12 → 0.8.14
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 +37 -13
- package/dist/constructs.js +37 -13
- package/dist/usage.cjs +4 -2
- package/dist/usage.js +4 -2
- package/package.json +1 -1
package/dist/constructs.cjs
CHANGED
|
@@ -838,6 +838,9 @@ function merge(...args) {
|
|
|
838
838
|
return require_suggestion.deduplicateSuggestions(suggestions);
|
|
839
839
|
},
|
|
840
840
|
getDocFragments(state, _defaultValue) {
|
|
841
|
+
let brief;
|
|
842
|
+
let description;
|
|
843
|
+
let footer;
|
|
841
844
|
const fragments = parsers.flatMap((p, i) => {
|
|
842
845
|
let parserState;
|
|
843
846
|
if (p.initialState === void 0) {
|
|
@@ -851,7 +854,11 @@ function merge(...args) {
|
|
|
851
854
|
kind: "available",
|
|
852
855
|
state: state.state
|
|
853
856
|
};
|
|
854
|
-
|
|
857
|
+
const docFragments = p.getDocFragments(parserState, void 0);
|
|
858
|
+
brief ??= docFragments.brief;
|
|
859
|
+
description ??= docFragments.description;
|
|
860
|
+
footer ??= docFragments.footer;
|
|
861
|
+
return docFragments.fragments;
|
|
855
862
|
});
|
|
856
863
|
const entries = fragments.filter((f) => f.type === "entry");
|
|
857
864
|
const sections = [];
|
|
@@ -866,18 +873,28 @@ function merge(...args) {
|
|
|
866
873
|
entries
|
|
867
874
|
};
|
|
868
875
|
sections.push(labeledSection);
|
|
869
|
-
return {
|
|
876
|
+
return {
|
|
877
|
+
brief,
|
|
878
|
+
description,
|
|
879
|
+
footer,
|
|
880
|
+
fragments: sections.map((s) => ({
|
|
881
|
+
...s,
|
|
882
|
+
type: "section"
|
|
883
|
+
}))
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
return {
|
|
887
|
+
brief,
|
|
888
|
+
description,
|
|
889
|
+
footer,
|
|
890
|
+
fragments: [...sections.map((s) => ({
|
|
870
891
|
...s,
|
|
871
892
|
type: "section"
|
|
872
|
-
}))
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
})), {
|
|
878
|
-
type: "section",
|
|
879
|
-
entries
|
|
880
|
-
}] };
|
|
893
|
+
})), {
|
|
894
|
+
type: "section",
|
|
895
|
+
entries
|
|
896
|
+
}]
|
|
897
|
+
};
|
|
881
898
|
}
|
|
882
899
|
};
|
|
883
900
|
}
|
|
@@ -1062,10 +1079,17 @@ function group(label, parser) {
|
|
|
1062
1079
|
for (const fragment of fragments) if (fragment.type === "entry") allEntries.push(fragment);
|
|
1063
1080
|
else if (fragment.type === "section") if (fragment.title) titledSections.push(fragment);
|
|
1064
1081
|
else allEntries.push(...fragment.entries);
|
|
1065
|
-
const
|
|
1082
|
+
const initialFragments = parser.getDocFragments({
|
|
1083
|
+
kind: "available",
|
|
1084
|
+
state: parser.initialState
|
|
1085
|
+
}, void 0);
|
|
1086
|
+
const initialHasCommands = initialFragments.fragments.some((f) => f.type === "entry" && f.term.type === "command" || f.type === "section" && f.entries.some((e) => e.term.type === "command"));
|
|
1087
|
+
const currentHasCommands = allEntries.some((e) => e.term.type === "command");
|
|
1088
|
+
const applyLabel = !initialHasCommands || currentHasCommands;
|
|
1089
|
+
const labeledSection = applyLabel ? {
|
|
1066
1090
|
title: label,
|
|
1067
1091
|
entries: allEntries
|
|
1068
|
-
};
|
|
1092
|
+
} : { entries: allEntries };
|
|
1069
1093
|
return {
|
|
1070
1094
|
description,
|
|
1071
1095
|
fragments: [...titledSections.map((s) => ({
|
package/dist/constructs.js
CHANGED
|
@@ -838,6 +838,9 @@ function merge(...args) {
|
|
|
838
838
|
return deduplicateSuggestions(suggestions);
|
|
839
839
|
},
|
|
840
840
|
getDocFragments(state, _defaultValue) {
|
|
841
|
+
let brief;
|
|
842
|
+
let description;
|
|
843
|
+
let footer;
|
|
841
844
|
const fragments = parsers.flatMap((p, i) => {
|
|
842
845
|
let parserState;
|
|
843
846
|
if (p.initialState === void 0) {
|
|
@@ -851,7 +854,11 @@ function merge(...args) {
|
|
|
851
854
|
kind: "available",
|
|
852
855
|
state: state.state
|
|
853
856
|
};
|
|
854
|
-
|
|
857
|
+
const docFragments = p.getDocFragments(parserState, void 0);
|
|
858
|
+
brief ??= docFragments.brief;
|
|
859
|
+
description ??= docFragments.description;
|
|
860
|
+
footer ??= docFragments.footer;
|
|
861
|
+
return docFragments.fragments;
|
|
855
862
|
});
|
|
856
863
|
const entries = fragments.filter((f) => f.type === "entry");
|
|
857
864
|
const sections = [];
|
|
@@ -866,18 +873,28 @@ function merge(...args) {
|
|
|
866
873
|
entries
|
|
867
874
|
};
|
|
868
875
|
sections.push(labeledSection);
|
|
869
|
-
return {
|
|
876
|
+
return {
|
|
877
|
+
brief,
|
|
878
|
+
description,
|
|
879
|
+
footer,
|
|
880
|
+
fragments: sections.map((s) => ({
|
|
881
|
+
...s,
|
|
882
|
+
type: "section"
|
|
883
|
+
}))
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
return {
|
|
887
|
+
brief,
|
|
888
|
+
description,
|
|
889
|
+
footer,
|
|
890
|
+
fragments: [...sections.map((s) => ({
|
|
870
891
|
...s,
|
|
871
892
|
type: "section"
|
|
872
|
-
}))
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
})), {
|
|
878
|
-
type: "section",
|
|
879
|
-
entries
|
|
880
|
-
}] };
|
|
893
|
+
})), {
|
|
894
|
+
type: "section",
|
|
895
|
+
entries
|
|
896
|
+
}]
|
|
897
|
+
};
|
|
881
898
|
}
|
|
882
899
|
};
|
|
883
900
|
}
|
|
@@ -1062,10 +1079,17 @@ function group(label, parser) {
|
|
|
1062
1079
|
for (const fragment of fragments) if (fragment.type === "entry") allEntries.push(fragment);
|
|
1063
1080
|
else if (fragment.type === "section") if (fragment.title) titledSections.push(fragment);
|
|
1064
1081
|
else allEntries.push(...fragment.entries);
|
|
1065
|
-
const
|
|
1082
|
+
const initialFragments = parser.getDocFragments({
|
|
1083
|
+
kind: "available",
|
|
1084
|
+
state: parser.initialState
|
|
1085
|
+
}, void 0);
|
|
1086
|
+
const initialHasCommands = initialFragments.fragments.some((f) => f.type === "entry" && f.term.type === "command" || f.type === "section" && f.entries.some((e) => e.term.type === "command"));
|
|
1087
|
+
const currentHasCommands = allEntries.some((e) => e.term.type === "command");
|
|
1088
|
+
const applyLabel = !initialHasCommands || currentHasCommands;
|
|
1089
|
+
const labeledSection = applyLabel ? {
|
|
1066
1090
|
title: label,
|
|
1067
1091
|
entries: allEntries
|
|
1068
|
-
};
|
|
1092
|
+
} : { entries: allEntries };
|
|
1069
1093
|
return {
|
|
1070
1094
|
description,
|
|
1071
1095
|
fragments: [...titledSections.map((s) => ({
|
package/dist/usage.cjs
CHANGED
|
@@ -186,8 +186,10 @@ function normalizeUsageTerm(term) {
|
|
|
186
186
|
const terms = [];
|
|
187
187
|
for (const usage of term.terms) {
|
|
188
188
|
const normalized = normalizeUsage(usage);
|
|
189
|
-
if (normalized.length
|
|
190
|
-
|
|
189
|
+
if (normalized.length >= 1 && normalized[0].type === "exclusive") {
|
|
190
|
+
const rest = normalized.slice(1);
|
|
191
|
+
for (const subUsage of normalized[0].terms) terms.push([...subUsage, ...rest]);
|
|
192
|
+
} else terms.push(normalized);
|
|
191
193
|
}
|
|
192
194
|
return {
|
|
193
195
|
type: "exclusive",
|
package/dist/usage.js
CHANGED
|
@@ -185,8 +185,10 @@ function normalizeUsageTerm(term) {
|
|
|
185
185
|
const terms = [];
|
|
186
186
|
for (const usage of term.terms) {
|
|
187
187
|
const normalized = normalizeUsage(usage);
|
|
188
|
-
if (normalized.length
|
|
189
|
-
|
|
188
|
+
if (normalized.length >= 1 && normalized[0].type === "exclusive") {
|
|
189
|
+
const rest = normalized.slice(1);
|
|
190
|
+
for (const subUsage of normalized[0].terms) terms.push([...subUsage, ...rest]);
|
|
191
|
+
} else terms.push(normalized);
|
|
190
192
|
}
|
|
191
193
|
return {
|
|
192
194
|
type: "exclusive",
|