@dogsbay/format-mkdocs 0.2.0-beta.18 → 0.2.0-beta.181

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.
Files changed (149) hide show
  1. package/dist/cli.d.ts +0 -1
  2. package/dist/cli.js +118 -5
  3. package/dist/export/capabilities.d.ts +22 -0
  4. package/dist/export/capabilities.js +213 -0
  5. package/dist/export/to-astro.d.ts +0 -1
  6. package/dist/export/to-astro.js +12 -4
  7. package/dist/export/to-mkdocs-project.d.ts +12 -1
  8. package/dist/export/to-mkdocs-project.js +289 -64
  9. package/dist/export/to-mkdocs.d.ts +53 -4
  10. package/dist/export/to-mkdocs.js +905 -104
  11. package/dist/importer.d.ts +2 -1
  12. package/dist/importer.js +16 -2
  13. package/dist/index.d.ts +22 -4
  14. package/dist/index.js +41 -4
  15. package/dist/inline-walker.d.ts +0 -1
  16. package/dist/inline-walker.js +0 -1
  17. package/dist/loader.d.ts +1 -2
  18. package/dist/loader.js +28 -9
  19. package/dist/nav-coverage.d.ts +17 -0
  20. package/dist/nav-coverage.js +76 -0
  21. package/dist/parse.d.ts +0 -1
  22. package/dist/parse.js +0 -1
  23. package/dist/renderers/mermaid.d.ts +0 -1
  24. package/dist/renderers/mermaid.js +0 -1
  25. package/dist/rules/admonition.d.ts +0 -1
  26. package/dist/rules/admonition.js +0 -1
  27. package/dist/rules/annotations.d.ts +0 -1
  28. package/dist/rules/annotations.js +0 -1
  29. package/dist/rules/autodoc.d.ts +1 -2
  30. package/dist/rules/autodoc.js +1 -3
  31. package/dist/rules/blocks.d.ts +0 -1
  32. package/dist/rules/blocks.js +0 -1
  33. package/dist/rules/content-tabs.d.ts +0 -1
  34. package/dist/rules/content-tabs.js +0 -1
  35. package/dist/rules/docusaurus-admonitions.d.ts +0 -1
  36. package/dist/rules/docusaurus-admonitions.js +0 -1
  37. package/dist/rules/file-include.d.ts +0 -1
  38. package/dist/rules/file-include.js +0 -1
  39. package/dist/rules/footnotes.d.ts +0 -1
  40. package/dist/rules/footnotes.js +0 -1
  41. package/dist/rules/icon-shortcode.d.ts +0 -1
  42. package/dist/rules/icon-shortcode.js +0 -1
  43. package/dist/rules/keys.d.ts +0 -1
  44. package/dist/rules/keys.js +0 -1
  45. package/dist/rules/link-rewrite.d.ts +0 -1
  46. package/dist/rules/link-rewrite.js +0 -1
  47. package/dist/rules/math.d.ts +0 -1
  48. package/dist/rules/math.js +0 -1
  49. package/dist/rules/md-in-html.d.ts +0 -1
  50. package/dist/rules/md-in-html.js +0 -1
  51. package/dist/rules/snippets.d.ts +0 -1
  52. package/dist/rules/snippets.js +0 -1
  53. package/dist/rules/templates.d.ts +0 -1
  54. package/dist/rules/templates.js +0 -1
  55. package/dist/rules/variants.d.ts +0 -1
  56. package/dist/rules/variants.js +0 -1
  57. package/dist/tree.d.ts +0 -1
  58. package/dist/tree.js +0 -1
  59. package/dist/utils/indent.d.ts +0 -1
  60. package/dist/utils/indent.js +0 -1
  61. package/dist/utils/types.d.ts +0 -1
  62. package/dist/utils/types.js +0 -1
  63. package/dist/walker.d.ts +0 -1
  64. package/dist/walker.js +26 -1
  65. package/package.json +13 -12
  66. package/dist/autodoc/markdown-generator.d.ts +0 -6
  67. package/dist/autodoc/markdown-generator.d.ts.map +0 -1
  68. package/dist/autodoc/markdown-generator.js +0 -242
  69. package/dist/autodoc/markdown-generator.js.map +0 -1
  70. package/dist/autodoc/module-resolver.d.ts +0 -8
  71. package/dist/autodoc/module-resolver.d.ts.map +0 -1
  72. package/dist/autodoc/module-resolver.js +0 -218
  73. package/dist/autodoc/module-resolver.js.map +0 -1
  74. package/dist/autodoc/python-docstring.d.ts +0 -7
  75. package/dist/autodoc/python-docstring.d.ts.map +0 -1
  76. package/dist/autodoc/python-docstring.js +0 -324
  77. package/dist/autodoc/python-docstring.js.map +0 -1
  78. package/dist/autodoc/python-parser.d.ts +0 -10
  79. package/dist/autodoc/python-parser.d.ts.map +0 -1
  80. package/dist/autodoc/python-parser.js +0 -541
  81. package/dist/autodoc/python-parser.js.map +0 -1
  82. package/dist/autodoc/tree-builder.d.ts +0 -9
  83. package/dist/autodoc/tree-builder.d.ts.map +0 -1
  84. package/dist/autodoc/tree-builder.js +0 -279
  85. package/dist/autodoc/tree-builder.js.map +0 -1
  86. package/dist/autodoc/types.d.ts +0 -128
  87. package/dist/autodoc/types.d.ts.map +0 -1
  88. package/dist/autodoc/types.js +0 -2
  89. package/dist/autodoc/types.js.map +0 -1
  90. package/dist/cli.d.ts.map +0 -1
  91. package/dist/cli.js.map +0 -1
  92. package/dist/export/to-astro.d.ts.map +0 -1
  93. package/dist/export/to-astro.js.map +0 -1
  94. package/dist/export/to-mkdocs-project.d.ts.map +0 -1
  95. package/dist/export/to-mkdocs-project.js.map +0 -1
  96. package/dist/export/to-mkdocs.d.ts.map +0 -1
  97. package/dist/export/to-mkdocs.js.map +0 -1
  98. package/dist/importer.d.ts.map +0 -1
  99. package/dist/importer.js.map +0 -1
  100. package/dist/index.d.ts.map +0 -1
  101. package/dist/index.js.map +0 -1
  102. package/dist/inline-walker.d.ts.map +0 -1
  103. package/dist/inline-walker.js.map +0 -1
  104. package/dist/loader.d.ts.map +0 -1
  105. package/dist/loader.js.map +0 -1
  106. package/dist/parse.d.ts.map +0 -1
  107. package/dist/parse.js.map +0 -1
  108. package/dist/renderers/mermaid.d.ts.map +0 -1
  109. package/dist/renderers/mermaid.js.map +0 -1
  110. package/dist/rules/admonition.d.ts.map +0 -1
  111. package/dist/rules/admonition.js.map +0 -1
  112. package/dist/rules/annotations.d.ts.map +0 -1
  113. package/dist/rules/annotations.js.map +0 -1
  114. package/dist/rules/autodoc.d.ts.map +0 -1
  115. package/dist/rules/autodoc.js.map +0 -1
  116. package/dist/rules/blocks.d.ts.map +0 -1
  117. package/dist/rules/blocks.js.map +0 -1
  118. package/dist/rules/content-tabs.d.ts.map +0 -1
  119. package/dist/rules/content-tabs.js.map +0 -1
  120. package/dist/rules/docusaurus-admonitions.d.ts.map +0 -1
  121. package/dist/rules/docusaurus-admonitions.js.map +0 -1
  122. package/dist/rules/file-include.d.ts.map +0 -1
  123. package/dist/rules/file-include.js.map +0 -1
  124. package/dist/rules/footnotes.d.ts.map +0 -1
  125. package/dist/rules/footnotes.js.map +0 -1
  126. package/dist/rules/icon-shortcode.d.ts.map +0 -1
  127. package/dist/rules/icon-shortcode.js.map +0 -1
  128. package/dist/rules/keys.d.ts.map +0 -1
  129. package/dist/rules/keys.js.map +0 -1
  130. package/dist/rules/link-rewrite.d.ts.map +0 -1
  131. package/dist/rules/link-rewrite.js.map +0 -1
  132. package/dist/rules/math.d.ts.map +0 -1
  133. package/dist/rules/math.js.map +0 -1
  134. package/dist/rules/md-in-html.d.ts.map +0 -1
  135. package/dist/rules/md-in-html.js.map +0 -1
  136. package/dist/rules/snippets.d.ts.map +0 -1
  137. package/dist/rules/snippets.js.map +0 -1
  138. package/dist/rules/templates.d.ts.map +0 -1
  139. package/dist/rules/templates.js.map +0 -1
  140. package/dist/rules/variants.d.ts.map +0 -1
  141. package/dist/rules/variants.js.map +0 -1
  142. package/dist/tree.d.ts.map +0 -1
  143. package/dist/tree.js.map +0 -1
  144. package/dist/utils/indent.d.ts.map +0 -1
  145. package/dist/utils/indent.js.map +0 -1
  146. package/dist/utils/types.d.ts.map +0 -1
  147. package/dist/utils/types.js.map +0 -1
  148. package/dist/walker.d.ts.map +0 -1
  149. package/dist/walker.js.map +0 -1
