@doccov/fumadocs-adapter 0.0.1 → 0.0.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/CHANGELOG.md +13 -0
- package/bunup.config.ts +0 -1
- package/dist/components/index.d.ts +76 -76
- package/dist/components/index.js +11 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/shared/{chunk-pqaj3kdh.js → chunk-edfpjshy.js} +633 -632
- package/package.json +1 -2
- package/src/components/api-page.tsx +4 -10
- package/src/components/class-page.tsx +4 -10
- package/src/components/code-example.tsx +6 -2
- package/src/components/collapsible-method.tsx +12 -24
- package/src/components/coverage-badge.tsx +19 -7
- package/src/components/enum-page.tsx +13 -7
- package/src/components/examples.tsx +17 -6
- package/src/components/expandable-property.tsx +14 -17
- package/src/components/function-page.tsx +9 -12
- package/src/components/index.ts +29 -44
- package/src/components/interface-page.tsx +19 -8
- package/src/components/members-section.tsx +12 -10
- package/src/components/method-section.tsx +4 -1
- package/src/components/parameter-card.tsx +3 -8
- package/src/components/signature.tsx +1 -3
- package/src/components/type-table.tsx +7 -12
- package/src/components/variable-page.tsx +3 -9
- package/src/index.ts +3 -4
- package/src/server.ts +0 -1
- package/src/styles/docskit.css +8 -7
- package/tsconfig.json +0 -1
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import type { OpenPkg, SpecExport } from '@openpkg-ts/spec';
|
|
4
|
+
import { CoverageBadge } from './coverage-badge';
|
|
5
|
+
import { ExamplesSection } from './examples';
|
|
4
6
|
import { Signature } from './signature';
|
|
5
7
|
import { TypeTable } from './type-table';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
function formatSchema(schema: unknown): string {
|
|
10
|
+
if (!schema) return 'unknown';
|
|
11
|
+
if (typeof schema === 'string') return schema;
|
|
12
|
+
if (typeof schema === 'object' && schema !== null) {
|
|
13
|
+
const s = schema as Record<string, unknown>;
|
|
14
|
+
if (s.$ref && typeof s.$ref === 'string') {
|
|
15
|
+
return s.$ref.replace('#/types/', '');
|
|
16
|
+
}
|
|
17
|
+
if (s.type) return String(s.type);
|
|
18
|
+
}
|
|
19
|
+
return 'unknown';
|
|
20
|
+
}
|
|
8
21
|
|
|
9
22
|
export interface InterfacePageProps {
|
|
10
23
|
export: SpecExport;
|
|
11
24
|
spec: OpenPkg;
|
|
12
25
|
}
|
|
13
26
|
|
|
14
|
-
export function InterfacePage({ export: exp, spec }: InterfacePageProps) {
|
|
27
|
+
export function InterfacePage({ export: exp, spec }: InterfacePageProps): React.ReactNode {
|
|
15
28
|
// For interfaces/types, members are the properties
|
|
16
29
|
const properties = exp.members?.filter(
|
|
17
|
-
(m) => m.kind === 'property' || m.kind === 'field' || !m.kind
|
|
30
|
+
(m) => m.kind === 'property' || m.kind === 'field' || !m.kind,
|
|
18
31
|
);
|
|
19
32
|
const methods = exp.members?.filter((m) => m.kind === 'method' || m.kind === 'function');
|
|
20
33
|
|
|
@@ -57,7 +70,7 @@ export function InterfacePage({ export: exp, spec }: InterfacePageProps) {
|
|
|
57
70
|
{methods.map((method, index) => {
|
|
58
71
|
const sig = method.signatures?.[0];
|
|
59
72
|
const params = sig?.parameters ?? [];
|
|
60
|
-
const returnType = sig?.returns?.
|
|
73
|
+
const returnType = formatSchema(sig?.returns?.schema);
|
|
61
74
|
|
|
62
75
|
return (
|
|
63
76
|
<div key={method.name ?? index} className="rounded-lg border border-fd-border p-4">
|
|
@@ -66,8 +79,7 @@ export function InterfacePage({ export: exp, spec }: InterfacePageProps) {
|
|
|
66
79
|
{params
|
|
67
80
|
.map((p) => {
|
|
68
81
|
const optional = p.required === false ? '?' : '';
|
|
69
|
-
const type =
|
|
70
|
-
typeof p.schema === 'string' ? p.schema : (p.schema as any)?.tsType ?? 'any';
|
|
82
|
+
const type = formatSchema(p.schema);
|
|
71
83
|
return `${p.name}${optional}: ${type}`;
|
|
72
84
|
})
|
|
73
85
|
.join(', ')}
|
|
@@ -91,4 +103,3 @@ export function InterfacePage({ export: exp, spec }: InterfacePageProps) {
|
|
|
91
103
|
</div>
|
|
92
104
|
);
|
|
93
105
|
}
|
|
94
|
-
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
4
|
-
import { TypeTable } from './type-table';
|
|
3
|
+
import type { OpenPkg, SpecMember } from '@openpkg-ts/spec';
|
|
5
4
|
|
|
6
5
|
export interface MembersSectionProps {
|
|
7
6
|
members: SpecMember[];
|
|
@@ -17,7 +16,6 @@ function formatSchema(schema: unknown): string {
|
|
|
17
16
|
if (s.$ref && typeof s.$ref === 'string') {
|
|
18
17
|
return s.$ref.replace('#/types/', '');
|
|
19
18
|
}
|
|
20
|
-
if (s.tsType) return String(s.tsType);
|
|
21
19
|
if (s.type) return String(s.type);
|
|
22
20
|
}
|
|
23
21
|
return 'unknown';
|
|
@@ -76,11 +74,12 @@ function MemberRow({ member }: { member: SpecMember }) {
|
|
|
76
74
|
const sig = member.signatures?.[0];
|
|
77
75
|
let signature = '';
|
|
78
76
|
if (sig) {
|
|
79
|
-
const params =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
const params =
|
|
78
|
+
sig.parameters?.map((p) => {
|
|
79
|
+
const optional = p.required === false ? '?' : '';
|
|
80
|
+
return `${p.name}${optional}: ${formatSchema(p.schema)}`;
|
|
81
|
+
}) ?? [];
|
|
82
|
+
const returnType = formatSchema(sig.returns?.schema) ?? 'void';
|
|
84
83
|
signature = `(${params.join(', ')}): ${returnType}`;
|
|
85
84
|
}
|
|
86
85
|
|
|
@@ -114,7 +113,11 @@ function MemberRow({ member }: { member: SpecMember }) {
|
|
|
114
113
|
);
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
export function MembersSection({
|
|
116
|
+
export function MembersSection({
|
|
117
|
+
members,
|
|
118
|
+
spec: _spec,
|
|
119
|
+
title = 'Members',
|
|
120
|
+
}: MembersSectionProps): React.ReactNode {
|
|
118
121
|
if (!members?.length) return null;
|
|
119
122
|
|
|
120
123
|
const groups = groupMembersByKind(members);
|
|
@@ -190,4 +193,3 @@ export function MembersSection({ members, spec, title = 'Members' }: MembersSect
|
|
|
190
193
|
</div>
|
|
191
194
|
);
|
|
192
195
|
}
|
|
193
|
-
|
|
@@ -13,6 +13,9 @@ export interface MethodSectionProps {
|
|
|
13
13
|
* Method display section with collapsible behavior
|
|
14
14
|
* @deprecated Use CollapsibleMethod directly for more control
|
|
15
15
|
*/
|
|
16
|
-
export function MethodSection({
|
|
16
|
+
export function MethodSection({
|
|
17
|
+
member,
|
|
18
|
+
defaultExpanded = false,
|
|
19
|
+
}: MethodSectionProps): React.ReactNode {
|
|
17
20
|
return <CollapsibleMethod member={member} defaultExpanded={defaultExpanded} />;
|
|
18
21
|
}
|
|
@@ -15,13 +15,12 @@ function formatSchema(schema: unknown): string {
|
|
|
15
15
|
if (s.$ref && typeof s.$ref === 'string') {
|
|
16
16
|
return s.$ref.replace('#/types/', '');
|
|
17
17
|
}
|
|
18
|
-
if (s.tsType) return String(s.tsType);
|
|
19
18
|
if (s.type) return String(s.type);
|
|
20
19
|
}
|
|
21
20
|
return 'unknown';
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
export function ParameterCard({ param, spec }: ParameterCardProps) {
|
|
23
|
+
export function ParameterCard({ param, spec: _spec }: ParameterCardProps): React.ReactNode {
|
|
25
24
|
const type = formatSchema(param.schema);
|
|
26
25
|
const isRequired = param.required !== false;
|
|
27
26
|
|
|
@@ -38,15 +37,11 @@ export function ParameterCard({ param, spec }: ParameterCardProps) {
|
|
|
38
37
|
</div>
|
|
39
38
|
|
|
40
39
|
{/* Type */}
|
|
41
|
-
<div className="text-sm text-fd-muted-foreground font-mono">
|
|
42
|
-
{type}
|
|
43
|
-
</div>
|
|
40
|
+
<div className="text-sm text-fd-muted-foreground font-mono">{type}</div>
|
|
44
41
|
|
|
45
42
|
{/* Description */}
|
|
46
43
|
{param.description && (
|
|
47
|
-
<p className="text-sm text-fd-muted-foreground mt-2">
|
|
48
|
-
{param.description}
|
|
49
|
-
</p>
|
|
44
|
+
<p className="text-sm text-fd-muted-foreground mt-2">{param.description}</p>
|
|
50
45
|
)}
|
|
51
46
|
</div>
|
|
52
47
|
);
|
|
@@ -38,7 +38,6 @@ function formatSchema(schema: unknown): string {
|
|
|
38
38
|
if (s.$ref && typeof s.$ref === 'string') {
|
|
39
39
|
return s.$ref.replace('#/types/', '');
|
|
40
40
|
}
|
|
41
|
-
if (s.tsType) return String(s.tsType);
|
|
42
41
|
if (s.type) return String(s.type);
|
|
43
42
|
}
|
|
44
43
|
return 'unknown';
|
|
@@ -46,7 +45,6 @@ function formatSchema(schema: unknown): string {
|
|
|
46
45
|
|
|
47
46
|
function formatReturnType(sig?: SpecSignature): string {
|
|
48
47
|
if (!sig?.returns) return 'void';
|
|
49
|
-
if (sig.returns.tsType) return sig.returns.tsType;
|
|
50
48
|
return formatSchema(sig.returns.schema);
|
|
51
49
|
}
|
|
52
50
|
|
|
@@ -85,7 +83,7 @@ function buildSignatureString(exp: SpecExport, sigIndex = 0): string {
|
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
export function Signature({ export: exp, signatureIndex = 0 }: SignatureProps) {
|
|
86
|
+
export function Signature({ export: exp, signatureIndex = 0 }: SignatureProps): React.ReactNode {
|
|
89
87
|
const signature = buildSignatureString(exp, signatureIndex);
|
|
90
88
|
|
|
91
89
|
// Build RawCode for syntax highlighting
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import type { OpenPkg,
|
|
3
|
+
import type { OpenPkg, SpecMember, SpecSignatureParameter } from '@openpkg-ts/spec';
|
|
4
4
|
|
|
5
5
|
export interface TypeTableProps {
|
|
6
6
|
items: (SpecSignatureParameter | SpecMember)[];
|
|
@@ -20,8 +20,6 @@ function formatSchema(schema: unknown): string {
|
|
|
20
20
|
}
|
|
21
21
|
// Handle type
|
|
22
22
|
if (s.type) return String(s.type);
|
|
23
|
-
// Handle tsType
|
|
24
|
-
if (s.tsType) return String(s.tsType);
|
|
25
23
|
}
|
|
26
24
|
return 'unknown';
|
|
27
25
|
}
|
|
@@ -30,7 +28,7 @@ function isParameter(item: SpecSignatureParameter | SpecMember): item is SpecSig
|
|
|
30
28
|
return 'required' in item;
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
export function TypeTable({ items, showRequired = true }: TypeTableProps) {
|
|
31
|
+
export function TypeTable({ items, showRequired = true }: TypeTableProps): React.ReactNode {
|
|
34
32
|
if (!items?.length) return null;
|
|
35
33
|
|
|
36
34
|
return (
|
|
@@ -40,7 +38,9 @@ export function TypeTable({ items, showRequired = true }: TypeTableProps) {
|
|
|
40
38
|
<tr className="border-b border-fd-border">
|
|
41
39
|
<th className="text-left py-2 px-3 font-medium text-fd-muted-foreground">Name</th>
|
|
42
40
|
<th className="text-left py-2 px-3 font-medium text-fd-muted-foreground">Type</th>
|
|
43
|
-
<th className="text-left py-2 px-3 font-medium text-fd-muted-foreground">
|
|
41
|
+
<th className="text-left py-2 px-3 font-medium text-fd-muted-foreground">
|
|
42
|
+
Description
|
|
43
|
+
</th>
|
|
44
44
|
</tr>
|
|
45
45
|
</thead>
|
|
46
46
|
<tbody>
|
|
@@ -56,9 +56,7 @@ export function TypeTable({ items, showRequired = true }: TypeTableProps) {
|
|
|
56
56
|
<code className="text-fd-primary font-mono text-xs bg-fd-secondary px-1.5 py-0.5 rounded">
|
|
57
57
|
{name}
|
|
58
58
|
</code>
|
|
59
|
-
{showRequired && required &&
|
|
60
|
-
<span className="ml-1 text-red-500 text-xs">*</span>
|
|
61
|
-
)}
|
|
59
|
+
{showRequired && required && <span className="ml-1 text-red-500 text-xs">*</span>}
|
|
62
60
|
{showRequired && !required && (
|
|
63
61
|
<span className="ml-1 text-fd-muted-foreground text-xs">?</span>
|
|
64
62
|
)}
|
|
@@ -66,9 +64,7 @@ export function TypeTable({ items, showRequired = true }: TypeTableProps) {
|
|
|
66
64
|
<td className="py-2 px-3 align-top">
|
|
67
65
|
<code className="font-mono text-xs text-fd-muted-foreground">{type}</code>
|
|
68
66
|
</td>
|
|
69
|
-
<td className="py-2 px-3 align-top text-fd-muted-foreground">
|
|
70
|
-
{description}
|
|
71
|
-
</td>
|
|
67
|
+
<td className="py-2 px-3 align-top text-fd-muted-foreground">{description}</td>
|
|
72
68
|
</tr>
|
|
73
69
|
);
|
|
74
70
|
})}
|
|
@@ -77,4 +73,3 @@ export function TypeTable({ items, showRequired = true }: TypeTableProps) {
|
|
|
77
73
|
</div>
|
|
78
74
|
);
|
|
79
75
|
}
|
|
80
|
-
|
|
@@ -17,13 +17,12 @@ function formatSchema(schema: unknown): string {
|
|
|
17
17
|
if (s.$ref && typeof s.$ref === 'string') {
|
|
18
18
|
return s.$ref.replace('#/types/', '');
|
|
19
19
|
}
|
|
20
|
-
if (s.tsType) return String(s.tsType);
|
|
21
20
|
if (s.type) return String(s.type);
|
|
22
21
|
}
|
|
23
22
|
return 'unknown';
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
export function VariablePage({ export: exp, spec }: VariablePageProps) {
|
|
25
|
+
export function VariablePage({ export: exp, spec: _spec }: VariablePageProps): React.ReactNode {
|
|
27
26
|
const typeValue = typeof exp.type === 'string' ? exp.type : formatSchema(exp.schema);
|
|
28
27
|
const hasExamples = exp.examples && exp.examples.length > 0;
|
|
29
28
|
|
|
@@ -31,9 +30,7 @@ export function VariablePage({ export: exp, spec }: VariablePageProps) {
|
|
|
31
30
|
<div className="space-y-8">
|
|
32
31
|
{/* Description */}
|
|
33
32
|
{exp.description && (
|
|
34
|
-
<p className="text-fd-muted-foreground text-lg leading-relaxed">
|
|
35
|
-
{exp.description}
|
|
36
|
-
</p>
|
|
33
|
+
<p className="text-fd-muted-foreground text-lg leading-relaxed">{exp.description}</p>
|
|
37
34
|
)}
|
|
38
35
|
|
|
39
36
|
{/* Declaration */}
|
|
@@ -63,10 +60,7 @@ export function VariablePage({ export: exp, spec }: VariablePageProps) {
|
|
|
63
60
|
<h3 className="text-sm font-semibold uppercase tracking-wide text-fd-muted-foreground mb-3">
|
|
64
61
|
{exp.name} usage
|
|
65
62
|
</h3>
|
|
66
|
-
<CodeExample
|
|
67
|
-
code={exp.examples![0]}
|
|
68
|
-
filename={`${exp.name.toLowerCase()}.ts`}
|
|
69
|
-
/>
|
|
63
|
+
<CodeExample code={exp.examples![0]} filename={`${exp.name.toLowerCase()}.ts`} />
|
|
70
64
|
</div>
|
|
71
65
|
)}
|
|
72
66
|
</div>
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Server
|
|
2
|
-
export { createOpenPkg } from './server';
|
|
3
|
-
export type { OpenPkgInstance, OpenPkgOptions } from './server';
|
|
4
2
|
|
|
3
|
+
export type { APIPageProps } from './components/api-page';
|
|
5
4
|
// Components
|
|
6
5
|
export { APIPage } from './components/api-page';
|
|
7
|
-
export type {
|
|
8
|
-
|
|
6
|
+
export type { OpenPkgInstance, OpenPkgOptions } from './server';
|
|
7
|
+
export { createOpenPkg } from './server';
|
package/src/server.ts
CHANGED
package/src/styles/docskit.css
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Docskit CSS Variables for Fumadocs
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* This file defines the CSS variables needed for @doccov/ui docskit components
|
|
5
5
|
* to work within Fumadocs themes.
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
7
|
* Import this in your global CSS:
|
|
8
8
|
* @import '@doccov/fumadocs-adapter/css';
|
|
9
|
-
*
|
|
9
|
+
*
|
|
10
10
|
* Or add these variables to your Tailwind CSS:
|
|
11
11
|
* @import 'tailwindcss';
|
|
12
12
|
* @import 'fumadocs-ui/css/neutral.css';
|
|
@@ -23,14 +23,15 @@
|
|
|
23
23
|
--dk-tab-inactive-foreground: var(--color-fd-muted-foreground, hsl(0 0% 60%));
|
|
24
24
|
--dk-tab-active-foreground: var(--color-fd-foreground, hsl(0 0% 98%));
|
|
25
25
|
--dk-selection: var(--color-fd-primary, hsl(220 70% 50%));
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
/* Line highlight colors */
|
|
28
28
|
--dk-line-bg: transparent;
|
|
29
29
|
--dk-line-border: transparent;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/* Light mode overrides if needed */
|
|
33
|
-
.light,
|
|
33
|
+
.light,
|
|
34
|
+
[data-theme="light"] {
|
|
34
35
|
--dk-background: var(--color-fd-card, hsl(0 0% 98%));
|
|
35
36
|
--dk-border: var(--color-fd-border, hsl(0 0% 85%));
|
|
36
37
|
--dk-tabs-background: var(--color-fd-muted, hsl(0 0% 95%));
|
|
@@ -97,7 +98,8 @@
|
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
/* GitHub Light theme */
|
|
100
|
-
.light,
|
|
101
|
+
.light,
|
|
102
|
+
[data-theme="light"] {
|
|
101
103
|
--ch-0: #24292f; /* default text */
|
|
102
104
|
--ch-1: #cf222e; /* strings, inherited class */
|
|
103
105
|
--ch-2: #116329; /* string literals */
|
|
@@ -127,4 +129,3 @@
|
|
|
127
129
|
--ch-26: #ffffffe6;
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
|
-
|
package/tsconfig.json
CHANGED