@openpkg-ts/doc-generator 0.1.0

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,827 @@
1
+ import { OpenPkg as OpenPkg9, SpecExample, SpecExport as SpecExport5, SpecExportKind as SpecExportKind5, SpecMember as SpecMember2, SpecSchema as SpecSchema2, SpecSignature as SpecSignature2, SpecSignatureParameter, SpecTag, SpecType as SpecType3, SpecTypeKind, SpecTypeParameter as SpecTypeParameter2 } from "@openpkg-ts/spec";
2
+ import { OpenPkg, SpecExport } from "@openpkg-ts/spec";
3
+ import { ComponentType, ReactNode } from "react";
4
+ /**
5
+ * Core interface for framework adapters.
6
+ * Each adapter provides framework-specific file generation, components, and config helpers.
7
+ */
8
+ interface DocFrameworkAdapter {
9
+ /** Unique identifier for this adapter */
10
+ name: string;
11
+ /** Display name for documentation */
12
+ displayName: string;
13
+ /** Supported doc framework version(s) */
14
+ version: string;
15
+ /** Generate framework-specific files from spec */
16
+ generate: FileGenerator;
17
+ /** Styled components tailored for the framework */
18
+ components: AdapterComponents;
19
+ /** Config helper for the framework */
20
+ config?: ConfigHelper;
21
+ }
22
+ /**
23
+ * File generation functions for a doc framework.
24
+ */
25
+ interface FileGenerator {
26
+ /** Generate MDX/MD files for each */
27
+ pages(spec: OpenPkg, options?: PageGeneratorOptions): GeneratedFile[];
28
+ /** Generate navigation/sidebar config */
29
+ navigation(spec: OpenPkg, options?: NavGeneratorOptions): GeneratedFile;
30
+ /** Generate search index */
31
+ searchIndex?(spec: OpenPkg, options?: SearchGeneratorOptions): GeneratedFile;
32
+ }
33
+ interface PageGeneratorOptions {
34
+ /** Output directory for generated files */
35
+ outDir?: string;
36
+ /** Base path for URLs */
37
+ basePath?: string;
38
+ /** Include frontmatter in generated files */
39
+ frontmatter?: boolean;
40
+ /** Group exports by kind, module, or tag */
41
+ groupBy?: "kind" | "module" | "tag" | "none";
42
+ /** Filter exports to include */
43
+ filter?: (exp: SpecExport) => boolean;
44
+ }
45
+ interface NavGeneratorOptions {
46
+ /** Output file path */
47
+ outFile?: string;
48
+ /** Base path for links */
49
+ basePath?: string;
50
+ /** Group navigation items */
51
+ groupBy?: "kind" | "module" | "tag";
52
+ /** Include type definitions in nav */
53
+ includeTypes?: boolean;
54
+ }
55
+ interface SearchGeneratorOptions {
56
+ /** Output file path */
57
+ outFile?: string;
58
+ /** Base URL for search results */
59
+ baseUrl?: string;
60
+ /** Fields to include in search index */
61
+ fields?: ("name" | "description" | "signature" | "examples")[];
62
+ }
63
+ interface GeneratedFile {
64
+ /** Relative path for the file */
65
+ path: string;
66
+ /** File contents */
67
+ content: string;
68
+ /** File type for logging/display */
69
+ type: "page" | "navigation" | "search" | "config";
70
+ }
71
+ /**
72
+ * React components provided by an adapter.
73
+ */
74
+ interface AdapterComponents {
75
+ /** Main API page wrapper */
76
+ APIPage: ComponentType<APIPageComponentProps>;
77
+ /** Function page */
78
+ FunctionPage: ComponentType<ExportPageProps>;
79
+ /** Class page */
80
+ ClassPage: ComponentType<ExportPageProps>;
81
+ /** Interface page */
82
+ InterfacePage: ComponentType<ExportPageProps>;
83
+ /** Enum page */
84
+ EnumPage: ComponentType<ExportPageProps>;
85
+ /** Variable/constant page */
86
+ VariablePage: ComponentType<ExportPageProps>;
87
+ /** Type alias page */
88
+ TypePage?: ComponentType<ExportPageProps>;
89
+ }
90
+ interface APIPageComponentProps {
91
+ /** The OpenPkg spec */
92
+ spec: OpenPkg;
93
+ /** Currently selected ID */
94
+ exportId?: string;
95
+ /** Children to render inside the page */
96
+ children?: ReactNode;
97
+ }
98
+ interface ExportPageProps {
99
+ /** The to render */
100
+ export: SpecExport;
101
+ /** The full spec for type resolution */
102
+ spec?: OpenPkg;
103
+ /** Additional children */
104
+ children?: ReactNode;
105
+ }
106
+ /**
107
+ * Config helper for integrating with the doc framework.
108
+ */
109
+ interface ConfigHelper {
110
+ /** Generate framework config snippet */
111
+ generateConfig(options?: ConfigOptions): string;
112
+ /** Validate existing config */
113
+ validateConfig?(configPath: string): ConfigValidationResult;
114
+ }
115
+ interface ConfigOptions {
116
+ /** Package name for the docs */
117
+ packageName?: string;
118
+ /** Base path for API docs */
119
+ basePath?: string;
120
+ /** Enable search integration */
121
+ search?: boolean;
122
+ }
123
+ interface ConfigValidationResult {
124
+ valid: boolean;
125
+ errors?: string[];
126
+ warnings?: string[];
127
+ }
128
+ /**
129
+ * Registry for framework adapters.
130
+ */
131
+ interface AdapterRegistry {
132
+ /** Register a new adapter */
133
+ register(adapter: DocFrameworkAdapter): void;
134
+ /** Get adapter by name */
135
+ get(name: string): DocFrameworkAdapter | undefined;
136
+ /** List all registered adapters */
137
+ list(): DocFrameworkAdapter[];
138
+ }
139
+ /**
140
+ * Create a new adapter registry.
141
+ */
142
+ declare function createAdapterRegistry(): AdapterRegistry;
143
+ /**
144
+ * Default adapter registry instance.
145
+ */
146
+ declare const adapterRegistry: AdapterRegistry;
147
+ import { OpenPkg as OpenPkg7, SpecExport as SpecExport3, SpecExportKind as SpecExportKind4, SpecType } from "@openpkg-ts/spec";
148
+ import { OpenPkg as OpenPkg2 } from "@openpkg-ts/spec";
149
+ interface HTMLOptions {
150
+ /** Page title override */
151
+ title?: string;
152
+ /** Include inline styles */
153
+ includeStyles?: boolean;
154
+ /** Custom CSS to inject */
155
+ customCSS?: string;
156
+ /** Custom head content */
157
+ headContent?: string;
158
+ /** Wrap in full HTML document */
159
+ fullDocument?: boolean;
160
+ /** Export to render (single mode) */
161
+ export?: string;
162
+ }
163
+ /**
164
+ * Render spec to standalone HTML page.
165
+ *
166
+ * @param spec - The OpenPkg spec to render
167
+ * @param options - HTML rendering options
168
+ * @returns Complete HTML document or fragment
169
+ *
170
+ * @example
171
+ * ```ts
172
+ * import { createDocs } from '@openpkg-ts/doc-generator'
173
+ *
174
+ * const docs = createDocs('./openpkg.json')
175
+ *
176
+ * // Full HTML page
177
+ * const html = docs.toHTML({ includeStyles: true })
178
+ * fs.writeFileSync('api.html', html)
179
+ *
180
+ * // Single export, no document wrapper
181
+ * const fragment = docs.toHTML({ export: 'greet', fullDocument: false })
182
+ * ```
183
+ */
184
+ declare function toHTML2(spec: OpenPkg2, options?: HTMLOptions): string;
185
+ import { OpenPkg as OpenPkg3, SpecExportKind } from "@openpkg-ts/spec";
186
+ interface JSONOptions {
187
+ /** Include raw spec data alongside simplified data */
188
+ includeRaw?: boolean;
189
+ /** Export to render (single mode) */
190
+ export?: string;
191
+ /** Include computed fields (signatures, formatted types) */
192
+ computed?: boolean;
193
+ /** Flatten nested structures */
194
+ flatten?: boolean;
195
+ }
196
+ interface SimplifiedParameter {
197
+ name: string;
198
+ type: string;
199
+ required: boolean;
200
+ description?: string;
201
+ default?: unknown;
202
+ rest?: boolean;
203
+ }
204
+ interface SimplifiedReturn {
205
+ type: string;
206
+ description?: string;
207
+ }
208
+ interface SimplifiedSignature {
209
+ parameters: SimplifiedParameter[];
210
+ returns?: SimplifiedReturn;
211
+ description?: string;
212
+ typeParameters?: string[];
213
+ }
214
+ interface SimplifiedMember {
215
+ name: string;
216
+ kind: "property" | "method";
217
+ type?: string;
218
+ description?: string;
219
+ visibility?: "public" | "protected" | "private";
220
+ signature?: SimplifiedSignature;
221
+ }
222
+ interface SimplifiedExample {
223
+ code: string;
224
+ title?: string;
225
+ description?: string;
226
+ language?: string;
227
+ }
228
+ interface SimplifiedExport {
229
+ id: string;
230
+ name: string;
231
+ kind: SpecExportKind;
232
+ signature: string;
233
+ description?: string;
234
+ deprecated: boolean;
235
+ tags: Array<{
236
+ name: string;
237
+ text: string;
238
+ }>;
239
+ parameters?: SimplifiedParameter[];
240
+ returns?: SimplifiedReturn;
241
+ members?: SimplifiedMember[];
242
+ examples?: SimplifiedExample[];
243
+ extends?: string;
244
+ implements?: string[];
245
+ sourceFile?: string;
246
+ sourceLine?: number;
247
+ }
248
+ interface SimplifiedSpec {
249
+ name: string;
250
+ version?: string;
251
+ description?: string;
252
+ exports: SimplifiedExport[];
253
+ byKind: Record<SpecExportKind, SimplifiedExport[]>;
254
+ totalExports: number;
255
+ }
256
+ /**
257
+ * Render spec to simplified JSON structure.
258
+ *
259
+ * @param spec - The OpenPkg spec to simplify
260
+ * @param options - JSON rendering options
261
+ * @returns Simplified spec or single structure
262
+ *
263
+ * @example
264
+ * ```ts
265
+ * import { createDocs } from '@openpkg-ts/doc-generator'
266
+ *
267
+ * const docs = createDocs('./openpkg.json')
268
+ *
269
+ * // Full spec as simplified JSON
270
+ * const json = docs.toJSON()
271
+ * // { name, version, exports: [...], byKind: {...} }
272
+ *
273
+ * // Single * const fnJson = docs.toJSON({ export: 'greet' })
274
+ * // { id, name, kind, signature, parameters, returns, ... }
275
+ * ```
276
+ */
277
+ declare function toJSON2(spec: OpenPkg3, options?: JSONOptions): SimplifiedSpec | SimplifiedExport;
278
+ /**
279
+ * Serialize to JSON string with formatting.
280
+ *
281
+ * @param spec - The OpenPkg spec to serialize
282
+ * @param options - JSON options plus pretty formatting option
283
+ * @returns JSON string
284
+ */
285
+ declare function toJSONString(spec: OpenPkg3, options?: JSONOptions & {
286
+ pretty?: boolean;
287
+ }): string;
288
+ import { OpenPkg as OpenPkg4, SpecExport as SpecExport2 } from "@openpkg-ts/spec";
289
+ interface MarkdownOptions {
290
+ /** Include frontmatter in output */
291
+ frontmatter?: boolean;
292
+ /** Sections to include */
293
+ sections?: {
294
+ signature?: boolean;
295
+ description?: boolean;
296
+ parameters?: boolean;
297
+ returns?: boolean;
298
+ examples?: boolean;
299
+ members?: boolean;
300
+ properties?: boolean;
301
+ methods?: boolean;
302
+ };
303
+ /** Custom frontmatter fields */
304
+ customFrontmatter?: Record<string, unknown>;
305
+ /** Use code fences for signatures */
306
+ codeSignatures?: boolean;
307
+ /** Heading level offset (0 = starts at h1, 1 = starts at h2) */
308
+ headingOffset?: number;
309
+ }
310
+ interface ExportMarkdownOptions extends MarkdownOptions {
311
+ /** Export to render */
312
+ export?: string;
313
+ }
314
+ /**
315
+ * Render a single to MDX.
316
+ *
317
+ * @param exp - The to render
318
+ * @param options - Markdown rendering options
319
+ * @returns MDX string with frontmatter
320
+ *
321
+ * @example
322
+ * ```ts
323
+ * const mdx = exportToMarkdown(fn, {
324
+ * frontmatter: true,
325
+ * codeSignatures: true,
326
+ * sections: { examples: true }
327
+ * })
328
+ * ```
329
+ */
330
+ declare function exportToMarkdown(exp: SpecExport2, options?: MarkdownOptions): string;
331
+ /**
332
+ * Render entire spec to MDX.
333
+ *
334
+ * @param spec - The OpenPkg spec to render
335
+ * @param options - Markdown options, optionally with name for single mode
336
+ * @returns MDX string
337
+ *
338
+ * @example
339
+ * ```ts
340
+ * import { createDocs } from '@openpkg-ts/doc-generator'
341
+ *
342
+ * const docs = createDocs('./openpkg.json')
343
+ *
344
+ * // Full spec
345
+ * const fullMdx = docs.toMarkdown()
346
+ *
347
+ * // Single * const fnMdx = docs.toMarkdown({ export: 'greet' })
348
+ * ```
349
+ */
350
+ declare function toMarkdown2(spec: OpenPkg4, options?: ExportMarkdownOptions): string;
351
+ import { OpenPkg as OpenPkg5, SpecExportKind as SpecExportKind2 } from "@openpkg-ts/spec";
352
+ type NavFormat = "fumadocs" | "docusaurus" | "generic";
353
+ type GroupBy = "kind" | "module" | "tag" | "none";
354
+ interface NavOptions {
355
+ /** Output format */
356
+ format?: NavFormat;
357
+ /** How to group exports */
358
+ groupBy?: GroupBy;
359
+ /** Base path for links */
360
+ basePath?: string;
361
+ /** Custom slug generator */
362
+ slugify?: (name: string) => string;
363
+ /** Include index pages for groups */
364
+ includeGroupIndex?: boolean;
365
+ /** Custom kind labels */
366
+ kindLabels?: Partial<Record<SpecExportKind2, string>>;
367
+ /** Sort exports alphabetically */
368
+ sortAlphabetically?: boolean;
369
+ }
370
+ interface NavItem {
371
+ title: string;
372
+ href?: string;
373
+ items?: NavItem[];
374
+ }
375
+ interface NavGroup {
376
+ title: string;
377
+ items: NavItem[];
378
+ index?: string;
379
+ }
380
+ interface GenericNav {
381
+ title: string;
382
+ groups: NavGroup[];
383
+ items: NavItem[];
384
+ }
385
+ interface FumadocsMetaItem {
386
+ title: string;
387
+ pages?: string[];
388
+ defaultOpen?: boolean;
389
+ }
390
+ interface FumadocsMeta {
391
+ root?: boolean;
392
+ title?: string;
393
+ pages?: (string | FumadocsMetaItem)[];
394
+ }
395
+ interface DocusaurusSidebarItem {
396
+ type: "category" | "doc" | "link";
397
+ label: string;
398
+ items?: DocusaurusSidebarItem[];
399
+ id?: string;
400
+ href?: string;
401
+ }
402
+ type DocusaurusSidebar = DocusaurusSidebarItem[];
403
+ /**
404
+ * Generate navigation structure for doc frameworks.
405
+ *
406
+ * @param spec - The OpenPkg spec
407
+ * @param options - Navigation options including format and grouping
408
+ * @returns Navigation structure in requested format
409
+ *
410
+ * @example
411
+ * ```ts
412
+ * import { createDocs } from '@openpkg-ts/doc-generator'
413
+ *
414
+ * const docs = createDocs('./openpkg.json')
415
+ *
416
+ * // Generic nav
417
+ * const nav = docs.toNavigation({ format: 'generic', groupBy: 'kind' })
418
+ *
419
+ * // Fumadocs meta.json
420
+ * const meta = docs.toNavigation({ format: 'fumadocs' })
421
+ *
422
+ * // Docusaurus sidebar
423
+ * const sidebar = docs.toNavigation({ format: 'docusaurus' })
424
+ * ```
425
+ */
426
+ declare function toNavigation2(spec: OpenPkg5, options?: NavOptions): GenericNav | FumadocsMeta | DocusaurusSidebar;
427
+ /**
428
+ * Generate Fumadocs meta.json file content.
429
+ *
430
+ * @param spec - The OpenPkg spec
431
+ * @param options - Navigation options (format is forced to fumadocs)
432
+ * @returns JSON string for meta.json file
433
+ *
434
+ * @example
435
+ * ```ts
436
+ * const meta = toFumadocsMetaJSON(spec, { groupBy: 'kind' })
437
+ * fs.writeFileSync('docs/api/meta.json', meta)
438
+ * ```
439
+ */
440
+ declare function toFumadocsMetaJSON(spec: OpenPkg5, options?: Omit<NavOptions, "format">): string;
441
+ /**
442
+ * Generate Docusaurus sidebar config.
443
+ *
444
+ * @param spec - The OpenPkg spec
445
+ * @param options - Navigation options (format is forced to docusaurus)
446
+ * @returns JavaScript module.exports string for sidebars.js
447
+ *
448
+ * @example
449
+ * ```ts
450
+ * const sidebar = toDocusaurusSidebarJS(spec, { basePath: 'api' })
451
+ * fs.writeFileSync('sidebars.js', sidebar)
452
+ * ```
453
+ */
454
+ declare function toDocusaurusSidebarJS(spec: OpenPkg5, options?: Omit<NavOptions, "format">): string;
455
+ import { OpenPkg as OpenPkg6, SpecExportKind as SpecExportKind3 } from "@openpkg-ts/spec";
456
+ interface SearchOptions {
457
+ /** Base URL for search result links */
458
+ baseUrl?: string;
459
+ /** Custom slug generator */
460
+ slugify?: (name: string) => string;
461
+ /** Include type signatures in search content */
462
+ includeSignatures?: boolean;
463
+ /** Include member names in search content */
464
+ includeMembers?: boolean;
465
+ /** Include parameter names in search content */
466
+ includeParameters?: boolean;
467
+ /** Weight multipliers for ranking */
468
+ weights?: {
469
+ name?: number;
470
+ description?: number;
471
+ signature?: number;
472
+ tags?: number;
473
+ };
474
+ }
475
+ interface PagefindRecord {
476
+ url: string;
477
+ content: string;
478
+ word_count: number;
479
+ filters: Record<string, string[]>;
480
+ meta: {
481
+ title: string;
482
+ kind?: string;
483
+ description?: string;
484
+ signature?: string;
485
+ };
486
+ anchors?: Array<{
487
+ element: string;
488
+ id: string;
489
+ text: string;
490
+ }>;
491
+ weighted_sections?: Array<{
492
+ weight: number;
493
+ text: string;
494
+ }>;
495
+ }
496
+ interface AlgoliaRecord {
497
+ objectID: string;
498
+ name: string;
499
+ kind: SpecExportKind3;
500
+ description?: string;
501
+ signature: string;
502
+ content: string;
503
+ tags: string[];
504
+ deprecated: boolean;
505
+ url: string;
506
+ hierarchy: {
507
+ lvl0: string;
508
+ lvl1: string;
509
+ lvl2?: string;
510
+ };
511
+ _rankingInfo?: {
512
+ nbTypos: number;
513
+ words: number;
514
+ };
515
+ }
516
+ interface SearchRecord {
517
+ id: string;
518
+ name: string;
519
+ kind: SpecExportKind3;
520
+ signature: string;
521
+ description?: string;
522
+ content: string;
523
+ keywords: string[];
524
+ url: string;
525
+ deprecated: boolean;
526
+ }
527
+ interface SearchIndex {
528
+ records: SearchRecord[];
529
+ version: string;
530
+ generatedAt: string;
531
+ packageName: string;
532
+ }
533
+ /**
534
+ * Generate search index from spec.
535
+ *
536
+ * @param spec - The OpenPkg spec to index
537
+ * @param options - Search index configuration
538
+ * @returns Search index with records for each *
539
+ * @example
540
+ * ```ts
541
+ * import { createDocs } from '@openpkg-ts/doc-generator'
542
+ *
543
+ * const docs = createDocs('./openpkg.json')
544
+ * const index = docs.toSearchIndex({ baseUrl: '/api' })
545
+ * // { records: [...], version: '1.0.0', packageName: 'my-lib' }
546
+ * ```
547
+ */
548
+ declare function toSearchIndex2(spec: OpenPkg6, options?: SearchOptions): SearchIndex;
549
+ /**
550
+ * Generate Pagefind-compatible records.
551
+ *
552
+ * @param spec - The OpenPkg spec to index
553
+ * @param options - Search configuration including weights
554
+ * @returns Array of Pagefind-compatible search records
555
+ *
556
+ * @example
557
+ * ```ts
558
+ * const records = toPagefindRecords(spec, {
559
+ * baseUrl: '/docs/api',
560
+ * weights: { name: 10, description: 5 }
561
+ * })
562
+ * ```
563
+ */
564
+ declare function toPagefindRecords2(spec: OpenPkg6, options?: SearchOptions): PagefindRecord[];
565
+ /**
566
+ * Generate Algolia-compatible records.
567
+ *
568
+ * @param spec - The OpenPkg spec to index
569
+ * @param options - Search configuration
570
+ * @returns Array of Algolia-compatible search records with hierarchy
571
+ *
572
+ * @example
573
+ * ```ts
574
+ * const records = toAlgoliaRecords(spec, { baseUrl: '/api' })
575
+ * // Upload to Algolia index
576
+ * ```
577
+ */
578
+ declare function toAlgoliaRecords2(spec: OpenPkg6, options?: SearchOptions): AlgoliaRecord[];
579
+ /**
580
+ * Serialize search index to JSON string.
581
+ *
582
+ * @param spec - The OpenPkg spec to index
583
+ * @param options - Search options plus pretty formatting option
584
+ * @returns JSON string of search index
585
+ *
586
+ * @example
587
+ * ```ts
588
+ * const json = toSearchIndexJSON(spec, { pretty: true })
589
+ * fs.writeFileSync('search-index.json', json)
590
+ * ```
591
+ */
592
+ declare function toSearchIndexJSON(spec: OpenPkg6, options?: SearchOptions & {
593
+ pretty?: boolean;
594
+ }): string;
595
+ interface LoadOptions {
596
+ /** Path to openpkg.json file or the spec object directly */
597
+ input: string | OpenPkg7;
598
+ }
599
+ interface DocsInstance {
600
+ /** The parsed OpenPkg spec */
601
+ spec: OpenPkg7;
602
+ /** Get an by its ID */
603
+ getExport(id: string): SpecExport3 | undefined;
604
+ /** Get a type definition by its ID */
605
+ getType(id: string): SpecType | undefined;
606
+ /** Get all exports of a specific kind */
607
+ getExportsByKind(kind: SpecExportKind4): SpecExport3[];
608
+ /** Get all exports */
609
+ getAllExports(): SpecExport3[];
610
+ /** Get all type definitions */
611
+ getAllTypes(): SpecType[];
612
+ /** Get exports by JSDoc tag (e.g., '@beta', '@internal') */
613
+ getExportsByTag(tagName: string): SpecExport3[];
614
+ /** Search exports by name or description */
615
+ search(query: string): SpecExport3[];
616
+ /** Get exports belonging to a specific module/namespace */
617
+ getModule(moduleName: string): SpecExport3[];
618
+ /** Get deprecated exports */
619
+ getDeprecated(): SpecExport3[];
620
+ /** Get exports grouped by kind */
621
+ groupByKind(): Record<SpecExportKind4, SpecExport3[]>;
622
+ /** Render spec or single to MDX */
623
+ toMarkdown(options?: ExportMarkdownOptions): string;
624
+ /** Render spec or single to HTML */
625
+ toHTML(options?: HTMLOptions): string;
626
+ /** Render spec or single to JSON structure */
627
+ toJSON(options?: JSONOptions): SimplifiedSpec | SimplifiedExport;
628
+ /** Generate navigation structure */
629
+ toNavigation(options?: NavOptions): GenericNav | FumadocsMeta | DocusaurusSidebar;
630
+ /** Generate search index */
631
+ toSearchIndex(options?: SearchOptions): SearchIndex;
632
+ /** Generate Pagefind-compatible records */
633
+ toPagefindRecords(options?: SearchOptions): PagefindRecord[];
634
+ /** Generate Algolia-compatible records */
635
+ toAlgoliaRecords(options?: SearchOptions): AlgoliaRecord[];
636
+ }
637
+ /**
638
+ * Loads an OpenPkg spec from file or object.
639
+ *
640
+ * @example
641
+ * ```ts
642
+ * import { loadSpec } from '@openpkg-ts/doc-generator'
643
+ *
644
+ * // From spec object
645
+ * import spec from './openpkg.json'
646
+ * const docs = loadSpec(spec)
647
+ * ```
648
+ */
649
+ declare function loadSpec(spec: OpenPkg7): DocsInstance;
650
+ /**
651
+ * Creates a docs instance for querying and rendering API documentation.
652
+ *
653
+ * @example
654
+ * ```ts
655
+ * import { createDocs } from '@openpkg-ts/doc-generator'
656
+ *
657
+ * // From file path
658
+ * const docs = createDocs('./openpkg.json')
659
+ *
660
+ * // From spec object
661
+ * import spec from './openpkg.json'
662
+ * const docs = createDocs(spec)
663
+ *
664
+ * // Query
665
+ * docs.getExport('useState')
666
+ * docs.getExportsByKind('function')
667
+ * docs.getExportsByTag('@beta')
668
+ * docs.search('hook')
669
+ * ```
670
+ */
671
+ declare function createDocs(input: string | OpenPkg7): DocsInstance;
672
+ import { OpenPkg as OpenPkg8, SpecExport as SpecExport4, SpecMember, SpecSchema, SpecSignature, SpecType as SpecType2, SpecTypeParameter } from "@openpkg-ts/spec";
673
+ /**
674
+ * Format a schema to a human-readable type string.
675
+ *
676
+ * @param schema - The schema to format
677
+ * @returns Formatted type string
678
+ *
679
+ * @example
680
+ * ```ts
681
+ * formatSchema({ type: 'string' }) // 'string'
682
+ * formatSchema({ $ref: '#/types/User' }) // 'User'
683
+ * formatSchema({ anyOf: [{ type: 'string' }, { type: 'number' }] }) // 'string | number'
684
+ * ```
685
+ */
686
+ declare function formatSchema(schema: SpecSchema | undefined): string;
687
+ /**
688
+ * Format type parameters to a string like `<T, U extends string>`.
689
+ *
690
+ * @param typeParams - Array of type parameters
691
+ * @returns Formatted type parameters string or empty string
692
+ *
693
+ * @example
694
+ * ```ts
695
+ * formatTypeParameters([{ name: 'T' }]) // '<T>'
696
+ * formatTypeParameters([{ name: 'T', constraint: 'object' }]) // '<T extends object>'
697
+ * formatTypeParameters([{ name: 'T', default: 'unknown' }]) // '<T = unknown>'
698
+ * ```
699
+ */
700
+ declare function formatTypeParameters(typeParams?: SpecTypeParameter[]): string;
701
+ /**
702
+ * Format function parameters to a string like `(a: string, b?: number)`.
703
+ *
704
+ * @param sig - The signature containing parameters
705
+ * @returns Formatted parameters string
706
+ *
707
+ * @example
708
+ * ```ts
709
+ * formatParameters({ parameters: [{ name: 'id', schema: { type: 'string' } }] })
710
+ * // '(id: string)'
711
+ * ```
712
+ */
713
+ declare function formatParameters(sig?: SpecSignature): string;
714
+ /**
715
+ * Format return type from signature.
716
+ *
717
+ * @param sig - The signature containing return type
718
+ * @returns Formatted return type string
719
+ *
720
+ * @example
721
+ * ```ts
722
+ * formatReturnType({ returns: { schema: { type: 'Promise', items: { type: 'string' } } } })
723
+ * // 'Promise<string>'
724
+ * ```
725
+ */
726
+ declare function formatReturnType(sig?: SpecSignature): string;
727
+ /**
728
+ * Build a full signature string for an export.
729
+ *
730
+ * @param exp - The to build a signature for
731
+ * @param sigIndex - Index of signature to use for overloaded functions
732
+ * @returns Complete signature string
733
+ *
734
+ * @example
735
+ * ```ts
736
+ * buildSignatureString({ kind: 'function', name: 'greet', signatures: [...] })
737
+ * // 'function greet(name: string): string'
738
+ *
739
+ * buildSignatureString({ kind: 'class', name: 'Logger', extends: 'EventEmitter' })
740
+ * // 'class Logger extends EventEmitter'
741
+ * ```
742
+ */
743
+ declare function buildSignatureString(exp: SpecExport4, sigIndex?: number): string;
744
+ /**
745
+ * Resolve a type reference to its definition.
746
+ *
747
+ * @param ref - Type reference string (e.g., '#/types/User')
748
+ * @param spec - The OpenPkg spec containing type definitions
749
+ * @returns The resolved type definition or undefined
750
+ *
751
+ * @example
752
+ * ```ts
753
+ * resolveTypeRef('#/types/User', spec)
754
+ * // { id: 'User', name: 'User', kind: 'interface', ... }
755
+ * ```
756
+ */
757
+ declare function resolveTypeRef(ref: string, spec: OpenPkg8): SpecType2 | undefined;
758
+ /**
759
+ * Check if a member is a method (has signatures).
760
+ *
761
+ * @param member - The member to check
762
+ * @returns True if the member is a method
763
+ *
764
+ * @example
765
+ * ```ts
766
+ * isMethod({ name: 'foo', signatures: [{ parameters: [] }] }) // true
767
+ * isMethod({ name: 'bar', schema: { type: 'string' } }) // false
768
+ * ```
769
+ */
770
+ declare function isMethod(member: SpecMember): boolean;
771
+ /**
772
+ * Check if a member is a property (no signatures).
773
+ *
774
+ * @param member - The member to check
775
+ * @returns True if the member is a property
776
+ */
777
+ declare function isProperty(member: SpecMember): boolean;
778
+ /**
779
+ * Get methods from members list.
780
+ *
781
+ * @param members - Array of members to filter
782
+ * @returns Array of method members
783
+ */
784
+ declare function getMethods(members?: SpecMember[]): SpecMember[];
785
+ /**
786
+ * Get properties from members list.
787
+ *
788
+ * @param members - Array of members to filter
789
+ * @returns Array of property members
790
+ */
791
+ declare function getProperties(members?: SpecMember[]): SpecMember[];
792
+ /**
793
+ * Group members by visibility (public, protected, private).
794
+ *
795
+ * @param members - Array of members to group
796
+ * @returns Object with public, protected, and private arrays
797
+ *
798
+ * @example
799
+ * ```ts
800
+ * const groups = groupByVisibility(classExport.members)
801
+ * groups.public // [{ name: 'foo', visibility: 'public' }]
802
+ * groups.private // [{ name: 'bar', visibility: 'private' }]
803
+ * ```
804
+ */
805
+ declare function groupByVisibility(members?: SpecMember[]): {
806
+ public: SpecMember[];
807
+ protected: SpecMember[];
808
+ private: SpecMember[];
809
+ };
810
+ /**
811
+ * Sort exports alphabetically by name.
812
+ *
813
+ * @param items - Array of items with a name property
814
+ * @returns New sorted array
815
+ */
816
+ declare function sortByName<T extends {
817
+ name: string;
818
+ }>(items: T[]): T[];
819
+ /**
820
+ * Sort exports by kind, then name.
821
+ * Kind order: function, class, interface, type, enum, variable, namespace, module, reference, external.
822
+ *
823
+ * @param exports - Array of exports to sort
824
+ * @returns New sorted array
825
+ */
826
+ declare function sortByKindThenName(exports: SpecExport4[]): SpecExport4[];
827
+ export { toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toPagefindRecords2 as toPagefindRecords, toNavigation2 as toNavigation, toMarkdown2 as toMarkdown, toJSONString, toJSON2 as toJSON, toHTML2 as toHTML, toFumadocsMetaJSON, toDocusaurusSidebarJS, toAlgoliaRecords2 as toAlgoliaRecords, sortByName, sortByKindThenName, resolveTypeRef, loadSpec, isProperty, isMethod, groupByVisibility, getProperties, getMethods, formatTypeParameters, formatSchema, formatReturnType, formatParameters, exportToMarkdown, createDocs, createAdapterRegistry, buildSignatureString, adapterRegistry, SpecTypeParameter2 as SpecTypeParameter, SpecTypeKind, SpecType3 as SpecType, SpecTag, SpecSignatureParameter, SpecSignature2 as SpecSignature, SpecSchema2 as SpecSchema, SpecMember2 as SpecMember, SpecExportKind5 as SpecExportKind, SpecExport5 as SpecExport, SpecExample, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SearchRecord, SearchOptions, SearchIndex, SearchGeneratorOptions, PagefindRecord, PageGeneratorOptions, OpenPkg9 as OpenPkg, NavOptions, NavItem, NavGroup, NavGeneratorOptions, NavFormat, MarkdownOptions, LoadOptions, JSONOptions, HTMLOptions, GroupBy, GenericNav, GeneratedFile, FumadocsMetaItem, FumadocsMeta, FileGenerator, ExportPageProps, ExportMarkdownOptions, DocusaurusSidebarItem, DocusaurusSidebar, DocsInstance, DocFrameworkAdapter, ConfigValidationResult, ConfigOptions, ConfigHelper, AlgoliaRecord, AdapterRegistry, AdapterComponents, APIPageComponentProps };