@@ -27,4 +27,5 @@ export declare function readMkdocsConfig(sourceDir: string): MkdocsConfig;
27
27
  * Import a MkDocs project: parse all pages and extract navigation.
28
28
  */
29
29
  export declare function importMkdocsProject(sourceDir: string, opts?: Record<string, unknown>): Promise<MkdocsImportResult>;
30
- //# sourceMappingURL=importer.d.ts.map
30
+ /** Mark the pages `pagesOutsideNav` names `unlisted: true`; returns how many. */
31
+ export declare function unlistOutsideNav(pages: ExportPage[], raw: Record<string, unknown>): number;
package/dist/importer.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * Reads a MkDocs project directory (containing mkdocs.yml) and produces
5
5
  * ExportPage[] + NavItem[] — the universal format contract.
6
6
  */
7
+ import { pagesOutsideNav } from "./nav-coverage.js";
7
8
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
8
9
  import { join, relative, basename, dirname, resolve } from "node:path";
9
10
  import MarkdownIt from "markdown-it";
@@ -75,7 +76,9 @@ export async function importMkdocsProject(sourceDir, opts = {}) {
75
76
  const parseOpts = {
76
77
  collapse: false,
77
78
  youtubeEmbed: true,
78
- diagrams: true,
79
+ // `content.diagrams` (false, true, "mermaid-cli" or "pele"); it was always true here, so
80
+ // `content.diagrams: false` did not reach MkDocs sources
81
+ diagrams: opts.diagrams ?? true,
79
82
  };
80
83
  // Detect mkdocstrings autodoc config
81
84
  const mkdocstringsConfig = extractMkdocstringsConfig(config.raw, sourceDir);
@@ -164,8 +167,20 @@ export async function importMkdocsProject(sourceDir, opts = {}) {
164
167
  // where pages will actually be emitted.
165
168
  const hrefPrefix = typeof opts.hrefPrefix === "string" ? opts.hrefPrefix : "/docs";
166
169
  const nav = convertNav(config.raw.nav, hrefPrefix);
170
+ unlistOutsideNav(pages, config.raw);
167
171
  return { pages, nav, config };
168
172
  }
173
+ /** Mark the pages `pagesOutsideNav` names `unlisted: true`; returns how many. */
174
+ export function unlistOutsideNav(pages, raw) {
175
+ const out = new Set(pagesOutsideNav(pages.map((p) => p.slug), raw));
176
+ for (const page of pages)
177
+ if (out.has(page.slug))
178
+ page.frontmatter = { ...(page.frontmatter ?? {}), unlisted: true };
179
+ if (out.size > 0) {
180
+ console.log(` ${out.size} page(s) not in mkdocs.yml's nav are unlisted: built, out of the menu, and (unlike MkDocs) out of search, the sitemap and llms.txt (docs/unlisted-pages.md)`);
181
+ }
182
+ return out.size;
183
+ }
169
184
  // ── Helpers ─────────────────────────────────────────────
170
185
  /** Match a YAML frontmatter block at the start of an MD source. */
171
186
  const FRONTMATTER_RE = /^---\n([\s\S]*?)\n---\n?/;
@@ -373,4 +388,3 @@ function extractMacrosData(config, sourceDir) {
373
388
  }
374
389
  return Object.keys(result).length > 0 ? result : null;
375
390
  }
