@functional-examples/documentation 0.0.0-alpha.3 → 0.0.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.
@@ -0,0 +1,21 @@
1
+ import type { ResolvedConfig } from '@functional-examples/devkit';
2
+ import type { ResolvedDocumentationPluginOptions } from '../schema.js';
3
+ export declare function createGenerateCommand(config: ResolvedConfig, pluginOpts: ResolvedDocumentationPluginOptions): import("cli-forge").CLI<{
4
+ unmatched: string[];
5
+ '--'?: string[];
6
+ } & {} & {
7
+ output: string;
8
+ } & {} & {
9
+ format: string;
10
+ } & {
11
+ templates?: string | undefined;
12
+ } & {} & {
13
+ filter?: string | undefined;
14
+ } & {} & {} & {
15
+ "dry-run": boolean;
16
+ } & {} & {
17
+ clean: boolean;
18
+ } & {} & {
19
+ check: boolean;
20
+ }, Promise<void>, {}, undefined>;
21
+ //# sourceMappingURL=generate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAK3E,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,cAAc,CAAC;AA6CvE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,kCAAkC;;;;;;;;;;;;;;;;;sCAiP/C"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAK3E,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,cAAc,CAAC;AA6CvE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,kCAAkC;;;;;;;;;;;;;;;;;iCAiP/C"}
@@ -0,0 +1,21 @@
1
+ import type { ResolvedConfig } from '@functional-examples/devkit';
2
+ import type { ResolvedDocumentationPluginOptions } from '../schema.js';
3
+ export declare function createDocumentationCommands(config: ResolvedConfig, pluginOpts: ResolvedDocumentationPluginOptions): import("cli-forge").CLI<{
4
+ unmatched: string[];
5
+ '--'?: string[];
6
+ } & {} & {
7
+ output: string;
8
+ } & {} & {
9
+ format: string;
10
+ } & {
11
+ templates?: string | undefined;
12
+ } & {} & {
13
+ filter?: string | undefined;
14
+ } & {} & {} & {
15
+ "dry-run": boolean;
16
+ } & {} & {
17
+ clean: boolean;
18
+ } & {} & {
19
+ check: boolean;
20
+ }, Promise<void>, {}, undefined>[];
21
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,cAAc,CAAC;AAGvE,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,kCAAkC;;;;;;;;;;;;;;;;;wCAG/C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,cAAc,CAAC;AAGvE,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,kCAAkC;;;;;;;;;;;;;;;;;mCAG/C"}
@@ -0,0 +1,9 @@
1
+ import type { Extractor } from '@functional-examples/devkit';
2
+ /**
3
+ * Create a markdown frontmatter extractor.
4
+ *
5
+ * Scans for .md files with YAML frontmatter containing at least `id` and `title`.
6
+ * Treats each matching file as a single-file example.
7
+ */
8
+ export declare function createMarkdownExtractor(): Extractor;
9
+ //# sourceMappingURL=extractor.d.ts.map
@@ -0,0 +1,32 @@
1
+ import type { Plugin } from '@functional-examples/devkit';
2
+ import type { DocsMetadataSchemaType, DocumentationPluginOptions } from './schema.js';
3
+ /**
4
+ * Create the documentation plugin.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { createDocumentationPlugin } from '@functional-examples/documentation';
9
+ *
10
+ * const config = {
11
+ * plugins: [
12
+ * createDocumentationPlugin({
13
+ * outputDir: './docs',
14
+ * format: 'markdown',
15
+ * }),
16
+ * ],
17
+ * };
18
+ * ```
19
+ */
20
+ export declare function createDocumentationPlugin(options?: DocumentationPluginOptions): Plugin<DocsMetadataSchemaType>;
21
+ export type { DocumentationPluginOptions, DocsMetadata, ResolvedDocumentationPluginOptions, DocsMetadataSchemaType, } from './schema.js';
22
+ export type { TemplateData, TemplateDescriptor, RenderedFile, IndexTemplateData, ProseRenderResult, } from './templates/engine.js';
23
+ export type { TemplateHelpers } from './templates/helpers.js';
24
+ export type { ProseHelpers } from './templates/prose-helpers.js';
25
+ export { createMarkdownExtractor } from './extractor/extractor.js';
26
+ export { renderTemplate, buildTemplateData, renderProseFiles, loadTemplates, parseTemplateName, substituteVars, renderItemTemplate, renderIndexTemplate, getBuiltinTemplatesDir, } from './templates/engine.js';
27
+ export { templateHelpers } from './templates/helpers.js';
28
+ export { ConsumptionTracker } from './templates/consumption-tracker.js';
29
+ export { createProseHelpers, fencedBlock } from './templates/prose-helpers.js';
30
+ export { createGuideRenderer } from './templates/guide-renderer.js';
31
+ export type { GuideRenderer, ExampleAccessor } from './templates/guide-renderer.js';
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,63 @@
1
+ import { z } from 'zod';
2
+ import type { ValidationResult } from '@functional-examples/devkit';
3
+ /**
4
+ * Zod schema for documentation-specific metadata.
5
+ */
6
+ export declare const docsMetadataSchema: z.ZodObject<{
7
+ docs: z.ZodOptional<z.ZodObject<{
8
+ template: z.ZodOptional<z.ZodString>;
9
+ skip: z.ZodOptional<z.ZodBoolean>;
10
+ outputName: z.ZodOptional<z.ZodString>;
11
+ /** Descriptions for specific hunks/regions, keyed by hunk ID */
12
+ hunks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
13
+ }, z.core.$strict>>;
14
+ }, z.core.$strip>;
15
+ export type DocsMetadataSchemaType = z.infer<typeof docsMetadataSchema>;
16
+ /** JSON Schema for metadata plugin registration */
17
+ export declare const DOCS_METADATA_JSON_SCHEMA: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
18
+ docs: z.ZodOptional<z.ZodObject<{
19
+ template: z.ZodOptional<z.ZodString>;
20
+ skip: z.ZodOptional<z.ZodBoolean>;
21
+ outputName: z.ZodOptional<z.ZodString>;
22
+ /** Descriptions for specific hunks/regions, keyed by hunk ID */
23
+ hunks: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
24
+ }, z.core.$strict>>;
25
+ }, z.core.$strip>>;
26
+ /**
27
+ * Zod schema for documentation plugin options.
28
+ * Fields with defaults are resolved via `docsOptionsSchema.parse(...)`.
29
+ */
30
+ export declare const docsOptionsSchema: z.ZodObject<{
31
+ outputDir: z.ZodDefault<z.ZodString>;
32
+ format: z.ZodDefault<z.ZodEnum<{
33
+ markdown: "markdown";
34
+ mdoc: "mdoc";
35
+ }>>;
36
+ templates: z.ZodOptional<z.ZodString>;
37
+ enableExtractor: z.ZodDefault<z.ZodBoolean>;
38
+ }, z.core.$strip>;
39
+ /** JSON Schema for options plugin registration */
40
+ export declare const DOCS_OPTIONS_JSON_SCHEMA: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
41
+ outputDir: z.ZodDefault<z.ZodString>;
42
+ format: z.ZodDefault<z.ZodEnum<{
43
+ markdown: "markdown";
44
+ mdoc: "mdoc";
45
+ }>>;
46
+ templates: z.ZodOptional<z.ZodString>;
47
+ enableExtractor: z.ZodDefault<z.ZodBoolean>;
48
+ }, z.core.$strip>>;
49
+ /**
50
+ * Validate documentation metadata using Zod schema.
51
+ */
52
+ export declare function validateDocsMetadata(metadata: unknown): ValidationResult;
53
+ /** Options for the documentation plugin factory (input — all optional). */
54
+ export type DocumentationPluginOptions = z.input<typeof docsOptionsSchema>;
55
+ /** Resolved options with defaults applied (output of parsing). */
56
+ export type ResolvedDocumentationPluginOptions = z.output<typeof docsOptionsSchema>;
57
+ /**
58
+ * Documentation-specific metadata that examples can declare.
59
+ */
60
+ export interface DocsMetadata {
61
+ docs?: DocsMetadataSchemaType;
62
+ }
63
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1,16 @@
1
+ import type { ExampleFile } from '@functional-examples/devkit';
2
+ /**
3
+ * Tracks which example files have been "consumed" by prose template helpers
4
+ * (e.g. `file()` or `region()`). Consumed files are excluded from the
5
+ * "remaining files" section in the rendered output.
6
+ */
7
+ export declare class ConsumptionTracker {
8
+ private consumed;
9
+ /** Mark a file as consumed by its relative path. */
10
+ consume(relativePath: string): void;
11
+ /** Check whether a file has been consumed. */
12
+ isConsumed(relativePath: string): boolean;
13
+ /** Return only those files that have NOT been consumed. */
14
+ getUnconsumedFiles(files: ExampleFile[]): ExampleFile[];
15
+ }
16
+ //# sourceMappingURL=consumption-tracker.d.ts.map
@@ -0,0 +1,123 @@
1
+ import type { Example, ExampleFile } from '@functional-examples/devkit';
2
+ import { type TemplateHelpers } from './helpers.js';
3
+ /**
4
+ * Template data model passed to Eta per-item templates as `it`.
5
+ */
6
+ export interface TemplateData {
7
+ /** Example unique identifier */
8
+ id: string;
9
+ /** Example title */
10
+ title: string;
11
+ /** Example description */
12
+ description?: string;
13
+ /** Full metadata object */
14
+ metadata: Record<string, unknown>;
15
+ /** Example files */
16
+ files: ExampleFile[];
17
+ /** Template helper functions */
18
+ helpers: TemplateHelpers;
19
+ /** Prose files rendered through Eta (with file/region helpers expanded) */
20
+ renderedProse: string[];
21
+ /** Files not consumed by prose helpers — the "remaining" code files */
22
+ unconsumedFiles: ExampleFile[];
23
+ }
24
+ /** Data model for aggregate (index) templates. */
25
+ export interface IndexTemplateData {
26
+ examples: {
27
+ id: string;
28
+ title: string;
29
+ description?: string;
30
+ }[];
31
+ format: string;
32
+ helpers: TemplateHelpers;
33
+ }
34
+ /** Parsed template file descriptor. */
35
+ export interface TemplateDescriptor {
36
+ /** Absolute path to the .template source file */
37
+ sourcePath: string;
38
+ /** Filename minus '.template', e.g. '@slug.md' */
39
+ outputPattern: string;
40
+ /** File extension, e.g. '.md' or '.mdoc' */
41
+ format: string;
42
+ /** Whether the filename contains an @var placeholder */
43
+ perItem: boolean;
44
+ /** Variable name (e.g. 'slug') when perItem is true */
45
+ variable?: string;
46
+ /** Raw Eta template content */
47
+ content: string;
48
+ }
49
+ /** Rendered output ready to write. */
50
+ export interface RenderedFile {
51
+ /** Relative path for the output file */
52
+ relativePath: string;
53
+ /** Rendered content */
54
+ content: string;
55
+ }
56
+ /** Result of rendering prose files through Eta. */
57
+ export interface ProseRenderResult {
58
+ /** Rendered prose content strings (one per prose file). */
59
+ renderedProse: string[];
60
+ /** Files not consumed by prose file/region helpers. */
61
+ unconsumedFiles: ExampleFile[];
62
+ }
63
+ /**
64
+ * Render prose files through Eta, expanding `file()` and `region()` helpers,
65
+ * and return which files remain unconsumed.
66
+ */
67
+ export declare function renderProseFiles(files: ExampleFile[], metadata: Record<string, unknown>): ProseRenderResult;
68
+ /**
69
+ * Build the template data model from an Example.
70
+ */
71
+ export declare function buildTemplateData(example: Example): TemplateData;
72
+ /**
73
+ * Resolve the built-in templates directory relative to this file.
74
+ * At runtime, this file lives at `dist/templates/engine.js`.
75
+ * The templates directory is at `packages/documentation/templates/`
76
+ * — two levels up from `dist/templates/`.
77
+ */
78
+ export declare function getBuiltinTemplatesDir(): string;
79
+ /**
80
+ * Parse a template's relative path into its descriptor fields.
81
+ *
82
+ * The `@var` convention can appear in any path segment — either in the
83
+ * filename itself or in a directory name:
84
+ * - `@slug.md.template` → variable `slug` (flat, filename)
85
+ * - `examples/@example/index.md.template` → variable `example` (nested, directory)
86
+ *
87
+ * @param relativePath - Path relative to the templates root, e.g. `examples/@example/index.md.template`
88
+ */
89
+ export declare function parseTemplateName(relativePath: string): Pick<TemplateDescriptor, 'outputPattern' | 'format' | 'perItem' | 'variable'>;
90
+ /**
91
+ * Replace `@var` placeholders in a pattern with values from a vars map.
92
+ *
93
+ * Example: `substituteVars('@slug.md', { slug: 'getting-started' })` → `getting-started.md`
94
+ */
95
+ export declare function substituteVars(pattern: string, vars: Record<string, string>): string;
96
+ /**
97
+ * Load all `.template` files from a directory (recursively) and parse their paths.
98
+ *
99
+ * Supports nested directory structures like:
100
+ * ```
101
+ * templates/
102
+ * index.md.template
103
+ * examples/@example/index.md.template
104
+ * ```
105
+ */
106
+ export declare function loadTemplates(dir?: string): Promise<TemplateDescriptor[]>;
107
+ /**
108
+ * Render a per-item template for a single example.
109
+ */
110
+ export declare function renderItemTemplate(template: TemplateDescriptor, example: Example): Promise<RenderedFile>;
111
+ /**
112
+ * Render an aggregate template with all examples.
113
+ */
114
+ export declare function renderIndexTemplate(template: TemplateDescriptor, examples: Example[]): Promise<RenderedFile>;
115
+ /**
116
+ * Render an example using the default or a custom template file.
117
+ *
118
+ * @param example - The example to render
119
+ * @param templatePath - Optional path to a custom .eta template file
120
+ * @returns Rendered string
121
+ */
122
+ export declare function renderTemplate(example: Example, templatePath?: string): Promise<string>;
123
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Guide hydration renderer — expands example references in standalone
3
+ * markdown guides that reference files/regions from *any* scanned example.
4
+ *
5
+ * Unlike prose helpers (scoped to a single example), the guide renderer
6
+ * creates a cross-example lookup so authors can write:
7
+ *
8
+ * ```markdown
9
+ * <%= example('basic-usage').file('scan.ts') %>
10
+ * <%= example('basic-usage').region('config-setup') %>
11
+ * ```
12
+ */
13
+ import type { ExampleFile, ScannedExample } from '@functional-examples/devkit';
14
+ /**
15
+ * A renderer that expands example references in guide markdown.
16
+ */
17
+ export interface GuideRenderer {
18
+ /** Render a markdown string, expanding example references. */
19
+ render(markdown: string): string;
20
+ /** Read a markdown file and render it, expanding example references. */
21
+ renderFile(filePath: string): Promise<string>;
22
+ }
23
+ /**
24
+ * Scoped API returned by `example(id)` inside guide templates.
25
+ */
26
+ export interface ExampleAccessor {
27
+ /** Render a file as a fenced code block. */
28
+ file(relativePath: string): string;
29
+ /** Render a region/hunk as a fenced code block. */
30
+ region(regionId: string): string;
31
+ /** All files in the example. */
32
+ files: ExampleFile[];
33
+ /** The example's metadata. */
34
+ metadata: Record<string, unknown>;
35
+ /** The example's title. */
36
+ title: string;
37
+ /** The example's description. */
38
+ description?: string;
39
+ }
40
+ /**
41
+ * Create a guide renderer bound to a set of scanned examples.
42
+ *
43
+ * Guide templates can reference any example by ID:
44
+ * ```markdown
45
+ * <%= example('basic-usage').file('scan.ts') %>
46
+ * ```
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * import { createGuideRenderer } from '@functional-examples/documentation';
51
+ * import { scan } from 'functional-examples';
52
+ *
53
+ * const { examples } = await scan({ root: workspaceRoot });
54
+ * const renderer = createGuideRenderer(examples);
55
+ * const html = await renderer.renderFile('docs/guides/getting-started.md');
56
+ * ```
57
+ */
58
+ export declare function createGuideRenderer(examples: ScannedExample[]): GuideRenderer;
59
+ //# sourceMappingURL=guide-renderer.d.ts.map
@@ -0,0 +1,45 @@
1
+ import type { ExampleFile } from '@functional-examples/devkit';
2
+ /**
3
+ * Infer a code fence language identifier from a file path's extension.
4
+ */
5
+ export declare function langFromPath(filePath: string): string;
6
+ /**
7
+ * Select a specific hunk (region) by ID across all files.
8
+ * Returns the first matching hunk or undefined.
9
+ */
10
+ export declare function region(files: ExampleFile[], regionId: string): {
11
+ file: ExampleFile;
12
+ content: string;
13
+ } | undefined;
14
+ /**
15
+ * Filter files by extension.
16
+ */
17
+ export declare function filesByExt(files: ExampleFile[], ext: string): ExampleFile[];
18
+ /**
19
+ * Check whether a file is a prose/documentation file (e.g. README.md).
20
+ */
21
+ export declare function isProseFile(file: ExampleFile): boolean;
22
+ /**
23
+ * Look up a hunk description from the docs metadata.
24
+ * Returns the description string or undefined.
25
+ */
26
+ export declare function hunkDescription(metadata: Record<string, unknown>, hunkId: string): string | undefined;
27
+ /**
28
+ * Convert a string to a URL-friendly slug.
29
+ * Strips backticks, lowercases, replaces non-alphanumeric runs with dashes,
30
+ * and trims leading/trailing dashes.
31
+ */
32
+ export declare function slugify(text: string): string;
33
+ /**
34
+ * Collected template helpers exposed as `it.helpers`.
35
+ */
36
+ export declare const templateHelpers: {
37
+ readonly langFromPath: typeof langFromPath;
38
+ readonly region: typeof region;
39
+ readonly filesByExt: typeof filesByExt;
40
+ readonly isProseFile: typeof isProseFile;
41
+ readonly hunkDescription: typeof hunkDescription;
42
+ readonly slugify: typeof slugify;
43
+ };
44
+ export type TemplateHelpers = typeof templateHelpers;
45
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1,26 @@
1
+ import type { ExampleFile } from '@functional-examples/devkit';
2
+ import { ConsumptionTracker } from './consumption-tracker.js';
3
+ import { templateHelpers } from './helpers.js';
4
+ /** Helpers injected into prose Eta templates as top-level variables. */
5
+ export interface ProseHelpers {
6
+ /** Render a file as a fenced code block and mark it consumed. */
7
+ file: (relativePath: string) => string;
8
+ /** Render a region/hunk as a fenced code block and mark its file consumed. */
9
+ region: (regionId: string) => string;
10
+ /** All example files (read-only). */
11
+ files: ExampleFile[];
12
+ /** Standard template helpers (langFromPath, slugify, etc.). */
13
+ helpers: typeof templateHelpers;
14
+ }
15
+ /**
16
+ * Build a fenced code block string for a given language and content.
17
+ */
18
+ export declare function fencedBlock(lang: string, content: string): string;
19
+ /**
20
+ * Create prose-template helpers bound to a specific set of files and tracker.
21
+ *
22
+ * These helpers are injected into Eta prose templates via `functionHeader`
23
+ * so authors can write `<%= file('utils.ts') %>` instead of `<%= it.file('utils.ts') %>`.
24
+ */
25
+ export declare function createProseHelpers(files: ExampleFile[], tracker: ConsumptionTracker): ProseHelpers;
26
+ //# sourceMappingURL=prose-helpers.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functional-examples/documentation",
3
- "version": "0.0.0-alpha.3",
3
+ "version": "0.0.1",
4
4
  "type": "module",
