docmind-cli 0.1.0 → 0.1.1
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/index.js +102 -25
- package/dist/preview-client.js +170 -169
- package/dist/preview.css +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8177,6 +8177,7 @@ function parseBulletList(lines, i) {
|
|
|
8177
8177
|
}
|
|
8178
8178
|
function parseOrderedList(lines, i) {
|
|
8179
8179
|
if (!/^\d+\.\s/.test(lines[i])) return null;
|
|
8180
|
+
const start = Number.parseInt(lines[i], 10) || 1;
|
|
8180
8181
|
const items = [];
|
|
8181
8182
|
let j = i;
|
|
8182
8183
|
while (j < lines.length && /^\d+\.\s/.test(lines[j])) {
|
|
@@ -8189,15 +8190,19 @@ function parseOrderedList(lines, i) {
|
|
|
8189
8190
|
const item = { type: "listItem", content: content.length ? content : [{ type: "paragraph", content: [] }] };
|
|
8190
8191
|
items.push(tagRaw(item, lines, itemStart, j));
|
|
8191
8192
|
}
|
|
8192
|
-
return { node: { type: "orderedList", attrs: { start
|
|
8193
|
+
return { node: { type: "orderedList", attrs: { start }, content: items }, newI: j };
|
|
8194
|
+
}
|
|
8195
|
+
function isQuoteLine(line) {
|
|
8196
|
+
return line.startsWith("> ") || line.trim() === ">";
|
|
8193
8197
|
}
|
|
8194
8198
|
function parseBlockquote(lines, i) {
|
|
8195
|
-
if (!
|
|
8199
|
+
if (!isQuoteLine(lines[i])) return null;
|
|
8196
8200
|
const quoteLines = [];
|
|
8197
8201
|
let j = i;
|
|
8198
|
-
while (j < lines.length && (lines[j]
|
|
8202
|
+
while (j < lines.length && isQuoteLine(lines[j])) quoteLines.push(lines[j++].replace(/^>\s?/, ""));
|
|
8203
|
+
const content = parseBlocks(quoteLines);
|
|
8199
8204
|
return {
|
|
8200
|
-
node: { type: "blockquote", content: [{ type: "paragraph"
|
|
8205
|
+
node: { type: "blockquote", content: content.length ? content : [{ type: "paragraph" }] },
|
|
8201
8206
|
newI: j
|
|
8202
8207
|
};
|
|
8203
8208
|
}
|
|
@@ -8244,6 +8249,9 @@ function collectUntilClose(lines, start, first, close) {
|
|
|
8244
8249
|
}
|
|
8245
8250
|
return null;
|
|
8246
8251
|
}
|
|
8252
|
+
function joinParagraphLines(paraLines) {
|
|
8253
|
+
return paraLines.reduce((acc, line) => / {2,}$/.test(acc) ? `${acc.replace(/ +$/, "")}<br>${line}` : `${acc} ${line}`);
|
|
8254
|
+
}
|
|
8247
8255
|
function parseParagraph(lines, i) {
|
|
8248
8256
|
const paraLines = [];
|
|
8249
8257
|
let j = i;
|
|
@@ -8251,7 +8259,7 @@ function parseParagraph(lines, i) {
|
|
|
8251
8259
|
paraLines.push(lines[j++]);
|
|
8252
8260
|
}
|
|
8253
8261
|
if (paraLines.length > 0) {
|
|
8254
|
-
return { node: { type: "paragraph", content: parseInline(paraLines
|
|
8262
|
+
return { node: { type: "paragraph", content: parseInline(joinParagraphLines(paraLines)) }, newI: j };
|
|
8255
8263
|
}
|
|
8256
8264
|
return { node: null, newI: i + 1 };
|
|
8257
8265
|
}
|
|
@@ -8584,8 +8592,10 @@ function nodeToMarkdown(node, rawIndex) {
|
|
|
8584
8592
|
return paragraphToMarkdown(node);
|
|
8585
8593
|
case "bulletList":
|
|
8586
8594
|
return (node.content ?? []).map((item) => serializeListItem(item, "- ", rawIndex)).join("\n");
|
|
8587
|
-
case "orderedList":
|
|
8588
|
-
|
|
8595
|
+
case "orderedList": {
|
|
8596
|
+
const start = Math.max(1, Number(node.attrs?.start) || 1);
|
|
8597
|
+
return (node.content ?? []).map((item, idx) => serializeListItem(item, `${start + idx}. `, rawIndex)).join("\n");
|
|
8598
|
+
}
|
|
8589
8599
|
case "taskList":
|
|
8590
8600
|
return (node.content ?? []).map(
|
|
8591
8601
|
(item) => serializeListItem(item, `- [${item.attrs?.checked ? "x" : " "}] `, rawIndex, { inlineFirstParagraph: true })
|
|
@@ -8593,7 +8603,9 @@ function nodeToMarkdown(node, rawIndex) {
|
|
|
8593
8603
|
case "blockquote": {
|
|
8594
8604
|
const color = canonicalQuoteColor(String(node.attrs?.color ?? ""));
|
|
8595
8605
|
const aligned = (node.content ?? []).some((n) => blockAlign(n));
|
|
8596
|
-
if (!color && !aligned)
|
|
8606
|
+
if (!color && !aligned) {
|
|
8607
|
+
return childrenToMarkdown(node.content ?? [], rawIndex).split("\n").map((line) => line ? `> ${line}` : ">").join("\n");
|
|
8608
|
+
}
|
|
8597
8609
|
const colorAttr = color ? ` color="${color}"` : "";
|
|
8598
8610
|
return `<Quote${colorAttr}>
|
|
8599
8611
|
${indent(childrenToMarkdown(node.content ?? [], rawIndex))}
|
|
@@ -17636,7 +17648,12 @@ async function buildOfflineState(input) {
|
|
|
17636
17648
|
};
|
|
17637
17649
|
}
|
|
17638
17650
|
const rows = new Rows();
|
|
17639
|
-
|
|
17651
|
+
const specFileForSlug = (slug) => {
|
|
17652
|
+
if (!slug || slug.includes("/")) return null;
|
|
17653
|
+
const hits = [...snapshot.files.keys()].filter((p) => /\.(ya?ml|json)$/i.test(p) && p.slice(p.lastIndexOf("/") + 1).replace(/\.(ya?ml|json)$/i, "") === slug);
|
|
17654
|
+
return hits.length === 1 ? hits[0] : null;
|
|
17655
|
+
};
|
|
17656
|
+
await seedExisting(model.navigation, rows, readText, specFileForSlug);
|
|
17640
17657
|
const existing = rows.size();
|
|
17641
17658
|
const diff = diffNavigation(model, rows.toDbNavState(), inventoryOf(snapshot, prefix), { subdirectory });
|
|
17642
17659
|
let refused = null;
|
|
@@ -17658,17 +17675,17 @@ async function buildOfflineState(input) {
|
|
|
17658
17675
|
counts: { existing, created: rows.size() - existing }
|
|
17659
17676
|
};
|
|
17660
17677
|
}
|
|
17661
|
-
async function seedExisting(nodes, rows, readText, parent = { sectionId: null, groupId: null, apiReference: false }) {
|
|
17678
|
+
async function seedExisting(nodes, rows, readText, specFileForSlug, parent = { sectionId: null, groupId: null, apiReference: false }) {
|
|
17662
17679
|
for (const [order, node] of nodes.entries()) {
|
|
17663
17680
|
switch (node.kind) {
|
|
17664
17681
|
case "tab": {
|
|
17665
17682
|
const id = node.id;
|
|
17666
17683
|
if (id) rows.add({ kind: "section", row: sectionRow(id, node.name, slugFromName(node.name), order, node.roles, node.mode, node.icon) });
|
|
17667
|
-
await seedExisting(node.children, rows, readText, { sectionId: id ?? null, groupId: null, apiReference: false });
|
|
17684
|
+
await seedExisting(node.children, rows, readText, specFileForSlug, { sectionId: id ?? null, groupId: null, apiReference: false });
|
|
17668
17685
|
break;
|
|
17669
17686
|
}
|
|
17670
17687
|
case "apiReference":
|
|
17671
|
-
await seedExisting(node.children, rows, readText, { sectionId: null, groupId: null, apiReference: true });
|
|
17688
|
+
await seedExisting(node.children, rows, readText, specFileForSlug, { sectionId: null, groupId: null, apiReference: true });
|
|
17672
17689
|
break;
|
|
17673
17690
|
case "group": {
|
|
17674
17691
|
const id = node.id;
|
|
@@ -17687,7 +17704,7 @@ async function seedExisting(nodes, rows, readText, parent = { sectionId: null, g
|
|
|
17687
17704
|
)
|
|
17688
17705
|
});
|
|
17689
17706
|
}
|
|
17690
|
-
await seedExisting(node.children, rows, readText, {
|
|
17707
|
+
await seedExisting(node.children, rows, readText, specFileForSlug, {
|
|
17691
17708
|
sectionId: parent.sectionId,
|
|
17692
17709
|
groupId: id ?? null,
|
|
17693
17710
|
apiReference: parent.apiReference
|
|
@@ -17722,20 +17739,15 @@ async function seedExisting(nodes, rows, readText, parent = { sectionId: null, g
|
|
|
17722
17739
|
break;
|
|
17723
17740
|
case "api":
|
|
17724
17741
|
if (node.id) {
|
|
17725
|
-
const
|
|
17742
|
+
const bySlug = await readText(node.ref) === null ? specFileForSlug(node.ref) : null;
|
|
17743
|
+
const path = bySlug ?? node.ref;
|
|
17744
|
+
const text = await readText(path);
|
|
17726
17745
|
const detection = text ? detectOpenApi(text) : null;
|
|
17727
17746
|
const name = node.name?.trim() || detection?.title || "Untitled API";
|
|
17747
|
+
const slug = bySlug ? uniqueSlug(node.ref, rows.specSlugs) : uniqueSlug(slugify(name), rows.specSlugs);
|
|
17728
17748
|
rows.add({
|
|
17729
17749
|
kind: "spec",
|
|
17730
|
-
row: specRow(
|
|
17731
|
-
node.id,
|
|
17732
|
-
name,
|
|
17733
|
-
uniqueSlug(slugify(name), rows.specSlugs),
|
|
17734
|
-
node.ref,
|
|
17735
|
-
order,
|
|
17736
|
-
parent.groupId,
|
|
17737
|
-
detection
|
|
17738
|
-
)
|
|
17750
|
+
row: specRow(node.id, name, slug, path, order, parent.groupId, detection)
|
|
17739
17751
|
});
|
|
17740
17752
|
}
|
|
17741
17753
|
break;
|
|
@@ -19266,6 +19278,60 @@ var init_api_tag_page = __esm({
|
|
|
19266
19278
|
}
|
|
19267
19279
|
});
|
|
19268
19280
|
|
|
19281
|
+
// ../../lib/docs/breadcrumbs.ts
|
|
19282
|
+
function orderedGroupChain(groupId, groups) {
|
|
19283
|
+
const byId = new Map(groups.map((g) => [g.id, g]));
|
|
19284
|
+
const chain = [];
|
|
19285
|
+
const seen = /* @__PURE__ */ new Set();
|
|
19286
|
+
for (let id = groupId; id && !seen.has(id); ) {
|
|
19287
|
+
seen.add(id);
|
|
19288
|
+
const group = byId.get(id);
|
|
19289
|
+
if (!group) break;
|
|
19290
|
+
chain.unshift({ id: group.id, name: group.name });
|
|
19291
|
+
id = group.parentId;
|
|
19292
|
+
}
|
|
19293
|
+
return chain;
|
|
19294
|
+
}
|
|
19295
|
+
function buildDocsBreadcrumbs(input) {
|
|
19296
|
+
const groupChain = orderedGroupChain(input.groupId, input.groups);
|
|
19297
|
+
if (groupChain.length === 0) return null;
|
|
19298
|
+
const trail = [
|
|
19299
|
+
{ id: "home", label: input.homeLabel, type: "home", route: null }
|
|
19300
|
+
];
|
|
19301
|
+
if (input.sectionId) {
|
|
19302
|
+
trail.push({
|
|
19303
|
+
id: input.sectionId,
|
|
19304
|
+
label: input.sectionName,
|
|
19305
|
+
type: "tab",
|
|
19306
|
+
route: input.sectionLandingRoute
|
|
19307
|
+
});
|
|
19308
|
+
}
|
|
19309
|
+
for (const group of groupChain) {
|
|
19310
|
+
trail.push({ id: group.id, label: group.name, type: "group", route: null });
|
|
19311
|
+
}
|
|
19312
|
+
trail.push({
|
|
19313
|
+
id: "current-page",
|
|
19314
|
+
label: input.pageTitle,
|
|
19315
|
+
type: "page",
|
|
19316
|
+
route: input.pageRoute,
|
|
19317
|
+
current: true
|
|
19318
|
+
});
|
|
19319
|
+
return trail;
|
|
19320
|
+
}
|
|
19321
|
+
function buildManifestPageBreadcrumbs(navigation, placement, opts) {
|
|
19322
|
+
return buildDocsBreadcrumbs({
|
|
19323
|
+
...opts,
|
|
19324
|
+
sectionId: placement.sectionId,
|
|
19325
|
+
groupId: placement.groupId,
|
|
19326
|
+
groups: navigation.groups
|
|
19327
|
+
});
|
|
19328
|
+
}
|
|
19329
|
+
var init_breadcrumbs = __esm({
|
|
19330
|
+
"../../lib/docs/breadcrumbs.ts"() {
|
|
19331
|
+
"use strict";
|
|
19332
|
+
}
|
|
19333
|
+
});
|
|
19334
|
+
|
|
19269
19335
|
// ../../lib/format-role.ts
|
|
19270
19336
|
function formatRoleLabel(name) {
|
|
19271
19337
|
if (!name) return "";
|
|
@@ -19375,6 +19441,8 @@ function docView(site, slug, role) {
|
|
|
19375
19441
|
const pubSection = pub.manifest.navigation.sections.find((s) => s.id === entry.sectionId) ?? null;
|
|
19376
19442
|
const pubGroup = entry.groupId ? pub.manifest.navigation.groups.find((g) => g.id === entry.groupId) ?? null : null;
|
|
19377
19443
|
const isChangelog = artifact.contentType === "changelog" || pubSection?.changelog === true;
|
|
19444
|
+
const pageRoute2 = publishedPageRoute(pub, entry) ?? `/${section}/${entry.slug}`;
|
|
19445
|
+
const sectionLanding = tabRoute({ slug: section, landingRoute: navPages[0]?.route });
|
|
19378
19446
|
let release = null;
|
|
19379
19447
|
if (isReleaseNotesSection(pubSection)) {
|
|
19380
19448
|
release = { version: entry.version, releaseDate: entry.releaseDate, isLatest: navPages[0]?.slug === slug };
|
|
@@ -19395,7 +19463,14 @@ function docView(site, slug, role) {
|
|
|
19395
19463
|
},
|
|
19396
19464
|
prevPage: prev,
|
|
19397
19465
|
nextPage: next,
|
|
19398
|
-
tabRoute:
|
|
19466
|
+
tabRoute: sectionLanding,
|
|
19467
|
+
breadcrumbs: buildManifestPageBreadcrumbs(pub.manifest.navigation, entry, {
|
|
19468
|
+
homeLabel: "Docs",
|
|
19469
|
+
pageTitle: artifact.title ?? entry.title,
|
|
19470
|
+
pageRoute: pageRoute2,
|
|
19471
|
+
sectionName: pubSection?.name ?? section,
|
|
19472
|
+
sectionLandingRoute: sectionLanding
|
|
19473
|
+
}),
|
|
19399
19474
|
pageLinks: prunePageLinks(artifact.content, publicationPageLinks(pub), artifact.githubPath),
|
|
19400
19475
|
isChangelog,
|
|
19401
19476
|
release
|
|
@@ -19422,6 +19497,7 @@ function apiDocView(site, slug, apiLandingRoute) {
|
|
|
19422
19497
|
prevPage: null,
|
|
19423
19498
|
nextPage: null,
|
|
19424
19499
|
tabRoute: apiLandingRoute,
|
|
19500
|
+
breadcrumbs: null,
|
|
19425
19501
|
pageLinks: publicationPageLinks(site.pub),
|
|
19426
19502
|
isChangelog: false,
|
|
19427
19503
|
release: null
|
|
@@ -19556,6 +19632,7 @@ var init_view = __esm({
|
|
|
19556
19632
|
init_release_notes();
|
|
19557
19633
|
init_page_links();
|
|
19558
19634
|
init_docs_routes();
|
|
19635
|
+
init_breadcrumbs();
|
|
19559
19636
|
init_public_settings();
|
|
19560
19637
|
init_system_roles();
|
|
19561
19638
|
init_format_role();
|
|
@@ -20732,7 +20809,7 @@ var package_default = {
|
|
|
20732
20809
|
license: "UNLICENSED",
|
|
20733
20810
|
type: "module",
|
|
20734
20811
|
bin: {
|
|
20735
|
-
docmind: "
|
|
20812
|
+
docmind: "dist/index.js"
|
|
20736
20813
|
},
|
|
20737
20814
|
files: [
|
|
20738
20815
|
"dist",
|