376
- //# sourceMappingURL=importer.js.map
package/dist/index.d.ts CHANGED
@@ -7,6 +7,8 @@ export { parseToTree } from "./parse.js";
7
7
  export { parseShortcode } from "./rules/icon-shortcode.js";
8
8
  export { treeToMkdocs } from "./export/to-mkdocs.js";
9
9
  export { exportMkdocsProject } from "./export/to-mkdocs-project.js";
10
+ export { MKDOCS_CAPABILITIES } from "./export/capabilities.js";
11
+ export { pagesOutsideNav } from "./nav-coverage.js";
10
12
  export type { MkdocsProjectOptions, MkdocsProjectExport } from "./export/to-mkdocs-project.js";
11
13
  export interface MkdocsPluginOptions {
12
14
  admonitions?: boolean;
@@ -50,8 +52,24 @@ export interface MkdocsPluginOptions {
50
52
  */
51
53
  export declare function mkdocsPlugin(md: MarkdownIt, options?: MkdocsPluginOptions): void;
52
54
  /**
53
- * Build plugin options from a mkdocs.yml `markdown_extensions` array.
54
- * Each entry can be a string or an object with a single key.
55
+ * Build plugin options from a mkdocs.yml `markdown_extensions`
56
+ * declaration. MkDocs accepts two shapes — list (canonical) and
57
+ * mapping (FastAPI-style):
58
+ *
59
+ * markdown_extensions:
60
+ * - admonition
61
+ * - pymdownx.tabbed:
62
+ * alternate_style: true
63
+ *
64
+ * markdown_extensions:
65
+ * admonition: null
66
+ * pymdownx.tabbed:
67
+ * alternate_style: true
68
+ *
69
+ * We accept either, plus `null` / `undefined` (no extensions
70
+ * declared). Without the mapping-form handling, FastAPI-style
71
+ * mkdocs.yml silently skips PyMdownX Blocks (`/// note`, etc.) and
72
+ * downstream parses fall through to raw paragraphs — surfaced by
73
+ * the migrate-mkdocs FastAPI smoke.
55
74
  */
56
- export declare function configureFromMkdocs(extensions: (string | Record<string, unknown>)[]): MkdocsPluginOptions;
57
- //# sourceMappingURL=index.d.ts.map
75
+ export declare function configureFromMkdocs(extensions: unknown): MkdocsPluginOptions;
package/dist/index.js CHANGED
@@ -7,6 +7,8 @@ export { parseShortcode } from "./rules/icon-shortcode.js";
7
7
  // MkDocs serializer (TreeNode[] → MkDocs markdown)
8
8
  export { treeToMkdocs } from "./export/to-mkdocs.js";
9
9
  export { exportMkdocsProject } from "./export/to-mkdocs-project.js";
10
+ export { MKDOCS_CAPABILITIES } from "./export/capabilities.js";
11
+ export { pagesOutsideNav } from "./nav-coverage.js";
10
12
  import { admonitionPlugin } from "./rules/admonition.js";
11
13
  import { blocksPlugin } from "./rules/blocks.js";
12
14
  import { contentTabsPlugin } from "./rules/content-tabs.js";
@@ -150,8 +152,25 @@ const EXTENSION_MAP = {
150
152
  },
151
153
  };
152
154
  /**
153
- * Build plugin options from a mkdocs.yml `markdown_extensions` array.
154
- * Each entry can be a string or an object with a single key.
155
+ * Build plugin options from a mkdocs.yml `markdown_extensions`
156
+ * declaration. MkDocs accepts two shapes — list (canonical) and
157
+ * mapping (FastAPI-style):
158
+ *
159
+ * markdown_extensions:
160
+ * - admonition
161
+ * - pymdownx.tabbed:
162
+ * alternate_style: true
163
+ *
164
+ * markdown_extensions:
165
+ * admonition: null
166
+ * pymdownx.tabbed:
167
+ * alternate_style: true
168
+ *
169
+ * We accept either, plus `null` / `undefined` (no extensions
170
+ * declared). Without the mapping-form handling, FastAPI-style
171
+ * mkdocs.yml silently skips PyMdownX Blocks (`/// note`, etc.) and
172
+ * downstream parses fall through to raw paragraphs — surfaced by
173
+ * the migrate-mkdocs FastAPI smoke.
155
174
  */
156
175
  export function configureFromMkdocs(extensions) {
157
176
  const opts = {
@@ -161,10 +180,28 @@ export function configureFromMkdocs(extensions) {
161
180
  snippets: false,
162
181
  annotations: false,
163
182
  };
164
- for (const ext of extensions) {
183
+ const entries = normalizeExtensions(extensions);
184
+ for (const ext of entries) {
165
185
  const name = typeof ext === "string" ? ext : Object.keys(ext)[0];
166
186
  EXTENSION_MAP[name]?.(opts);
167
187
  }
168
188
  return opts;
169
189
  }
170
- //# sourceMappingURL=index.js.map
190
+ /**
191
+ * Normalize the two forms of mkdocs.yml `markdown_extensions` into
192
+ * the canonical list shape EXTENSION_MAP expects.
193
+ */
194
+ function normalizeExtensions(raw) {
195
+ if (raw == null)
196
+ return [];
197
+ if (Array.isArray(raw)) {
198
+ return raw;
199
+ }
200
+ if (typeof raw === "object") {
201
+ // Mapping form → list of single-key objects (or bare strings
202
+ // when the value is null, matching the canonical bare-string
203
+ // entry).
204
+ return Object.entries(raw).map(([name, value]) => (value == null ? name : { [name]: value }));
205
+ }
206
+ return [];
207
+ }
@@ -14,4 +14,3 @@ import type { InlineNode } from "@dogsbay/types";
14
14
  * Convert markdown-it inline token children into structured InlineNode[].
15
15
  */
16
16
  export declare function walkInlineTokens(tokens: Token[] | null): InlineNode[];
17
- //# sourceMappingURL=inline-walker.d.ts.map
@@ -164,4 +164,3 @@ export function walkInlineTokens(tokens) {
164
164
  }
165
165
  return result;
166
166
  }
167
- //# sourceMappingURL=inline-walker.js.map
package/dist/loader.d.ts CHANGED
@@ -33,10 +33,9 @@ export declare function parseMkdocsMarkdown(source: string, md: MarkdownIt, opti
33
33
  collapse?: boolean;
34
34
  env?: Record<string, unknown>;
35
35
  youtubeEmbed?: boolean;
36
- diagrams?: boolean;
36
+ diagrams?: boolean | "mermaid-cli" | "pele";
37
37
  autodoc?: {
38
38
  sourceRoot: string;
39
39
  globalOptions?: Record<string, unknown>;
40
40
  };
41
41
  }): Promise<MkdocsParseResult>;
42
- //# sourceMappingURL=loader.d.ts.map
package/dist/loader.js CHANGED
@@ -37,9 +37,10 @@ export async function parseMkdocsMarkdown(source, md, options) {
37
37
  if (options?.youtubeEmbed) {
38
38
  liftYouTubeEmbeds(tree);
39
39
  }
40
- // Render diagram code blocks (mermaid etc.) to SVG (opt-in)
40
+ // Render diagram code blocks (mermaid etc.) to SVG (opt-in): mmdc, or Pele
41
+ // (`content.diagrams: pele`, plans/pele-diagrams.md)
41
42
  if (options?.diagrams) {
42
- await renderDiagrams(tree);
43
+ await renderDiagrams(tree, options.diagrams === "pele" ? "pele" : "mermaid-cli");
43
44
  }
44
45
  // Convert api-params HTML comments into structured TreeNodes
45
46
  convertApiParams(tree, md);
@@ -93,8 +94,7 @@ function convertApiParams(nodes, md) {
93
94
  */
94
95
  const DIRECTIVE_RE = /^:::\s+(\S+)\s*$/;
95
96
  async function processAutodocDirectives(nodes, options, md) {
96
- const { resolveIdentifier } = await import("./autodoc/module-resolver.js");
97
- const { symbolToTreeNode } = await import("./autodoc/tree-builder.js");
97
+ const { resolveIdentifier, symbolToTreeNode } = await import("@dogsbay/autodoc-python");
98
98
  const YAML = (await import("yaml")).default;
99
99
  // Defaults match mkdocstrings Python handler defaults.
100
100
  // Projects override these via mkdocs.yml handler options (passed as globalOptions).
@@ -183,14 +183,31 @@ const DIAGRAM_LANGS = new Set(["mermaid"]);
183
183
  * into { type: "diagram", props: { lang: "mermaid", code: "...", svg: "..." } }.
184
184
  * Source code is preserved for round-trip export and search.
185
185
  */
186
- async function renderDiagrams(nodes) {
186
+ async function renderDiagrams(nodes, engine) {
187
187
  let renderMermaidSvg;
188
+ const failed = [];
188
189
  try {
189
- const mod = await import("./renderers/mermaid.js");
190
- renderMermaidSvg = mod.renderMermaidSvg;
190
+ if (engine === "pele") {
191
+ // format-dogsbay-md's Pele renderer: one per page, so a repeated diagram gets its own ids
192
+ const { renderPeleSvg, diagramId } = await import("@dogsbay/format-dogsbay-md");
193
+ const seen = new Map();
194
+ renderMermaidSvg = async (code) => {
195
+ const base = diagramId(code);
196
+ const n = (seen.get(base) ?? 0) + 1;
197
+ seen.set(base, n);
198
+ const r = await renderPeleSvg(code, n === 1 ? base : `${base}-${n}`);
199
+ if ("error" in r)
200
+ failed.push(r.error);
201
+ return "svg" in r ? r.svg : null;
202
+ };
203
+ }
204
+ else {
205
+ const mod = await import("./renderers/mermaid.js");
206
+ renderMermaidSvg = mod.renderMermaidSvg;
207
+ }
191
208
  }
192
209
  catch (e) {
193
- console.warn("[diagrams] could not load mermaid renderer:", e);
210
+ console.warn("[diagrams] could not load the diagram renderer:", e);
194
211
  return;
195
212
  }
196
213
  async function walk(nodes) {
@@ -218,6 +235,9 @@ async function renderDiagrams(nodes) {
218
235
  }
219
236
  }
220
237
  await walk(nodes);
238
+ if (failed.length > 0) {
239
+ console.warn(`[diagrams] Pele could not draw ${failed.length} diagram(s), left as code blocks: ${failed[0].split("\n")[0].slice(0, 160)}`);
240
+ }
221
241
  }
222
242
  /**
223
243
  * Extract heading info for table of contents.
@@ -762,4 +782,3 @@ function slugify(text) {
762
782
  .trim()
763
783
  || "tab"; // fallback for titles that are entirely punctuation
764
784
  }
765
- //# sourceMappingURL=loader.js.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Which pages an MkDocs `nav:` leaves out (no Node: the importer and `migrate-mkdocs` share it).
3
+ */
4
+ /**
5
+ * The pages (by slug) an explicit `nav:` does not list. MkDocs builds them out of its menu
6
+ * (`not_in_nav` only quiets the notice), so they are UNLISTED here (plans/unlisted-pages.md):
7
+ * built, reachable by link, out of the menu — and also out of search, the sitemap and llms.txt,
8
+ * and noindex, which MkDocs does not do. None when MkDocs lists every page or the nav is not all
9
+ * written in mkdocs.yml:
10
+ * - no `nav:` (MkDocs lists every page);
11
+ * - a plugin that builds or extends the nav (literate-nav, awesome-pages/awesome-nav, i18n,
12
+ * monorepo/multirepo), or a nav entry naming a folder (`reference/`), a glob or `...`;
13
+ * The home page (`index`) is never one: MkDocs serves it at the root whatever the nav says. A
14
+ * Material blog's posts (`blog_dir`, default `blog`) are listed by the blog's own index. An entry
15
+ * to part of a page (`a.md#part`) lists the page.
16
+ */
17
+ export declare function pagesOutsideNav(slugs: readonly string[], raw: Record<string, unknown>): string[];
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Which pages an MkDocs `nav:` leaves out (no Node: the importer and `migrate-mkdocs` share it).
3
+ */
4
+ /**
5
+ * The pages (by slug) an explicit `nav:` does not list. MkDocs builds them out of its menu
6
+ * (`not_in_nav` only quiets the notice), so they are UNLISTED here (plans/unlisted-pages.md):
7
+ * built, reachable by link, out of the menu — and also out of search, the sitemap and llms.txt,
8
+ * and noindex, which MkDocs does not do. None when MkDocs lists every page or the nav is not all
9
+ * written in mkdocs.yml:
10
+ * - no `nav:` (MkDocs lists every page);
11
+ * - a plugin that builds or extends the nav (literate-nav, awesome-pages/awesome-nav, i18n,
12
+ * monorepo/multirepo), or a nav entry naming a folder (`reference/`), a glob or `...`;
13
+ * The home page (`index`) is never one: MkDocs serves it at the root whatever the nav says. A
14
+ * Material blog's posts (`blog_dir`, default `blog`) are listed by the blog's own index. An entry
15
+ * to part of a page (`a.md#part`) lists the page.
16
+ */
17
+ export function pagesOutsideNav(slugs, raw) {
18
+ const navRaw = raw.nav;
19
+ if (!Array.isArray(navRaw) || navRaw.length === 0)
20
+ return [];
21
+ const plugins = pluginEntries(raw.plugins);
22
+ if (plugins.some(([name]) => NAV_PLUGINS.test(name)))
23
+ return [];
24
+ const listed = new Set();
25
+ let partial = false;
26
+ const add = (path) => {
27
+ const bare = path.trim();
28
+ if (bare === "..." || bare.endsWith("/") || /[*?[\]]/.test(bare.split("#")[0]))
29
+ partial = true;
30
+ else {
31
+ const slug = navPathSlug(bare);
32
+ if (slug !== undefined)
33
+ listed.add(slug);
34
+ }
35
+ };
36
+ const walk = (items) => {
37
+ for (const entry of items) {
38
+ if (typeof entry === "string")
39
+ add(entry);
40
+ else if (entry && typeof entry === "object") {
41
+ for (const value of Object.values(entry)) {
42
+ if (typeof value === "string")
43
+ add(value);
44
+ else if (Array.isArray(value))
45
+ walk(value);
46
+ }
47
+ }
48
+ }
49
+ };
50
+ walk(navRaw);
51
+ if (partial)
52
+ return [];
53
+ const blogDirs = plugins
54
+ .filter(([name]) => name === "blog" || name === "material/blog")
55
+ .map(([, cfg]) => {
56
+ const dir = cfg && typeof cfg === "object" ? cfg.blog_dir : undefined;
57
+ return typeof dir === "string" ? dir.replace(/^\.?\/+|\/+$/g, "").replace(/^\.$/, "") : "blog";
58
+ });
59
+ return slugs.filter((slug) => slug !== "index" && !listed.has(slug) && !blogDirs.some((d) => d === "" || slug === d || slug.startsWith(`${d}/`)));
60
+ }
61
+ /** Plugins that build or extend the nav from elsewhere: the `nav:` in mkdocs.yml is not all of it. */
62
+ const NAV_PLUGINS = /^(?:literate-nav|awesome-pages|awesome-nav|i18n|static-i18n|monorepo|multirepo|mkdocs-nav-weight|gen-files)$/;
63
+ /** `plugins:` as `[name, config]`, from the list form (`- blog`, `- blog: {…}`) or the mapping form. */
64
+ function pluginEntries(plugins) {
65
+ if (Array.isArray(plugins)) {
66
+ return plugins.flatMap((p) => typeof p === "string" ? [[p, undefined]] : p && typeof p === "object" ? Object.entries(p) : []);
67
+ }
68
+ return plugins && typeof plugins === "object" ? Object.entries(plugins) : [];
69
+ }
70
+ /** A nav entry's file as a page slug (`a/index.md` → `a`, `index.md` → `index`, `a.md#x` → `a`); a URL names none. */
71
+ function navPathSlug(path) {
72
+ if (/^[a-z][a-z0-9+.-]*:/i.test(path) || path.startsWith("//"))
73
+ return undefined;
74
+ const slug = path.split(/[#?]/)[0].replace(/^\.?\/+/, "").replace(/\.md$/, "").replace(/\/index$/, "").replace(/^index$/, "");
75
+ return slug || "index";
76
+ }
package/dist/parse.d.ts CHANGED
@@ -9,4 +9,3 @@ export declare function parseToTree(md: MarkdownIt, src: string, envOverrides?:
9
9
  tree: TreeNode[];
10
10
  env: Record<string, unknown>;
11
11
  };
12
- //# sourceMappingURL=parse.d.ts.map
package/dist/parse.js CHANGED
@@ -43,4 +43,3 @@ export function parseToTree(md, src, envOverrides) {
43
43
  }
44
44
  return { tree, env };
45
45
  }
46
- //# sourceMappingURL=parse.js.map
@@ -6,4 +6,3 @@
6
6
  * identical diagrams across pages.
7
7
  */
8
8
  export declare function renderMermaidSvg(code: string): Promise<string | null>;
9
- //# sourceMappingURL=mermaid.d.ts.map
@@ -114,4 +114,3 @@ export async function renderMermaidSvg(code) {
114
114
  catch { /* ignore */ }
115
115
  }
116
116
  }
117
- //# sourceMappingURL=mermaid.js.map
@@ -3,4 +3,3 @@ import type MarkdownIt from "markdown-it";
3
3
  * Register the admonition block rule with markdown-it.
4
4
  */
5
5
  export declare function admonitionPlugin(md: MarkdownIt): void;
6
- //# sourceMappingURL=admonition.d.ts.map
@@ -70,4 +70,3 @@ export function admonitionPlugin(md) {
70
70
  alt: ["paragraph", "reference", "blockquote", "list"],
71
71
  });
72
72
  }
73
- //# sourceMappingURL=admonition.js.map
@@ -3,4 +3,3 @@ import type MarkdownIt from "markdown-it";
3
3
  * Register the annotations post-process rule with markdown-it.
4
4
  */
5
5
  export declare function annotationsPlugin(md: MarkdownIt): void;
6
- //# sourceMappingURL=annotations.d.ts.map
@@ -54,4 +54,3 @@ function annotationsRule(state) {
54
54
  export function annotationsPlugin(md) {
55
55
  md.core.ruler.push("annotations", annotationsRule);
56
56
  }
57
- //# sourceMappingURL=annotations.js.map
@@ -1,7 +1,6 @@
1
- import type { AutodocOptions } from "../autodoc/types.js";
1
+ import { type AutodocOptions } from "@dogsbay/autodoc-python";
2
2
  /**
3
3
  * Preprocess markdown source: replace ::: directives with generated API docs.
4
4
  * Called from the loader (async context) before md.parse().
5
5
  */
6
6
  export declare function preprocessAutodoc(source: string, options: AutodocOptions): Promise<string>;
7
- //# sourceMappingURL=autodoc.d.ts.map
@@ -1,6 +1,5 @@
1
1
  import YAML from "yaml";
2
- import { resolveIdentifier } from "../autodoc/module-resolver.js";
3
- import { generateMarkdown } from "../autodoc/markdown-generator.js";
2
+ import { resolveIdentifier, generateMarkdown, } from "@dogsbay/autodoc-python";
4
3
  /**
5
4
  * Match ::: identifier (mkdocstrings directive)
6
5
  */
@@ -99,4 +98,3 @@ export async function preprocessAutodoc(source, options) {
99
98
  }
100
99
  return changed ? lines.join("\n") : source;
101
100
  }
102
- //# sourceMappingURL=autodoc.js.map
@@ -3,4 +3,3 @@ import type MarkdownIt from "markdown-it";
3
3
  * Register the blocks syntax rule with markdown-it.
4
4
  */
5
5
  export declare function blocksPlugin(md: MarkdownIt): void;
6
- //# sourceMappingURL=blocks.d.ts.map
@@ -169,4 +169,3 @@ export function blocksPlugin(md) {
169
169
  alt: ["paragraph", "reference", "blockquote", "list"],
170
170
  });
171
171
  }
172
- //# sourceMappingURL=blocks.js.map
@@ -3,4 +3,3 @@ import type MarkdownIt from "markdown-it";
3
3
  * Register the content tabs block rule with markdown-it.
4
4
  */
5
5
  export declare function contentTabsPlugin(md: MarkdownIt): void;
6
- //# sourceMappingURL=content-tabs.d.ts.map
@@ -64,4 +64,3 @@ export function contentTabsPlugin(md) {
64
64
  alt: ["paragraph", "reference", "blockquote", "list"],
65
65
  });
