@openpkg-ts/fumadocs-adapter 0.2.1 → 0.2.3
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/package.json +15 -3
- package/CHANGELOG.md +0 -45
- package/bunup.config.ts +0 -9
- package/examples/01-basic-usage.ts +0 -103
- package/src/components/coverage-badge.tsx +0 -110
- package/src/components/index.ts +0 -42
- package/src/index.ts +0 -83
- package/tsconfig.json +0 -20
package/package.json
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpkg-ts/fumadocs-adapter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Fumadocs integration for OpenPkg API documentation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
7
9
|
"exports": {
|
|
8
|
-
".":
|
|
9
|
-
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./components": {
|
|
15
|
+
"import": "./dist/components/index.js",
|
|
16
|
+
"types": "./dist/components/index.d.ts"
|
|
17
|
+
},
|
|
10
18
|
"./css": "./src/styles/docskit.css"
|
|
11
19
|
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"src/styles"
|
|
23
|
+
],
|
|
12
24
|
"scripts": {
|
|
13
25
|
"build": "bunup",
|
|
14
26
|
"lint": "biome check src/",
|
package/CHANGELOG.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# @openpkg-ts/fumadocs-adapter
|
|
2
|
-
|
|
3
|
-
## 0.2.1
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- version bump for republish
|
|
8
|
-
|
|
9
|
-
## 0.2.0
|
|
10
|
-
|
|
11
|
-
### Minor Changes
|
|
12
|
-
|
|
13
|
-
- Rename package from @doccov/fumadocs-adapter to @openpkg-ts/fumadocs-adapter
|
|
14
|
-
|
|
15
|
-
## 0.1.0
|
|
16
|
-
|
|
17
|
-
### Minor Changes
|
|
18
|
-
|
|
19
|
-
- Initial release of @openpkg-ts/doc-generator
|
|
20
|
-
|
|
21
|
-
- Core API: createDocs(), loadSpec() for loading OpenPkg specs
|
|
22
|
-
- Query utilities: formatSchema(), buildSignatureString(), member filtering and sorting
|
|
23
|
-
- Renderers: Markdown/MDX, HTML, JSON output formats
|
|
24
|
-
- Navigation: Fumadocs, Docusaurus, and generic nav generation
|
|
25
|
-
- Search: Pagefind and Algolia compatible indexes
|
|
26
|
-
- React components: Headless (unstyled) and styled (Tailwind v4) variants
|
|
27
|
-
- CLI: generate, build, dev commands
|
|
28
|
-
- Adapter architecture: Extensible framework integration pattern
|
|
29
|
-
|
|
30
|
-
### Patch Changes
|
|
31
|
-
|
|
32
|
-
- Updated dependencies
|
|
33
|
-
- @openpkg-ts/doc-generator@0.1.0
|
|
34
|
-
|
|
35
|
-
## 0.0.3
|
|
36
|
-
|
|
37
|
-
### Patch Changes
|
|
38
|
-
|
|
39
|
-
- Remove deprecated `tsType` field in favor of `schema`, add CLI warning when `--runtime` requested without built code
|
|
40
|
-
|
|
41
|
-
## 0.0.2
|
|
42
|
-
|
|
43
|
-
### Patch Changes
|
|
44
|
-
|
|
45
|
-
- update components and configuration
|
package/bunup.config.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example: Fumadocs Adapter Basic Usage
|
|
3
|
-
*
|
|
4
|
-
* Run from fumadocs-adapter: bun examples/01-basic-usage.ts
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
buildSignatureString,
|
|
9
|
-
// Core API (re-exported from doc-generator)
|
|
10
|
-
createDocs,
|
|
11
|
-
createOpenPkg, // backward compat alias
|
|
12
|
-
// Query utilities
|
|
13
|
-
formatSchema,
|
|
14
|
-
getMethods,
|
|
15
|
-
getProperties,
|
|
16
|
-
toFumadocsMetaJSON,
|
|
17
|
-
// Render utilities
|
|
18
|
-
toMarkdown,
|
|
19
|
-
toNavigation,
|
|
20
|
-
// Search
|
|
21
|
-
toSearchIndex,
|
|
22
|
-
} from '../src/index';
|
|
23
|
-
|
|
24
|
-
// Sample spec for testing
|
|
25
|
-
const sampleSpec = {
|
|
26
|
-
openpkg: '0.4.0',
|
|
27
|
-
meta: {
|
|
28
|
-
ecosystem: 'js/ts',
|
|
29
|
-
name: 'test-package',
|
|
30
|
-
version: '1.0.0',
|
|
31
|
-
},
|
|
32
|
-
exports: [
|
|
33
|
-
{
|
|
34
|
-
id: 'hello',
|
|
35
|
-
name: 'hello',
|
|
36
|
-
kind: 'function',
|
|
37
|
-
description: 'Say hello',
|
|
38
|
-
signatures: [
|
|
39
|
-
{
|
|
40
|
-
parameters: [{ name: 'name', required: true, schema: { type: 'string' } }],
|
|
41
|
-
returns: { schema: { type: 'string' } },
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: 'Config',
|
|
47
|
-
name: 'Config',
|
|
48
|
-
kind: 'interface',
|
|
49
|
-
description: 'Configuration interface',
|
|
50
|
-
members: [
|
|
51
|
-
{ name: 'debug', kind: 'property', schema: { type: 'boolean' }, optional: true },
|
|
52
|
-
{ name: 'timeout', kind: 'property', schema: { type: 'number' } },
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
types: [],
|
|
57
|
-
} as any;
|
|
58
|
-
|
|
59
|
-
console.log('=== Fumadocs Adapter Usage ===\n');
|
|
60
|
-
|
|
61
|
-
// Use createDocs (preferred)
|
|
62
|
-
const docs = createDocs(sampleSpec);
|
|
63
|
-
console.log('Package:', docs.spec.meta.name);
|
|
64
|
-
console.log('Exports:', docs.getAllExports().length);
|
|
65
|
-
|
|
66
|
-
// Or use createOpenPkg (backward compat)
|
|
67
|
-
const openpkg = createOpenPkg(sampleSpec);
|
|
68
|
-
console.log('\nUsing createOpenPkg (backward compat):');
|
|
69
|
-
console.log('Same API:', openpkg.spec.meta.name);
|
|
70
|
-
|
|
71
|
-
// Query
|
|
72
|
-
console.log('\n--- Query ---');
|
|
73
|
-
const hello = docs.getExport('hello');
|
|
74
|
-
if (hello) {
|
|
75
|
-
console.log('Signature:', buildSignatureString(hello));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const config = docs.getExport('Config');
|
|
79
|
-
if (config?.members) {
|
|
80
|
-
console.log(
|
|
81
|
-
'Config properties:',
|
|
82
|
-
getProperties(config.members)
|
|
83
|
-
.map((p) => p.name)
|
|
84
|
-
.join(', '),
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Render
|
|
89
|
-
console.log('\n--- Render ---');
|
|
90
|
-
const md = docs.toMarkdown({ export: 'hello' });
|
|
91
|
-
console.log('Markdown:\n', md);
|
|
92
|
-
|
|
93
|
-
// Navigation for Fumadocs
|
|
94
|
-
console.log('\n--- Fumadocs Navigation ---');
|
|
95
|
-
const meta = toFumadocsMetaJSON(sampleSpec, { basePath: '/api' });
|
|
96
|
-
console.log(meta);
|
|
97
|
-
|
|
98
|
-
// Search index
|
|
99
|
-
console.log('\n--- Search Index ---');
|
|
100
|
-
const searchIndex = toSearchIndex(sampleSpec);
|
|
101
|
-
console.log('Records:', searchIndex.records.length);
|
|
102
|
-
|
|
103
|
-
console.log('\n=== Done ===');
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Documentation drift information.
|
|
5
|
-
* Describes a mismatch between docs and code.
|
|
6
|
-
*/
|
|
7
|
-
export interface DocDrift {
|
|
8
|
-
type: string;
|
|
9
|
-
issue: string;
|
|
10
|
-
suggestion?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Documentation metadata for an export.
|
|
15
|
-
* Contains coverage score, missing docs, and drift issues.
|
|
16
|
-
*/
|
|
17
|
-
export interface DocsMetadata {
|
|
18
|
-
coverageScore?: number;
|
|
19
|
-
missing?: string[];
|
|
20
|
-
drift?: DocDrift[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface CoverageBadgeProps {
|
|
24
|
-
docs: DocsMetadata;
|
|
25
|
-
showMissing?: boolean;
|
|
26
|
-
showDrift?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function getScoreColor(score: number): string {
|
|
30
|
-
if (score >= 80) return 'text-green-600 dark:text-green-400 bg-green-500/10 border-green-500/20';
|
|
31
|
-
if (score >= 60)
|
|
32
|
-
return 'text-yellow-600 dark:text-yellow-400 bg-yellow-500/10 border-yellow-500/20';
|
|
33
|
-
return 'text-red-600 dark:text-red-400 bg-red-500/10 border-red-500/20';
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function formatSignal(signal: string): string {
|
|
37
|
-
return signal.charAt(0).toUpperCase() + signal.slice(1);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function CoverageBadge({
|
|
41
|
-
docs,
|
|
42
|
-
showMissing = true,
|
|
43
|
-
showDrift = true,
|
|
44
|
-
}: CoverageBadgeProps): React.ReactNode {
|
|
45
|
-
const score = docs.coverageScore;
|
|
46
|
-
const hasMissing = showMissing && docs.missing && docs.missing.length > 0;
|
|
47
|
-
const hasDrift = showDrift && docs.drift && docs.drift.length > 0;
|
|
48
|
-
|
|
49
|
-
if (score == null && !hasMissing && !hasDrift) return null;
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<div className="my-6 space-y-3">
|
|
53
|
-
{score != null && (
|
|
54
|
-
<div
|
|
55
|
-
className={`inline-flex items-center gap-2 px-3 py-1.5 rounded-md border text-sm font-medium ${getScoreColor(score)}`}
|
|
56
|
-
>
|
|
57
|
-
<svg
|
|
58
|
-
className="w-4 h-4"
|
|
59
|
-
fill="none"
|
|
60
|
-
stroke="currentColor"
|
|
61
|
-
viewBox="0 0 24 24"
|
|
62
|
-
aria-hidden="true"
|
|
63
|
-
>
|
|
64
|
-
<path
|
|
65
|
-
strokeLinecap="round"
|
|
66
|
-
strokeLinejoin="round"
|
|
67
|
-
strokeWidth={2}
|
|
68
|
-
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
69
|
-
/>
|
|
70
|
-
</svg>
|
|
71
|
-
Coverage: {score}%
|
|
72
|
-
</div>
|
|
73
|
-
)}
|
|
74
|
-
|
|
75
|
-
{hasMissing && (
|
|
76
|
-
<div className="rounded-md bg-yellow-500/10 border border-yellow-500/20 px-3 py-2">
|
|
77
|
-
<p className="text-sm font-medium text-yellow-600 dark:text-yellow-400 mb-1">
|
|
78
|
-
Missing Documentation
|
|
79
|
-
</p>
|
|
80
|
-
<ul className="text-sm text-yellow-600/80 dark:text-yellow-400/80 list-disc list-inside">
|
|
81
|
-
{docs.missing!.map((signal) => (
|
|
82
|
-
<li key={signal}>{formatSignal(signal)}</li>
|
|
83
|
-
))}
|
|
84
|
-
</ul>
|
|
85
|
-
</div>
|
|
86
|
-
)}
|
|
87
|
-
|
|
88
|
-
{hasDrift && (
|
|
89
|
-
<div className="rounded-md bg-red-500/10 border border-red-500/20 px-3 py-2">
|
|
90
|
-
<p className="text-sm font-medium text-red-600 dark:text-red-400 mb-1">
|
|
91
|
-
Documentation Drift
|
|
92
|
-
</p>
|
|
93
|
-
<ul className="text-sm text-red-600/80 dark:text-red-400/80 space-y-1">
|
|
94
|
-
{docs.drift!.map((drift) => (
|
|
95
|
-
<li key={`${drift.type}-${drift.issue}`} className="flex flex-col">
|
|
96
|
-
<span className="font-medium">{drift.type}</span>
|
|
97
|
-
<span className="text-xs opacity-80">{drift.issue}</span>
|
|
98
|
-
{drift.suggestion && (
|
|
99
|
-
<span className="text-xs text-fd-muted-foreground mt-0.5">
|
|
100
|
-
Suggestion: {drift.suggestion}
|
|
101
|
-
</span>
|
|
102
|
-
)}
|
|
103
|
-
</li>
|
|
104
|
-
))}
|
|
105
|
-
</ul>
|
|
106
|
-
</div>
|
|
107
|
-
)}
|
|
108
|
-
</div>
|
|
109
|
-
);
|
|
110
|
-
}
|
package/src/components/index.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// CoverageBadge is doccov-specific, stays in fumadocs-adapter
|
|
2
|
-
|
|
3
|
-
// Re-export headless components from doc-generator
|
|
4
|
-
export {
|
|
5
|
-
CollapsibleMethod,
|
|
6
|
-
type CollapsibleMethodProps,
|
|
7
|
-
ExampleBlock,
|
|
8
|
-
type ExampleBlockProps,
|
|
9
|
-
ExpandableProperty,
|
|
10
|
-
type ExpandablePropertyProps,
|
|
11
|
-
MemberRow,
|
|
12
|
-
type MemberRowProps,
|
|
13
|
-
MembersTable,
|
|
14
|
-
type MembersTableProps,
|
|
15
|
-
NestedProperty,
|
|
16
|
-
type NestedPropertyProps,
|
|
17
|
-
ParamRow,
|
|
18
|
-
type ParamRowProps,
|
|
19
|
-
ParamTable,
|
|
20
|
-
type ParamTableProps,
|
|
21
|
-
Signature,
|
|
22
|
-
type SignatureProps,
|
|
23
|
-
TypeTable,
|
|
24
|
-
type TypeTableProps,
|
|
25
|
-
} from '@openpkg-ts/doc-generator/react';
|
|
26
|
-
// Re-export all styled components from doc-generator
|
|
27
|
-
export {
|
|
28
|
-
APIPage,
|
|
29
|
-
type APIPageProps,
|
|
30
|
-
ClassPage,
|
|
31
|
-
type ClassPageProps,
|
|
32
|
-
EnumPage,
|
|
33
|
-
type EnumPageProps,
|
|
34
|
-
FunctionPage,
|
|
35
|
-
type FunctionPageProps,
|
|
36
|
-
InterfacePage,
|
|
37
|
-
type InterfacePageProps,
|
|
38
|
-
VariablePage,
|
|
39
|
-
type VariablePageProps,
|
|
40
|
-
} from '@openpkg-ts/doc-generator/react/styled';
|
|
41
|
-
export type { CoverageBadgeProps, DocDrift, DocsMetadata } from './coverage-badge';
|
|
42
|
-
export { CoverageBadge } from './coverage-badge';
|
package/src/index.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// Re-export core from @openpkg-ts/doc-generator
|
|
2
|
-
|
|
3
|
-
// Re-export spec types for convenience
|
|
4
|
-
export type {
|
|
5
|
-
DocsInstance as OpenPkgInstance,
|
|
6
|
-
LoadOptions as OpenPkgOptions,
|
|
7
|
-
OpenPkg,
|
|
8
|
-
SpecExample,
|
|
9
|
-
SpecExport,
|
|
10
|
-
SpecExportKind,
|
|
11
|
-
SpecMember,
|
|
12
|
-
SpecSchema,
|
|
13
|
-
SpecSignature,
|
|
14
|
-
SpecSignatureParameter,
|
|
15
|
-
SpecTag,
|
|
16
|
-
SpecType,
|
|
17
|
-
SpecTypeKind,
|
|
18
|
-
SpecTypeParameter,
|
|
19
|
-
} from '@openpkg-ts/doc-generator';
|
|
20
|
-
export {
|
|
21
|
-
type AlgoliaRecord,
|
|
22
|
-
buildSignatureString,
|
|
23
|
-
createDocs,
|
|
24
|
-
createDocs as createOpenPkg,
|
|
25
|
-
type DocsInstance,
|
|
26
|
-
type ExportMarkdownOptions,
|
|
27
|
-
exportToMarkdown,
|
|
28
|
-
formatParameters,
|
|
29
|
-
formatReturnType,
|
|
30
|
-
formatSchema,
|
|
31
|
-
formatTypeParameters,
|
|
32
|
-
getMethods,
|
|
33
|
-
getProperties,
|
|
34
|
-
groupByVisibility,
|
|
35
|
-
type HTMLOptions,
|
|
36
|
-
isMethod,
|
|
37
|
-
isProperty,
|
|
38
|
-
type JSONOptions,
|
|
39
|
-
type LoadOptions,
|
|
40
|
-
loadSpec,
|
|
41
|
-
type MarkdownOptions,
|
|
42
|
-
type NavOptions,
|
|
43
|
-
type PagefindRecord,
|
|
44
|
-
resolveTypeRef,
|
|
45
|
-
type SearchIndex,
|
|
46
|
-
type SearchOptions,
|
|
47
|
-
type SearchRecord,
|
|
48
|
-
sortByKindThenName,
|
|
49
|
-
sortByName,
|
|
50
|
-
toAlgoliaRecords,
|
|
51
|
-
toDocusaurusSidebarJS,
|
|
52
|
-
toFumadocsMetaJSON,
|
|
53
|
-
toHTML,
|
|
54
|
-
toJSON,
|
|
55
|
-
toJSONString,
|
|
56
|
-
toMarkdown,
|
|
57
|
-
toNavigation,
|
|
58
|
-
toPagefindRecords,
|
|
59
|
-
toSearchIndex,
|
|
60
|
-
toSearchIndexJSON,
|
|
61
|
-
} from '@openpkg-ts/doc-generator';
|
|
62
|
-
// Re-export styled components (most common use case)
|
|
63
|
-
export {
|
|
64
|
-
APIPage,
|
|
65
|
-
type APIPageProps,
|
|
66
|
-
ClassPage,
|
|
67
|
-
type ClassPageProps,
|
|
68
|
-
EnumPage,
|
|
69
|
-
type EnumPageProps,
|
|
70
|
-
FunctionPage,
|
|
71
|
-
type FunctionPageProps,
|
|
72
|
-
InterfacePage,
|
|
73
|
-
type InterfacePageProps,
|
|
74
|
-
VariablePage,
|
|
75
|
-
type VariablePageProps,
|
|
76
|
-
} from '@openpkg-ts/doc-generator/react/styled';
|
|
77
|
-
// Re-export CoverageBadge (doccov-specific)
|
|
78
|
-
export {
|
|
79
|
-
CoverageBadge,
|
|
80
|
-
type CoverageBadgeProps,
|
|
81
|
-
type DocDrift,
|
|
82
|
-
type DocsMetadata,
|
|
83
|
-
} from './components/coverage-badge';
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"lib": ["ES2022", "DOM"],
|
|
7
|
-
"jsx": "react-jsx",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"declaration": true,
|
|
13
|
-
"declarationMap": true,
|
|
14
|
-
"outDir": "./dist",
|
|
15
|
-
"rootDir": "./src",
|
|
16
|
-
"resolveJsonModule": true
|
|
17
|
-
},
|
|
18
|
-
"include": ["src/**/*"],
|
|
19
|
-
"exclude": ["node_modules", "dist"]
|
|
20
|
-
}
|