@usecross/docs 0.10.2 → 0.12.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.
package/dist/ssr.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as DocsAppConfig } from './types-DlTTA3Dc.js';
1
+ import { h as DocsAppConfig } from './types-_anC1UJu.js';
2
2
  import 'react';
3
3
 
4
4
  /**
@@ -0,0 +1,320 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ /**
4
+ * Cross-Docs TypeScript type definitions
5
+ */
6
+
7
+ /** Single navigation item */
8
+ interface NavItem {
9
+ title: string;
10
+ href: string;
11
+ }
12
+ /** Navigation section containing multiple items */
13
+ interface NavSection {
14
+ title: string;
15
+ items: NavItem[];
16
+ }
17
+ /** Documentation set metadata (for multi-docs mode) */
18
+ interface DocSetMeta {
19
+ name: string;
20
+ slug: string;
21
+ description: string;
22
+ /** Emoji or short text icon (e.g., "🍓") */
23
+ icon?: string;
24
+ /** URL to icon image */
25
+ iconUrl?: string;
26
+ prefix: string;
27
+ }
28
+ /** Shared props passed to all pages via Inertia */
29
+ interface SharedProps {
30
+ nav: NavSection[];
31
+ currentPath: string;
32
+ /** Logo image URL (from Python backend) */
33
+ logoUrl?: string;
34
+ /** Logo image URL for dark/inverted contexts (from Python backend) */
35
+ logoInvertedUrl?: string;
36
+ /** Footer logo image URL (from Python backend) */
37
+ footerLogoUrl?: string;
38
+ /** Footer logo image URL for dark mode (from Python backend) */
39
+ footerLogoInvertedUrl?: string;
40
+ /** GitHub repository URL (from Python backend) */
41
+ githubUrl?: string;
42
+ /** Additional navigation links (from Python backend) */
43
+ navLinks?: Array<{
44
+ label: string;
45
+ href: string;
46
+ }>;
47
+ /** Available documentation sets (multi-docs mode) */
48
+ docSets?: DocSetMeta[];
49
+ /** Current documentation set slug (multi-docs mode) */
50
+ currentDocSet?: string;
51
+ }
52
+ /** Table of contents item */
53
+ interface TOCItem {
54
+ id: string;
55
+ /** Display text (use either text or title) */
56
+ text?: string;
57
+ /** Display title (use either text or title) */
58
+ title?: string;
59
+ level: number;
60
+ }
61
+ /** Document content structure */
62
+ interface DocContent {
63
+ title: string;
64
+ description: string;
65
+ body: string;
66
+ toc?: TOCItem[];
67
+ }
68
+ /** Props for DocsLayout component */
69
+ interface DocsLayoutProps {
70
+ children: ReactNode;
71
+ title: string;
72
+ description?: string;
73
+ /** Custom logo component (React node) */
74
+ logo?: ReactNode;
75
+ /** Custom logo for dark/inverted contexts (React node) */
76
+ logoInverted?: ReactNode;
77
+ /** Logo image URL (alternative to logo prop, can be passed from backend) */
78
+ logoUrl?: string;
79
+ /** Logo image URL for dark/inverted contexts */
80
+ logoInvertedUrl?: string;
81
+ /** GitHub repository URL (shows GitHub icon in nav) */
82
+ githubUrl?: string;
83
+ /** Additional navigation links */
84
+ navLinks?: Array<{
85
+ label: string;
86
+ href: string;
87
+ }>;
88
+ /** Custom header component (replaces entire header). Can be a ReactNode or a function that receives mobile menu props. */
89
+ header?: ReactNode | ((props: {
90
+ mobileMenuOpen: boolean;
91
+ toggleMobileMenu: () => void;
92
+ }) => ReactNode);
93
+ /** Header height in pixels. Used to calculate content offset. Defaults to 64 (h-16). */
94
+ headerHeight?: number;
95
+ /** Custom footer component */
96
+ footer?: ReactNode;
97
+ /** Table of contents items for the current page */
98
+ toc?: TOCItem[];
99
+ }
100
+ /** Props for TableOfContents component */
101
+ interface TableOfContentsProps {
102
+ items: TOCItem[];
103
+ className?: string;
104
+ style?: React.CSSProperties;
105
+ }
106
+ /** Props for Sidebar component */
107
+ interface SidebarProps {
108
+ nav: NavSection[];
109
+ currentPath: string;
110
+ className?: string;
111
+ /** Available documentation sets (multi-docs mode) */
112
+ docSets?: DocSetMeta[];
113
+ /** Current documentation set slug (multi-docs mode) */
114
+ currentDocSet?: string;
115
+ }
116
+ /** Props for Markdown component */
117
+ interface MarkdownProps {
118
+ content: string;
119
+ /** Override default markdown components */
120
+ components?: Record<string, React.ComponentType<any>>;
121
+ }
122
+ /** Props for CodeBlock component */
123
+ interface CodeBlockProps {
124
+ code: string;
125
+ language?: string;
126
+ filename?: string;
127
+ showLineNumbers?: boolean;
128
+ theme?: string;
129
+ className?: string;
130
+ }
131
+ /** Configuration for createDocsApp */
132
+ interface DocsAppConfig {
133
+ pages: Record<string, React.ComponentType<any>>;
134
+ title?: (pageTitle: string) => string;
135
+ /** Custom components to use in markdown (e.g., Alert, Card, etc.) */
136
+ components?: Record<string, React.ComponentType<any>>;
137
+ }
138
+ /** Griffe object kinds */
139
+ type GriffeKind = 'module' | 'class' | 'function' | 'attribute';
140
+ /** Griffe docstring section kinds */
141
+ type GriffeDocstringSectionKind = 'text' | 'parameters' | 'returns' | 'yields' | 'receives' | 'raises' | 'warns' | 'examples' | 'attributes' | 'other' | 'deprecated' | 'admonition';
142
+ /** Griffe expression (type annotation) */
143
+ interface GriffeExpression {
144
+ /** String representation of the expression */
145
+ str?: string;
146
+ /** Canonical string representation */
147
+ canonical?: string;
148
+ /** For name expressions */
149
+ name?: string;
150
+ /** For subscript expressions (e.g., List[int]) */
151
+ slice?: GriffeExpression;
152
+ /** For compound expressions */
153
+ left?: GriffeExpression;
154
+ right?: GriffeExpression;
155
+ }
156
+ /** Griffe parameter */
157
+ interface GriffeParameter {
158
+ name: string;
159
+ kind: 'positional-only' | 'positional-or-keyword' | 'var-positional' | 'keyword-only' | 'var-keyword';
160
+ annotation?: GriffeExpression | string;
161
+ default?: string;
162
+ }
163
+ /** Griffe docstring section element (for parameters, returns, etc.) */
164
+ interface GriffeDocstringElement {
165
+ name?: string;
166
+ annotation?: GriffeExpression | string;
167
+ description?: string;
168
+ value?: string;
169
+ }
170
+ /** Griffe docstring section */
171
+ interface GriffeDocstringSection {
172
+ kind: GriffeDocstringSectionKind;
173
+ value?: string | GriffeDocstringElement[];
174
+ title?: string;
175
+ }
176
+ /** Griffe parsed docstring */
177
+ interface GriffeDocstring {
178
+ value: string;
179
+ parsed?: GriffeDocstringSection[];
180
+ }
181
+ /** Griffe decorator */
182
+ interface GriffeDecorator {
183
+ value: string;
184
+ lineno?: number;
185
+ }
186
+ /** Base Griffe object with common properties */
187
+ interface GriffeObjectBase {
188
+ kind: GriffeKind;
189
+ name: string;
190
+ path?: string;
191
+ filepath?: string;
192
+ /** Relative file path (set by cross-docs) */
193
+ relative_filepath?: string;
194
+ /** Relative file path within the package (set by Griffe) */
195
+ relative_package_filepath?: string;
196
+ lineno?: number;
197
+ endlineno?: number;
198
+ docstring?: GriffeDocstring;
199
+ labels?: string[];
200
+ }
201
+ /** Griffe function/method */
202
+ interface GriffeFunction extends GriffeObjectBase {
203
+ kind: 'function';
204
+ parameters?: GriffeParameter[];
205
+ returns?: GriffeExpression | string;
206
+ decorators?: GriffeDecorator[];
207
+ /** Whether this is an async function */
208
+ is_async?: boolean;
209
+ }
210
+ /** Griffe attribute */
211
+ interface GriffeAttribute extends GriffeObjectBase {
212
+ kind: 'attribute';
213
+ annotation?: GriffeExpression | string;
214
+ value?: string;
215
+ }
216
+ /** Griffe class */
217
+ interface GriffeClass extends GriffeObjectBase {
218
+ kind: 'class';
219
+ bases?: Array<GriffeExpression | string>;
220
+ decorators?: GriffeDecorator[];
221
+ members?: Record<string, GriffeMember>;
222
+ }
223
+ /** Griffe module */
224
+ interface GriffeModule extends GriffeObjectBase {
225
+ kind: 'module';
226
+ members?: Record<string, GriffeMember>;
227
+ /** Generator metadata added by cross-docs */
228
+ _generator?: string;
229
+ _plugin?: string;
230
+ _version?: string;
231
+ }
232
+ /** Griffe alias (re-export) */
233
+ interface GriffeAlias {
234
+ kind: 'alias';
235
+ name: string;
236
+ path?: string;
237
+ /** The target path this alias points to */
238
+ target_path: string;
239
+ lineno?: number;
240
+ endlineno?: number;
241
+ }
242
+ /** Union of all Griffe member types */
243
+ type GriffeMember = GriffeModule | GriffeClass | GriffeFunction | GriffeAttribute | GriffeAlias;
244
+ /** Props for API documentation pages */
245
+ interface APIPageProps {
246
+ /** Full API data (the entire module tree) */
247
+ apiData: GriffeModule;
248
+ /** Current item being viewed (module, class, or function) */
249
+ currentItem?: GriffeMember;
250
+ /** Current URL path */
251
+ currentPath: string;
252
+ /** Current module name */
253
+ currentModule: string;
254
+ /** Navigation structure for API sidebar */
255
+ apiNav: NavSection[];
256
+ /** URL prefix for API links (e.g., /docs/api-reference) */
257
+ prefix: string;
258
+ /** Logo URL */
259
+ logoUrl?: string;
260
+ /** Logo URL for dark mode */
261
+ logoInvertedUrl?: string;
262
+ /** Footer logo URL */
263
+ footerLogoUrl?: string;
264
+ /** Footer logo URL for dark mode */
265
+ footerLogoInvertedUrl?: string;
266
+ /** GitHub URL */
267
+ githubUrl?: string;
268
+ /** Navigation links */
269
+ navLinks?: Array<{
270
+ label: string;
271
+ href: string;
272
+ }>;
273
+ /** Custom header component (replaces entire header). Can be a ReactNode or a function that receives mobile menu props. */
274
+ header?: React.ReactNode | ((props: {
275
+ mobileMenuOpen: boolean;
276
+ toggleMobileMenu: () => void;
277
+ }) => React.ReactNode);
278
+ /** Header height in pixels. Used to calculate content offset. Defaults to 64 (h-16). */
279
+ headerHeight?: number;
280
+ /** Custom footer component */
281
+ footer?: React.ReactNode;
282
+ }
283
+ /** Props for ModuleDoc component */
284
+ interface ModuleDocProps {
285
+ module: GriffeModule;
286
+ /** URL prefix for links */
287
+ prefix?: string;
288
+ }
289
+ /** Props for ClassDoc component */
290
+ interface ClassDocProps {
291
+ cls: GriffeClass;
292
+ /** URL prefix for links */
293
+ prefix?: string;
294
+ }
295
+ /** Props for FunctionDoc component */
296
+ interface FunctionDocProps {
297
+ fn: GriffeFunction;
298
+ /** Whether this is a method (inside a class) */
299
+ isMethod?: boolean;
300
+ }
301
+ /** Props for Signature component */
302
+ interface SignatureProps {
303
+ fn: GriffeFunction;
304
+ /** Show full path or just name */
305
+ showPath?: boolean;
306
+ }
307
+ /** Props for Docstring component */
308
+ interface DocstringProps {
309
+ docstring: GriffeDocstring;
310
+ /** Show raw text instead of parsed sections */
311
+ raw?: boolean;
312
+ }
313
+ /** Props for ParameterTable component */
314
+ interface ParameterTableProps {
315
+ parameters: GriffeParameter[];
316
+ /** Docstring sections for parameter descriptions */
317
+ docstringSections?: GriffeDocstringSection[];
318
+ }
319
+
320
+ export type { APIPageProps as A, CodeBlockProps as C, DocSetMeta as D, FunctionDocProps as F, GriffeModule as G, MarkdownProps as M, NavSection as N, ParameterTableProps as P, SidebarProps as S, TableOfContentsProps as T, DocsLayoutProps as a, DocContent as b, GriffeClass as c, GriffeFunction as d, GriffeDocstring as e, GriffeParameter as f, GriffeDocstringSection as g, DocsAppConfig as h, NavItem as i, SharedProps as j, TOCItem as k, GriffeKind as l, GriffeDocstringSectionKind as m, GriffeExpression as n, GriffeDocstringElement as o, GriffeDecorator as p, GriffeObjectBase as q, GriffeAttribute as r, GriffeMember as s, ModuleDocProps as t, ClassDocProps as u, SignatureProps as v, DocstringProps as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usecross/docs",
3
- "version": "0.10.2",
3
+ "version": "0.12.0",
4
4
  "description": "Documentation framework built on Cross-Inertia",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -6,7 +6,7 @@ import { ThemeToggle } from './ThemeToggle'
6
6
  import { useTheme } from './ThemeProvider'
7
7
  import type { DocsLayoutProps, SharedProps } from '../types'
8
8
 
9
- function MobileMenuButton({ onClick, isOpen }: { onClick: () => void; isOpen: boolean }) {
9
+ export function MobileMenuButton({ onClick, isOpen }: { onClick: () => void; isOpen: boolean }) {
10
10
  return (
11
11
  <button
12
12
  onClick={onClick}
@@ -52,6 +52,8 @@ export function DocsLayout({
52
52
  logoInvertedUrl: propLogoInvertedUrl,
53
53
  githubUrl: propGithubUrl,
54
54
  navLinks: propNavLinks,
55
+ header,
56
+ headerHeight = 64,
55
57
  footer,
56
58
  toc,
57
59
  }: DocsLayoutProps) {
@@ -86,88 +88,102 @@ export function DocsLayout({
86
88
  <Head title={title} />
87
89
 
88
90
  {/* Fixed navigation */}
89
- <nav className="fixed w-full z-50 bg-white/95 dark:bg-[#0f0f0f]/95 backdrop-blur-sm border-b border-gray-200 dark:border-gray-800 transition-colors">
90
- <div className="px-4 lg:px-10">
91
- <div className="flex justify-between h-16 items-center">
92
- <div className="flex items-center gap-2">
93
- <MobileMenuButton onClick={() => setMobileMenuOpen(!mobileMenuOpen)} isOpen={mobileMenuOpen} />
94
- {headerLogo ? (
95
- <Link href="/" className="flex items-center">
96
- {headerLogo}
97
- </Link>
98
- ) : (
99
- <Link href="/" className="font-bold text-lg text-gray-900 dark:text-white">
100
- Docs
101
- </Link>
102
- )}
103
- </div>
104
- <div className="flex items-center gap-6">
105
- <div className="-mr-2">
106
- <ThemeToggle size="sm" />
91
+ {(typeof header === 'function'
92
+ ? header({ mobileMenuOpen, toggleMobileMenu: () => setMobileMenuOpen(!mobileMenuOpen) })
93
+ : header) || (
94
+ <nav className="fixed w-full z-50 bg-white/95 dark:bg-[#0f0f0f]/95 backdrop-blur-sm border-b border-gray-200 dark:border-gray-800 transition-colors">
95
+ <div className="px-4 lg:px-10">
96
+ <div className="flex justify-between h-16 items-center">
97
+ <div className="flex items-center gap-2">
98
+ <MobileMenuButton onClick={() => setMobileMenuOpen(!mobileMenuOpen)} isOpen={mobileMenuOpen} />
99
+ {headerLogo ? (
100
+ <Link href="/" className="flex items-center">
101
+ {headerLogo}
102
+ </Link>
103
+ ) : (
104
+ <Link href="/" className="font-bold text-lg text-gray-900 dark:text-white">
105
+ Docs
106
+ </Link>
107
+ )}
107
108
  </div>
109
+ <div className="flex items-center gap-6">
110
+ <div className="-mr-2">
111
+ <ThemeToggle size="sm" />
112
+ </div>
108
113
 
109
- {navLinks.map((link) => (
110
- <Link
111
- key={link.href}
112
- href={link.href}
113
- className="hidden sm:block text-gray-700 dark:text-gray-300 font-medium hover:text-primary-600 dark:hover:text-primary-400 transition-colors"
114
- >
115
- {link.label}
116
- </Link>
117
- ))}
118
- {githubUrl && (
119
- <a
120
- href={githubUrl}
121
- target="_blank"
122
- rel="noopener noreferrer"
123
- className="text-gray-700 dark:text-gray-300 hover:text-primary-600 dark:hover:text-primary-400 transition-colors"
124
- >
125
- <GitHubIcon />
126
- </a>
127
- )}
114
+ {navLinks.map((link) => (
115
+ <Link
116
+ key={link.href}
117
+ href={link.href}
118
+ className="hidden sm:block text-gray-700 dark:text-gray-300 font-medium hover:text-primary-600 dark:hover:text-primary-400 transition-colors"
119
+ >
120
+ {link.label}
121
+ </Link>
122
+ ))}
123
+ {githubUrl && (
124
+ <a
125
+ href={githubUrl}
126
+ target="_blank"
127
+ rel="noopener noreferrer"
128
+ className="text-gray-700 dark:text-gray-300 hover:text-primary-600 dark:hover:text-primary-400 transition-colors"
129
+ >
130
+ <GitHubIcon />
131
+ </a>
132
+ )}
133
+ </div>
128
134
  </div>
129
135
  </div>
130
- </div>
131
- </nav>
136
+ </nav>
137
+ )}
132
138
 
133
139
  {/* Mobile sidebar */}
134
140
  {mobileMenuOpen && (
135
141
  <div className="fixed inset-0 z-40 lg:hidden">
136
142
  <div className="fixed inset-0 bg-black/50 dark:bg-black/70" onClick={() => setMobileMenuOpen(false)} />
137
- <div className="fixed inset-y-0 left-0 w-64 overflow-y-auto bg-white dark:bg-[#0f0f0f] px-4 py-6 pt-20 border-r border-gray-200 dark:border-gray-800 transition-colors">
143
+ <div
144
+ className="fixed inset-y-0 left-0 w-72 overflow-y-auto bg-white dark:bg-[#0f0f0f] px-4 py-6 border-r border-gray-200 dark:border-gray-800 transition-colors"
145
+ style={{ paddingTop: headerHeight + 16 }}
146
+ >
138
147
  <Sidebar nav={nav} currentPath={currentPath} docSets={docSets} currentDocSet={currentDocSet} />
139
148
  </div>
140
149
  </div>
141
150
  )}
142
151
 
143
152
  {/* Main content area */}
144
- <div className="bg-white dark:bg-[#0f0f0f] pt-16 w-full flex-1 transition-colors">
153
+ <div className="bg-white dark:bg-[#0f0f0f] w-full flex-1 transition-colors" style={{ paddingTop: headerHeight }}>
145
154
  <div className="flex">
146
155
  {/* Desktop sidebar - fixed width */}
147
- <aside className="hidden lg:block w-72 flex-shrink-0 border-r border-gray-200 dark:border-gray-800 min-h-[calc(100vh-4rem)] transition-colors">
148
- <nav className="sticky top-16 px-4 lg:px-10 py-6 max-h-[calc(100vh-4rem)] overflow-y-auto">
156
+ <aside
157
+ className="hidden lg:block w-[24rem] shrink-0 border-r border-gray-200 dark:border-gray-800 transition-colors"
158
+ style={{ minHeight: `calc(100vh - ${headerHeight}px)` }}
159
+ >
160
+ <nav
161
+ className="sticky px-4 lg:px-10 py-6 overflow-y-auto"
162
+ style={{ top: headerHeight, maxHeight: `calc(100vh - ${headerHeight}px)` }}
163
+ >
149
164
  <Sidebar nav={nav} currentPath={currentPath} docSets={docSets} currentDocSet={currentDocSet} />
150
165
  </nav>
151
166
  </aside>
152
167
 
153
168
  {/* Right section: content + TOC + footer (not under left sidebar) */}
154
169
  <div className="flex-1 min-w-0 flex flex-col">
155
- <div className="flex flex-1">
156
- {/* Main content */}
157
- <main className="flex-1 min-w-0 p-4 lg:px-10 lg:py-6">
158
- <article className="prose prose-lg max-w-3xl prose-headings:font-bold prose-headings:tracking-tight prose-h1:text-3xl prose-h1:mb-4 prose-h2:text-2xl prose-h2:mt-10 first:prose-h2:mt-0 prose-h3:text-xl prose-a:text-primary-600 dark:prose-a:text-primary-400 prose-a:no-underline hover:prose-a:underline prose-code:bg-gray-100 dark:prose-code:bg-gray-800 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:before:content-none prose-code:after:content-none dark:prose-headings:text-white dark:prose-strong:text-white dark:text-gray-300">
159
- {children}
160
- </article>
161
- </main>
170
+ <div className="flex-1 p-4 lg:px-10 lg:py-6">
171
+ <div className="flex gap-5">
172
+ {/* Main content */}
173
+ <main className="min-w-0 w-full max-w-4xl">
174
+ <article className="prose prose-lg max-w-none prose-headings:font-bold prose-headings:tracking-tight prose-h1:text-3xl prose-h1:mb-4 prose-h2:text-2xl prose-h2:mt-10 first:prose-h2:mt-0 prose-h3:text-xl prose-a:text-primary-600 dark:prose-a:text-primary-400 prose-a:no-underline hover:prose-a:underline prose-code:bg-gray-100 dark:prose-code:bg-gray-800 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded prose-code:before:content-none prose-code:after:content-none dark:prose-headings:text-white dark:prose-strong:text-white dark:text-gray-300">
175
+ {children}
176
+ </article>
177
+ </main>
162
178
 
163
- {/* Table of Contents - desktop only */}
164
- {toc && toc.length > 0 && (
165
- <aside className="hidden xl:block w-64 flex-shrink-0 transition-colors">
166
- <div className="sticky top-16 px-4 py-6 max-h-[calc(100vh-4rem)] overflow-y-auto">
167
- <TableOfContents items={toc} />
168
- </div>
169
- </aside>
170
- )}
179
+ {/* Table of Contents - desktop only */}
180
+ {toc && toc.length > 0 && (
181
+ <aside className="hidden xl:block w-56 shrink-0 transition-colors">
182
+ <TableOfContents items={toc} className="sticky overflow-y-auto"
183
+ style={{ top: headerHeight + 24, maxHeight: `calc(100vh - ${headerHeight + 24}px)` }} />
184
+ </aside>
185
+ )}
186
+ </div>
171
187
  </div>
172
188
 
173
189
  {/* Footer - spans from after sidebar to right edge */}