66
66
  }
67
- //# sourceMappingURL=content-tabs.js.map
@@ -4,4 +4,3 @@ import type MarkdownIt from "markdown-it";
4
4
  * Opt-in only — conflicts with mkdocstrings ::: directive.
5
5
  */
6
6
  export declare function docusaurusAdmonitionsPlugin(md: MarkdownIt): void;
7
- //# sourceMappingURL=docusaurus-admonitions.d.ts.map
@@ -98,4 +98,3 @@ export function docusaurusAdmonitionsPlugin(md) {
98
98
  alt: ["paragraph", "reference", "blockquote", "list"],
99
99
  });
100
100
  }
101
- //# sourceMappingURL=docusaurus-admonitions.js.map
@@ -25,4 +25,3 @@ export declare function remapHighlights(hlNums: number[], lnNums: number[]): num
25
25
  * Runs after snippets but before normalize.
26
26
  */
27
27
  export declare function fileIncludePlugin(md: MarkdownIt, options: FileIncludeOptions): void;
28
- //# sourceMappingURL=file-include.d.ts.map
@@ -195,4 +195,3 @@ function createFileIncludeRule(options) {
195
195
  export function fileIncludePlugin(md, options) {
196
196
  md.core.ruler.before("normalize", "file_include", createFileIncludeRule(options));
197
197
  }
198
- //# sourceMappingURL=file-include.js.map
@@ -3,4 +3,3 @@ import type MarkdownIt from "markdown-it";
3
3
  * Register footnote block + inline rules with markdown-it.
4
4
  */
5
5
  export declare function footnotesPlugin(md: MarkdownIt): void;
6
- //# sourceMappingURL=footnotes.d.ts.map
@@ -158,4 +158,3 @@ export function footnotesPlugin(md) {
158
158
  return `<fn-ref data-label="${label}"></fn-ref>`;
159
159
  };
160
160
  }
