@optique/core 0.7.15 → 0.7.16
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/package.json +1 -1
package/dist/constructs.cjs
CHANGED
|
@@ -882,6 +882,9 @@ function merge(...args) {
|
|
|
882
882
|
});
|
|
883
883
|
},
|
|
884
884
|
getDocFragments(state, _defaultValue) {
|
|
885
|
+
let brief;
|
|
886
|
+
let description;
|
|
887
|
+
let footer;
|
|
885
888
|
const fragments = parsers.flatMap((p, i) => {
|
|
886
889
|
let parserState;
|
|
887
890
|
if (p.initialState === void 0) {
|
|
@@ -895,7 +898,11 @@ function merge(...args) {
|
|
|
895
898
|
kind: "available",
|
|
896
899
|
state: state.state
|
|
897
900
|
};
|
|
898
|
-
|
|
901
|
+
const docFragments = p.getDocFragments(parserState, void 0);
|
|
902
|
+
brief ??= docFragments.brief;
|
|
903
|
+
description ??= docFragments.description;
|
|
904
|
+
footer ??= docFragments.footer;
|
|
905
|
+
return docFragments.fragments;
|
|
899
906
|
});
|
|
900
907
|
const entries = fragments.filter((f) => f.type === "entry");
|
|
901
908
|
const sections = [];
|
|
@@ -910,18 +917,28 @@ function merge(...args) {
|
|
|
910
917
|
entries
|
|
911
918
|
};
|
|
912
919
|
sections.push(labeledSection);
|
|
913
|
-
return {
|
|
920
|
+
return {
|
|
921
|
+
brief,
|
|
922
|
+
description,
|
|
923
|
+
footer,
|
|
924
|
+
fragments: sections.map((s) => ({
|
|
925
|
+
...s,
|
|
926
|
+
type: "section"
|
|
927
|
+
}))
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
return {
|
|
931
|
+
brief,
|
|
932
|
+
description,
|
|
933
|
+
footer,
|
|
934
|
+
fragments: [...sections.map((s) => ({
|
|
914
935
|
...s,
|
|
915
936
|
type: "section"
|
|
916
|
-
}))
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
})), {
|
|
922
|
-
type: "section",
|
|
923
|
-
entries
|
|
924
|
-
}] };
|
|
937
|
+
})), {
|
|
938
|
+
type: "section",
|
|
939
|
+
entries
|
|
940
|
+
}]
|
|
941
|
+
};
|
|
925
942
|
}
|
|
926
943
|
};
|
|
927
944
|
}
|
|
@@ -1112,10 +1129,17 @@ function group(label, parser) {
|
|
|
1112
1129
|
for (const fragment of fragments) if (fragment.type === "entry") allEntries.push(fragment);
|
|
1113
1130
|
else if (fragment.type === "section") if (fragment.title) titledSections.push(fragment);
|
|
1114
1131
|
else allEntries.push(...fragment.entries);
|
|
1115
|
-
const
|
|
1132
|
+
const initialFragments = parser.getDocFragments({
|
|
1133
|
+
kind: "available",
|
|
1134
|
+
state: parser.initialState
|
|
1135
|
+
}, void 0);
|
|
1136
|
+
const initialHasCommands = initialFragments.fragments.some((f) => f.type === "entry" && f.term.type === "command" || f.type === "section" && f.entries.some((e) => e.term.type === "command"));
|
|
1137
|
+
const currentHasCommands = allEntries.some((e) => e.term.type === "command");
|
|
1138
|
+
const applyLabel = !initialHasCommands || currentHasCommands;
|
|
1139
|
+
const labeledSection = applyLabel ? {
|
|
1116
1140
|
title: label,
|
|
1117
1141
|
entries: allEntries
|
|
1118
|
-
};
|
|
1142
|
+
} : { entries: allEntries };
|
|
1119
1143
|
return {
|
|
1120
1144
|
description,
|
|
1121
1145
|
fragments: [...titledSections.map((s) => ({
|
package/dist/constructs.js
CHANGED
|
@@ -882,6 +882,9 @@ function merge(...args) {
|
|
|
882
882
|
});
|
|
883
883
|
},
|
|
884
884
|
getDocFragments(state, _defaultValue) {
|
|
885
|
+
let brief;
|
|
886
|
+
let description;
|
|
887
|
+
let footer;
|
|
885
888
|
const fragments = parsers.flatMap((p, i) => {
|
|
886
889
|
let parserState;
|
|
887
890
|
if (p.initialState === void 0) {
|
|
@@ -895,7 +898,11 @@ function merge(...args) {
|
|
|
895
898
|
kind: "available",
|
|
896
899
|
state: state.state
|
|
897
900
|
};
|
|
898
|
-
|
|
901
|
+
const docFragments = p.getDocFragments(parserState, void 0);
|
|
902
|
+
brief ??= docFragments.brief;
|
|
903
|
+
description ??= docFragments.description;
|
|
904
|
+
footer ??= docFragments.footer;
|
|
905
|
+
return docFragments.fragments;
|
|
899
906
|
});
|
|
900
907
|
const entries = fragments.filter((f) => f.type === "entry");
|
|
901
908
|
const sections = [];
|
|
@@ -910,18 +917,28 @@ function merge(...args) {
|
|
|
910
917
|
entries
|
|
911
918
|
};
|
|
912
919
|
sections.push(labeledSection);
|
|
913
|
-
return {
|
|
920
|
+
return {
|
|
921
|
+
brief,
|
|
922
|
+
description,
|
|
923
|
+
footer,
|
|
924
|
+
fragments: sections.map((s) => ({
|
|
925
|
+
...s,
|
|
926
|
+
type: "section"
|
|
927
|
+
}))
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
return {
|
|
931
|
+
brief,
|
|
932
|
+
description,
|
|
933
|
+
footer,
|
|
934
|
+
fragments: [...sections.map((s) => ({
|
|
914
935
|
...s,
|
|
915
936
|
type: "section"
|
|
916
|
-
}))
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
})), {
|
|
922
|
-
type: "section",
|
|
923
|
-
entries
|
|
924
|
-
}] };
|
|
937
|
+
})), {
|
|
938
|
+
type: "section",
|
|
939
|
+
entries
|
|
940
|
+
}]
|
|
941
|
+
};
|
|
925
942
|
}
|
|
926
943
|
};
|
|
927
944
|
}
|
|
@@ -1112,10 +1129,17 @@ function group(label, parser) {
|
|
|
1112
1129
|
for (const fragment of fragments) if (fragment.type === "entry") allEntries.push(fragment);
|
|
1113
1130
|
else if (fragment.type === "section") if (fragment.title) titledSections.push(fragment);
|
|
1114
1131
|
else allEntries.push(...fragment.entries);
|
|
1115
|
-
const
|
|
1132
|
+
const initialFragments = parser.getDocFragments({
|
|
1133
|
+
kind: "available",
|
|
1134
|
+
state: parser.initialState
|
|
1135
|
+
}, void 0);
|
|
1136
|
+
const initialHasCommands = initialFragments.fragments.some((f) => f.type === "entry" && f.term.type === "command" || f.type === "section" && f.entries.some((e) => e.term.type === "command"));
|
|
1137
|
+
const currentHasCommands = allEntries.some((e) => e.term.type === "command");
|
|
1138
|
+
const applyLabel = !initialHasCommands || currentHasCommands;
|
|
1139
|
+
const labeledSection = applyLabel ? {
|
|
1116
1140
|
title: label,
|
|
1117
1141
|
entries: allEntries
|
|
1118
|
-
};
|
|
1142
|
+
} : { entries: allEntries };
|
|
1119
1143
|
return {
|
|
1120
1144
|
description,
|
|
1121
1145
|
fragments: [...titledSections.map((s) => ({
|