@optique/core 1.0.0-dev.1299 → 1.0.0-dev.1303
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 +8 -12
- package/dist/doc.js +8 -12
- package/package.json +1 -1
package/dist/doc.cjs
CHANGED
|
@@ -87,24 +87,20 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
87
87
|
...page,
|
|
88
88
|
sections: filteredSections
|
|
89
89
|
};
|
|
90
|
+
const hasContent = (msg) => Array.isArray(msg) && msg.length > 0;
|
|
90
91
|
if (options.maxWidth != null) {
|
|
91
92
|
const hasEntries = page.sections.some((s) => s.entries.length > 0);
|
|
92
|
-
const
|
|
93
|
-
const needsDescColumn = hasEntries && page.sections.some((s) => s.entries.some((e) => hasContent(e.description) || options.showDefault && e.default != null || options.showChoices && e.choices != null));
|
|
93
|
+
const needsDescColumn = hasEntries && page.sections.some((s) => s.entries.some((e) => hasContent(e.description) || options.showDefault && hasContent(e.default) || options.showChoices && hasContent(e.choices)));
|
|
94
94
|
let minDescWidth = 1;
|
|
95
95
|
if (needsDescColumn) {
|
|
96
|
-
if (options.showDefault && page.sections.some((s) => s.entries.some((e) => e.default
|
|
96
|
+
if (options.showDefault && page.sections.some((s) => s.entries.some((e) => hasContent(e.default)))) {
|
|
97
97
|
const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
|
|
98
|
-
|
|
99
|
-
const hasEmptyDefault = page.sections.some((s) => s.entries.some((e) => e.default != null && Array.isArray(e.default) && e.default.length === 0));
|
|
100
|
-
minDescWidth = Math.max(minDescWidth, hasEmptyDefault ? prefix.length + suffix.length : prefix.length);
|
|
98
|
+
minDescWidth = Math.max(minDescWidth, prefix.length);
|
|
101
99
|
}
|
|
102
|
-
if (options.showChoices && page.sections.some((s) => s.entries.some((e) => e.choices
|
|
100
|
+
if (options.showChoices && page.sections.some((s) => s.entries.some((e) => hasContent(e.choices)))) {
|
|
103
101
|
const prefix = typeof options.showChoices === "object" ? options.showChoices.prefix ?? " (" : " (";
|
|
104
|
-
const suffix = typeof options.showChoices === "object" ? options.showChoices.suffix ?? ")" : ")";
|
|
105
102
|
const label = typeof options.showChoices === "object" ? options.showChoices.label ?? "choices: " : "choices: ";
|
|
106
|
-
|
|
107
|
-
minDescWidth = Math.max(minDescWidth, hasEmptyChoices ? prefix.length + label.length + suffix.length : prefix.length + label.length);
|
|
103
|
+
minDescWidth = Math.max(minDescWidth, prefix.length + label.length);
|
|
108
104
|
}
|
|
109
105
|
}
|
|
110
106
|
const splitEntryMin = termIndent + 2 + Math.max(2, 2 * minDescWidth - 1);
|
|
@@ -196,7 +192,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
196
192
|
startWidth: extraTermOffset > 0 ? extraTermOffset : void 0
|
|
197
193
|
};
|
|
198
194
|
let description = entry.description == null ? "" : require_message.formatMessage(entry.description, descFormatOptions);
|
|
199
|
-
if (options.showDefault && entry.default
|
|
195
|
+
if (options.showDefault && hasContent(entry.default)) {
|
|
200
196
|
const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
|
|
201
197
|
const suffix = typeof options.showDefault === "object" ? options.showDefault.suffix ?? "]" : "]";
|
|
202
198
|
let defaultStartWidth;
|
|
@@ -219,7 +215,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
219
215
|
const formattedDefault = options.colors ? `\x1b[2m${defaultText}\x1b[0m` : defaultText;
|
|
220
216
|
description += formattedDefault;
|
|
221
217
|
}
|
|
222
|
-
if (options.showChoices && entry.choices
|
|
218
|
+
if (options.showChoices && hasContent(entry.choices)) {
|
|
223
219
|
const prefix = typeof options.showChoices === "object" ? options.showChoices.prefix ?? " (" : " (";
|
|
224
220
|
const suffix = typeof options.showChoices === "object" ? options.showChoices.suffix ?? ")" : ")";
|
|
225
221
|
const label = typeof options.showChoices === "object" ? options.showChoices.label ?? "choices: " : "choices: ";
|
package/dist/doc.js
CHANGED
|
@@ -87,24 +87,20 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
87
87
|
...page,
|
|
88
88
|
sections: filteredSections
|
|
89
89
|
};
|
|
90
|
+
const hasContent = (msg) => Array.isArray(msg) && msg.length > 0;
|
|
90
91
|
if (options.maxWidth != null) {
|
|
91
92
|
const hasEntries = page.sections.some((s) => s.entries.length > 0);
|
|
92
|
-
const
|
|
93
|
-
const needsDescColumn = hasEntries && page.sections.some((s) => s.entries.some((e) => hasContent(e.description) || options.showDefault && e.default != null || options.showChoices && e.choices != null));
|
|
93
|
+
const needsDescColumn = hasEntries && page.sections.some((s) => s.entries.some((e) => hasContent(e.description) || options.showDefault && hasContent(e.default) || options.showChoices && hasContent(e.choices)));
|
|
94
94
|
let minDescWidth = 1;
|
|
95
95
|
if (needsDescColumn) {
|
|
96
|
-
if (options.showDefault && page.sections.some((s) => s.entries.some((e) => e.default
|
|
96
|
+
if (options.showDefault && page.sections.some((s) => s.entries.some((e) => hasContent(e.default)))) {
|
|
97
97
|
const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
|
|
98
|
-
|
|
99
|
-
const hasEmptyDefault = page.sections.some((s) => s.entries.some((e) => e.default != null && Array.isArray(e.default) && e.default.length === 0));
|
|
100
|
-
minDescWidth = Math.max(minDescWidth, hasEmptyDefault ? prefix.length + suffix.length : prefix.length);
|
|
98
|
+
minDescWidth = Math.max(minDescWidth, prefix.length);
|
|
101
99
|
}
|
|
102
|
-
if (options.showChoices && page.sections.some((s) => s.entries.some((e) => e.choices
|
|
100
|
+
if (options.showChoices && page.sections.some((s) => s.entries.some((e) => hasContent(e.choices)))) {
|
|
103
101
|
const prefix = typeof options.showChoices === "object" ? options.showChoices.prefix ?? " (" : " (";
|
|
104
|
-
const suffix = typeof options.showChoices === "object" ? options.showChoices.suffix ?? ")" : ")";
|
|
105
102
|
const label = typeof options.showChoices === "object" ? options.showChoices.label ?? "choices: " : "choices: ";
|
|
106
|
-
|
|
107
|
-
minDescWidth = Math.max(minDescWidth, hasEmptyChoices ? prefix.length + label.length + suffix.length : prefix.length + label.length);
|
|
103
|
+
minDescWidth = Math.max(minDescWidth, prefix.length + label.length);
|
|
108
104
|
}
|
|
109
105
|
}
|
|
110
106
|
const splitEntryMin = termIndent + 2 + Math.max(2, 2 * minDescWidth - 1);
|
|
@@ -196,7 +192,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
196
192
|
startWidth: extraTermOffset > 0 ? extraTermOffset : void 0
|
|
197
193
|
};
|
|
198
194
|
let description = entry.description == null ? "" : formatMessage(entry.description, descFormatOptions);
|
|
199
|
-
if (options.showDefault && entry.default
|
|
195
|
+
if (options.showDefault && hasContent(entry.default)) {
|
|
200
196
|
const prefix = typeof options.showDefault === "object" ? options.showDefault.prefix ?? " [" : " [";
|
|
201
197
|
const suffix = typeof options.showDefault === "object" ? options.showDefault.suffix ?? "]" : "]";
|
|
202
198
|
let defaultStartWidth;
|
|
@@ -219,7 +215,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
219
215
|
const formattedDefault = options.colors ? `\x1b[2m${defaultText}\x1b[0m` : defaultText;
|
|
220
216
|
description += formattedDefault;
|
|
221
217
|
}
|
|
222
|
-
if (options.showChoices && entry.choices
|
|
218
|
+
if (options.showChoices && hasContent(entry.choices)) {
|
|
223
219
|
const prefix = typeof options.showChoices === "object" ? options.showChoices.prefix ?? " (" : " (";
|
|
224
220
|
const suffix = typeof options.showChoices === "object" ? options.showChoices.suffix ?? ")" : ")";
|
|
225
221
|
const label = typeof options.showChoices === "object" ? options.showChoices.label ?? "choices: " : "choices: ";
|