@optique/core 1.0.0-dev.487 → 1.0.0-dev.488
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 +5 -5
- package/dist/doc.js +5 -5
- package/dist/parser.cjs +27 -7
- package/dist/parser.js +27 -7
- package/package.json +1 -1
package/dist/doc.cjs
CHANGED
|
@@ -27,9 +27,10 @@ function scoreSection(section) {
|
|
|
27
27
|
/**
|
|
28
28
|
* The default section comparator: command-only sections come first, then
|
|
29
29
|
* mixed sections, then option/argument-only sections. Untitled sections
|
|
30
|
-
* receive a
|
|
31
|
-
*
|
|
32
|
-
* same score preserve their original relative order
|
|
30
|
+
* receive a score bonus of -1 via {@link scoreSection} so that untitled
|
|
31
|
+
* command-only sections naturally sort before titled command-only sections.
|
|
32
|
+
* Sections with the same score preserve their original relative order
|
|
33
|
+
* (stable sort).
|
|
33
34
|
*/
|
|
34
35
|
function defaultSectionOrder(a, b) {
|
|
35
36
|
return scoreSection(a) - scoreSection(b);
|
|
@@ -103,8 +104,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
103
104
|
})).toSorted((a, b) => {
|
|
104
105
|
const cmp = comparator(a.section, b.section);
|
|
105
106
|
if (cmp !== 0) return cmp;
|
|
106
|
-
|
|
107
|
-
return titleCmp !== 0 ? titleCmp : a.index - b.index;
|
|
107
|
+
return a.index - b.index;
|
|
108
108
|
}).map(({ section }) => section);
|
|
109
109
|
for (const section of sections) {
|
|
110
110
|
if (section.entries.length < 1) continue;
|
package/dist/doc.js
CHANGED
|
@@ -27,9 +27,10 @@ function scoreSection(section) {
|
|
|
27
27
|
/**
|
|
28
28
|
* The default section comparator: command-only sections come first, then
|
|
29
29
|
* mixed sections, then option/argument-only sections. Untitled sections
|
|
30
|
-
* receive a
|
|
31
|
-
*
|
|
32
|
-
* same score preserve their original relative order
|
|
30
|
+
* receive a score bonus of -1 via {@link scoreSection} so that untitled
|
|
31
|
+
* command-only sections naturally sort before titled command-only sections.
|
|
32
|
+
* Sections with the same score preserve their original relative order
|
|
33
|
+
* (stable sort).
|
|
33
34
|
*/
|
|
34
35
|
function defaultSectionOrder(a, b) {
|
|
35
36
|
return scoreSection(a) - scoreSection(b);
|
|
@@ -103,8 +104,7 @@ function formatDocPage(programName, page, options = {}) {
|
|
|
103
104
|
})).toSorted((a, b) => {
|
|
104
105
|
const cmp = comparator(a.section, b.section);
|
|
105
106
|
if (cmp !== 0) return cmp;
|
|
106
|
-
|
|
107
|
-
return titleCmp !== 0 ? titleCmp : a.index - b.index;
|
|
107
|
+
return a.index - b.index;
|
|
108
108
|
}).map(({ section }) => section);
|
|
109
109
|
for (const section of sections) {
|
|
110
110
|
if (section.entries.length < 1) continue;
|
package/dist/parser.cjs
CHANGED
|
@@ -387,14 +387,34 @@ function buildDocPage(parser, context, args) {
|
|
|
387
387
|
kind: "available",
|
|
388
388
|
state: context.state
|
|
389
389
|
}, void 0);
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
if (
|
|
395
|
-
|
|
390
|
+
const buildingSections = [];
|
|
391
|
+
let untitledSection = null;
|
|
392
|
+
const titledSectionMap = /* @__PURE__ */ new Map();
|
|
393
|
+
for (const fragment of fragments) if (fragment.type === "entry") {
|
|
394
|
+
if (untitledSection == null) {
|
|
395
|
+
untitledSection = { entries: [] };
|
|
396
|
+
buildingSections.push(untitledSection);
|
|
397
|
+
}
|
|
398
|
+
untitledSection.entries.push(fragment);
|
|
399
|
+
} else if (fragment.type === "section") if (fragment.title == null) {
|
|
400
|
+
if (untitledSection == null) {
|
|
401
|
+
untitledSection = { entries: [] };
|
|
402
|
+
buildingSections.push(untitledSection);
|
|
403
|
+
}
|
|
404
|
+
untitledSection.entries.push(...fragment.entries);
|
|
405
|
+
} else {
|
|
406
|
+
let section = titledSectionMap.get(fragment.title);
|
|
407
|
+
if (section == null) {
|
|
408
|
+
section = {
|
|
409
|
+
title: fragment.title,
|
|
410
|
+
entries: []
|
|
411
|
+
};
|
|
412
|
+
titledSectionMap.set(fragment.title, section);
|
|
413
|
+
buildingSections.push(section);
|
|
414
|
+
}
|
|
415
|
+
section.entries.push(...fragment.entries);
|
|
396
416
|
}
|
|
397
|
-
|
|
417
|
+
const sections = buildingSections;
|
|
398
418
|
const usage = [...require_usage.normalizeUsage(parser.usage)];
|
|
399
419
|
let i = 0;
|
|
400
420
|
for (const arg of args) {
|
package/dist/parser.js
CHANGED
|
@@ -387,14 +387,34 @@ function buildDocPage(parser, context, args) {
|
|
|
387
387
|
kind: "available",
|
|
388
388
|
state: context.state
|
|
389
389
|
}, void 0);
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
if (
|
|
395
|
-
|
|
390
|
+
const buildingSections = [];
|
|
391
|
+
let untitledSection = null;
|
|
392
|
+
const titledSectionMap = /* @__PURE__ */ new Map();
|
|
393
|
+
for (const fragment of fragments) if (fragment.type === "entry") {
|
|
394
|
+
if (untitledSection == null) {
|
|
395
|
+
untitledSection = { entries: [] };
|
|
396
|
+
buildingSections.push(untitledSection);
|
|
397
|
+
}
|
|
398
|
+
untitledSection.entries.push(fragment);
|
|
399
|
+
} else if (fragment.type === "section") if (fragment.title == null) {
|
|
400
|
+
if (untitledSection == null) {
|
|
401
|
+
untitledSection = { entries: [] };
|
|
402
|
+
buildingSections.push(untitledSection);
|
|
403
|
+
}
|
|
404
|
+
untitledSection.entries.push(...fragment.entries);
|
|
405
|
+
} else {
|
|
406
|
+
let section = titledSectionMap.get(fragment.title);
|
|
407
|
+
if (section == null) {
|
|
408
|
+
section = {
|
|
409
|
+
title: fragment.title,
|
|
410
|
+
entries: []
|
|
411
|
+
};
|
|
412
|
+
titledSectionMap.set(fragment.title, section);
|
|
413
|
+
buildingSections.push(section);
|
|
414
|
+
}
|
|
415
|
+
section.entries.push(...fragment.entries);
|
|
396
416
|
}
|
|
397
|
-
|
|
417
|
+
const sections = buildingSections;
|
|
398
418
|
const usage = [...normalizeUsage(parser.usage)];
|
|
399
419
|
let i = 0;
|
|
400
420
|
for (const arg of args) {
|