161
- //# sourceMappingURL=footnotes.js.map
@@ -27,4 +27,3 @@ export declare function parseShortcode(raw: string): ParsedShortcode;
27
27
  */
28
28
  export declare function iconShortcodePlugin(md: MarkdownIt): void;
29
29
  export {};
30
- //# sourceMappingURL=icon-shortcode.d.ts.map
@@ -166,4 +166,3 @@ function iconShortcodeRule(state, silent) {
166
166
  export function iconShortcodePlugin(md) {
167
167
  md.inline.ruler.after("image", "icon_shortcode", iconShortcodeRule);
168
168
  }
169
- //# sourceMappingURL=icon-shortcode.js.map
@@ -3,4 +3,3 @@ import type MarkdownIt from "markdown-it";
3
3
  * Register the keyboard keys inline rule with markdown-it.
4
4
  */
5
5
  export declare function keysPlugin(md: MarkdownIt): void;
6
- //# sourceMappingURL=keys.d.ts.map
@@ -27,4 +27,3 @@ function keysRule(state, silent) {
27
27
  export function keysPlugin(md) {
28
28
  md.inline.ruler.before("escape", "keys", keysRule);
29
29
  }
30
- //# sourceMappingURL=keys.js.map
@@ -4,4 +4,3 @@ export interface LinkRewriteOptions {
4
4
  baseUrl?: string;
5
5
  }
6
6
  export declare function linkRewritePlugin(md: MarkdownIt, options?: LinkRewriteOptions): void;
7
- //# sourceMappingURL=link-rewrite.d.ts.map
@@ -90,4 +90,3 @@ function rewriteAssetPath(src, fileDir) {
90
90
  export function linkRewritePlugin(md, options = {}) {
91
91
  md.core.ruler.push("link_rewrite", createLinkRewriteRule(options));
92
92
  }
93
- //# sourceMappingURL=link-rewrite.js.map
@@ -11,4 +11,3 @@ import type MarkdownIt from "markdown-it";
11
11
  * Register math rules with markdown-it.
12
12
  */
13
13
  export declare function mathPlugin(md: MarkdownIt): void;
14
- //# sourceMappingURL=math.d.ts.map
@@ -111,4 +111,3 @@ export function mathPlugin(md) {
111
111
  alt: ["paragraph", "reference", "blockquote"],
112
112
  });
113
113
  }
114
- //# sourceMappingURL=math.js.map
@@ -3,4 +3,3 @@ import type MarkdownIt from "markdown-it";
3
3
  * Register the md_in_html core rule with markdown-it.
4
4
  */
5
5
  export declare function mdInHtmlPlugin(md: MarkdownIt): void;
6
- //# sourceMappingURL=md-in-html.d.ts.map
@@ -132,4 +132,3 @@ function mdInHtmlRule(state) {
132
132
  export function mdInHtmlPlugin(md) {
133
133
  md.core.ruler.push("md_in_html", mdInHtmlRule);
134
134
  }
135
- //# sourceMappingURL=md-in-html.js.map
@@ -7,4 +7,3 @@ export interface SnippetsOptions {
7
7
  * Register the snippets core rule with markdown-it.
8
8
  */
9
9
  export declare function snippetsPlugin(md: MarkdownIt, options: SnippetsOptions): void;
10
- //# sourceMappingURL=snippets.d.ts.map
@@ -106,4 +106,3 @@ function createSnippetsRule(options) {
106
106
  export function snippetsPlugin(md, options) {
107
107
  md.core.ruler.before("normalize", "snippets", createSnippetsRule(options));
108
108
  }
109
- //# sourceMappingURL=snippets.js.map
@@ -12,4 +12,3 @@ export interface TemplatesOptions {
12
12
  * Must run BEFORE all other core rules (templates expand first).
13
13
  */
14
14
  export declare function templatesPlugin(md: MarkdownIt, options: TemplatesOptions): void;
15
- //# sourceMappingURL=templates.d.ts.map
@@ -102,4 +102,3 @@ function createTemplatesRule(options) {
102
102
  export function templatesPlugin(md, options) {
103
103
  md.core.ruler.before("normalize", "templates", createTemplatesRule(options));
104
104
  }
105
- //# sourceMappingURL=templates.js.map
@@ -9,4 +9,3 @@ export interface VariantsOptions {
9
9
  * get their {* *} includes resolved.
10
10
  */
11
11
  export declare function variantsPlugin(md: MarkdownIt, options: VariantsOptions): void;
12
- //# sourceMappingURL=variants.d.ts.map
@@ -145,4 +145,3 @@ function createVariantsRule(options) {
145
145
  export function variantsPlugin(md, options) {
146
146
  md.core.ruler.before("normalize", "variants", createVariantsRule(options));
147
147
  }
148
- //# sourceMappingURL=variants.js.map
package/dist/tree.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export type { TreeNode } from "@dogsbay/types";
2
- //# sourceMappingURL=tree.d.ts.map
package/dist/tree.js CHANGED
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=tree.js.map
@@ -15,4 +15,3 @@ export declare function findIndentedBlockEnd(state: StateBlock, startLine: numbe
15
15
  * become top-level blocks in the inner parse pass.
16
16
  */
17
17
  export declare function dedentAndTokenize(state: StateBlock, startLine: number, endLine: number, indent: number): void;
18
- //# sourceMappingURL=indent.d.ts.map
@@ -53,4 +53,3 @@ export function dedentAndTokenize(state, startLine, endLine, indent) {
53
53
  }
54
54
  state.blkIndent = savedBlkIndent;
55
55
  }
56
- //# sourceMappingURL=indent.js.map
@@ -16,4 +16,3 @@ export declare function resolveType(raw: string): string;
16
16
  * Auto-capitalize a type keyword for default title.
17
17
  */
18
18
  export declare function autoTitle(type: string): string;
19
- //# sourceMappingURL=types.d.ts.map
@@ -60,4 +60,3 @@ export function resolveType(raw) {
60
60
  export function autoTitle(type) {
61
61
  return type.charAt(0).toUpperCase() + type.slice(1);
62
62
  }
63
- //# sourceMappingURL=types.js.map
package/dist/walker.d.ts CHANGED
@@ -5,4 +5,3 @@ import type { TreeNode } from "./tree.js";
5
5
  * Handles open/close token pairs by recursively collecting children.
6
6
  */
7
7
  export declare function tokensToTree(tokens: Token[]): TreeNode[];
8
- //# sourceMappingURL=walker.d.ts.map