5
5
  "description": "Documentation generation plugin for functional-examples",
6
6
  "publishConfig": {
@@ -20,7 +20,7 @@
20
20
  "templates"
21
21
  ],
22
22
  "peerDependencies": {
23
- "functional-examples": "0.0.0-alpha.3"
23
+ "functional-examples": "0.0.1"
24
24
  },
25
25
  "peerDependenciesMeta": {
26
26
  "yaml": {
@@ -31,15 +31,15 @@
31
31
  "cli-forge": "1.2.0",
32
32
  "eta": "^3.5.0",
33
33
  "zod": "4.3.6",
34
- "@functional-examples/devkit": "0.0.0-alpha.3"
34
+ "@functional-examples/devkit": "0.0.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "22.19.8",
38
38
  "typescript": "^5.7.2",
39
39
  "vitest": "^1.3.1",
40
40
  "yaml": "^2.7.1",
41
- "functional-examples": "0.0.0-alpha.3",
42
- "@functional-examples/devkit": "0.0.0-alpha.3"
41
+ "@functional-examples/devkit": "0.0.1",
42
+ "functional-examples": "0.0.1"
43
43
  },
44
44
  "license": "MIT",
45
45
  "author": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdoc.d.ts","sourceRoot":"","sources":["../../src/renderers/markdoc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,IAAI,QAAQ,CAkChD"}
@@ -1,42 +0,0 @@
1
- /**
2
- * Markdoc renderer — wraps code blocks with Markdoc-style fence annotations.
3
- *
4
- * Converts standard Markdown code fences into Markdoc-annotated fences:
5
- * ```typescript → ```typescript {% process=true %}
6
- * code code
7
- * ``` ```
8
- *
9
- * Also converts headings to Markdoc-annotated headings with auto-generated IDs.
10
- */
11
- export function createMarkdocRenderer() {
12
- return {
13
- extension: '.mdoc',
14
- render(content) {
15
- const lines = content.split('\n');
16
- const result = [];
17
- for (const line of lines) {
18
- // Annotate code fences with Markdoc attributes
19
- const fenceMatch = line.match(/^(```\w+)\s*$/);
20
- if (fenceMatch) {
21
- result.push(`${fenceMatch[1]} {% process=true %}`);
22
- continue;
23
- }
24
- // Annotate headings with auto-generated IDs
25
- const headingMatch = line.match(/^(#{1,6})\s+(.+)$/);
26
- if (headingMatch) {
27
- const [, hashes, text] = headingMatch;
28
- const id = text
29
- .replace(/`/g, '')
30
- .toLowerCase()
31
- .replace(/[^a-z0-9]+/g, '-')
32
- .replace(/^-|-$/g, '');
33
- result.push(`${hashes} ${text} {% #${id} %}`);
34
- continue;
35
- }
36
- result.push(line);
37
- }
38
- return result.join('\n');
39
- },
40
- };
41
- }
42
- //# sourceMappingURL=markdoc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdoc.js","sourceRoot":"","sources":["../../src/renderers/markdoc.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL,SAAS,EAAE,OAAO;QAClB,MAAM,CAAC,OAAe;YACpB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAClC,MAAM,MAAM,GAAa,EAAE,CAAC;YAE5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,+CAA+C;gBAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;gBAC/C,IAAI,UAAU,EAAE,CAAC;oBACf,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC;oBACnD,SAAS;gBACX,CAAC;gBAED,4CAA4C;gBAC5C,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;gBACrD,IAAI,YAAY,EAAE,CAAC;oBACjB,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,YAAY,CAAC;oBACtC,MAAM,EAAE,GAAG,IAAI;yBACZ,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;yBACjB,WAAW,EAAE;yBACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;yBAC3B,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;oBACzB,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,IAAI,IAAI,QAAQ,EAAE,KAAK,CAAC,CAAC;oBAC9C,SAAS;gBACX,CAAC;gBAED,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;YAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/renderers/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,QAAQ,CAOjD"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Markdown renderer — passes template output through as-is.
3
- */
4
- export function createMarkdownRenderer() {
5
- return {
6
- extension: '.md',
7
- render(content) {
8
- return content;
9
- },
10
- };
11
- }
12
- //# sourceMappingURL=markdown.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown.js","sourceRoot":"","sources":["../../src/renderers/markdown.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,MAAM,CAAC,OAAe;YACpB,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/renderers/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,sEAAsE;IACtE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/renderers/types.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAC7B,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,kCAAkC;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE;QACL,wDAAwD;QACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,8CAA8C;QAC9C,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,iDAAiD;QACjD,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ;;;;CAMpB,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAC5B,OAAO,GAAE,0BAA+B,GACvC,kCAAkC,CAOpC"}
package/dist/types.js DELETED
@@ -1,20 +0,0 @@
1
- /**
2
- * Default option values.
3
- */
4
- export const DEFAULTS = {
5
- outputDir: './docs',
6
- format: 'markdown',
7
- enableExtractor: false,
8
- };
9
- /**
10
- * Resolve user options with defaults.
11
- */
12
- export function resolveOptions(options = {}) {
13
- return {
14
- outputDir: options.outputDir ?? DEFAULTS.outputDir,
15
- format: options.format ?? DEFAULTS.format,
16
- template: options.template,
17
- enableExtractor: options.enableExtractor ?? DEFAULTS.enableExtractor,
18
- };
19
- }
20
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAsCA;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,SAAS,EAAE,QAAQ;IACnB,MAAM,EAAE,UAAmB;IAC3B,eAAe,EAAE,KAAK;CAGvB,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,UAAsC,EAAE;IAExC,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS;QAClD,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM;QACzC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,QAAQ,CAAC,eAAe;KACrE,CAAC;AACJ,CAAC"}