@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/src/types.ts CHANGED
@@ -53,7 +53,10 @@ export interface SharedProps {
53
53
  /** Table of contents item */
54
54
  export interface TOCItem {
55
55
  id: string
56
- text: string
56
+ /** Display text (use either text or title) */
57
+ text?: string
58
+ /** Display title (use either text or title) */
59
+ title?: string
57
60
  level: number
58
61
  }
59
62
 
@@ -82,6 +85,10 @@ export interface DocsLayoutProps {
82
85
  githubUrl?: string
83
86
  /** Additional navigation links */
84
87
  navLinks?: Array<{ label: string; href: string }>
88
+ /** Custom header component (replaces entire header). Can be a ReactNode or a function that receives mobile menu props. */
89
+ header?: ReactNode | ((props: { mobileMenuOpen: boolean; toggleMobileMenu: () => void }) => ReactNode)
90
+ /** Header height in pixels. Used to calculate content offset. Defaults to 64 (h-16). */
91
+ headerHeight?: number
85
92
  /** Custom footer component */
86
93
  footer?: ReactNode
87
94
  /** Table of contents items for the current page */
@@ -92,6 +99,7 @@ export interface DocsLayoutProps {
92
99
  export interface TableOfContentsProps {
93
100
  items: TOCItem[]
94
101
  className?: string
102
+ style?: React.CSSProperties
95
103
  }
96
104
 
97
105
  /** Props for Sidebar component */
@@ -129,3 +137,216 @@ export interface DocsAppConfig {
129
137
  /** Custom components to use in markdown (e.g., Alert, Card, etc.) */
130
138
  components?: Record<string, React.ComponentType<any>>
131
139
  }
140
+
141
+ // =============================================================================
142
+ // Griffe API Documentation Types
143
+ // =============================================================================
144
+
145
+ /** Griffe object kinds */
146
+ export type GriffeKind = 'module' | 'class' | 'function' | 'attribute'
147
+
148
+ /** Griffe docstring section kinds */
149
+ export type GriffeDocstringSectionKind =
150
+ | 'text'
151
+ | 'parameters'
152
+ | 'returns'
153
+ | 'yields'
154
+ | 'receives'
155
+ | 'raises'
156
+ | 'warns'
157
+ | 'examples'
158
+ | 'attributes'
159
+ | 'other'
160
+ | 'deprecated'
161
+ | 'admonition'
162
+
163
+ /** Griffe expression (type annotation) */
164
+ export interface GriffeExpression {
165
+ /** String representation of the expression */
166
+ str?: string
167
+ /** Canonical string representation */
168
+ canonical?: string
169
+ /** For name expressions */
170
+ name?: string
171
+ /** For subscript expressions (e.g., List[int]) */
172
+ slice?: GriffeExpression
173
+ /** For compound expressions */
174
+ left?: GriffeExpression
175
+ right?: GriffeExpression
176
+ }
177
+
178
+ /** Griffe parameter */
179
+ export interface GriffeParameter {
180
+ name: string
181
+ kind: 'positional-only' | 'positional-or-keyword' | 'var-positional' | 'keyword-only' | 'var-keyword'
182
+ annotation?: GriffeExpression | string
183
+ default?: string
184
+ }
185
+
186
+ /** Griffe docstring section element (for parameters, returns, etc.) */
187
+ export interface GriffeDocstringElement {
188
+ name?: string
189
+ annotation?: GriffeExpression | string
190
+ description?: string
191
+ value?: string
192
+ }
193
+
194
+ /** Griffe docstring section */
195
+ export interface GriffeDocstringSection {
196
+ kind: GriffeDocstringSectionKind
197
+ value?: string | GriffeDocstringElement[]
198
+ title?: string
199
+ }
200
+
201
+ /** Griffe parsed docstring */
202
+ export interface GriffeDocstring {
203
+ value: string
204
+ parsed?: GriffeDocstringSection[]
205
+ }
206
+
207
+ /** Griffe decorator */
208
+ export interface GriffeDecorator {
209
+ value: string
210
+ lineno?: number
211
+ }
212
+
213
+ /** Base Griffe object with common properties */
214
+ export interface GriffeObjectBase {
215
+ kind: GriffeKind
216
+ name: string
217
+ path?: string
218
+ filepath?: string
219
+ /** Relative file path (set by cross-docs) */
220
+ relative_filepath?: string
221
+ /** Relative file path within the package (set by Griffe) */
222
+ relative_package_filepath?: string
223
+ lineno?: number
224
+ endlineno?: number
225
+ docstring?: GriffeDocstring
226
+ labels?: string[]
227
+ }
228
+
229
+ /** Griffe function/method */
230
+ export interface GriffeFunction extends GriffeObjectBase {
231
+ kind: 'function'
232
+ parameters?: GriffeParameter[]
233
+ returns?: GriffeExpression | string
234
+ decorators?: GriffeDecorator[]
235
+ /** Whether this is an async function */
236
+ is_async?: boolean
237
+ }
238
+
239
+ /** Griffe attribute */
240
+ export interface GriffeAttribute extends GriffeObjectBase {
241
+ kind: 'attribute'
242
+ annotation?: GriffeExpression | string
243
+ value?: string
244
+ }
245
+
246
+ /** Griffe class */
247
+ export interface GriffeClass extends GriffeObjectBase {
248
+ kind: 'class'
249
+ bases?: Array<GriffeExpression | string>
250
+ decorators?: GriffeDecorator[]
251
+ members?: Record<string, GriffeMember>
252
+ }
253
+
254
+ /** Griffe module */
255
+ export interface GriffeModule extends GriffeObjectBase {
256
+ kind: 'module'
257
+ members?: Record<string, GriffeMember>
258
+ /** Generator metadata added by cross-docs */
259
+ _generator?: string
260
+ _plugin?: string
261
+ _version?: string
262
+ }
263
+
264
+ /** Griffe alias (re-export) */
265
+ export interface GriffeAlias {
266
+ kind: 'alias'
267
+ name: string
268
+ path?: string
269
+ /** The target path this alias points to */
270
+ target_path: string
271
+ lineno?: number
272
+ endlineno?: number
273
+ }
274
+
275
+ /** Union of all Griffe member types */
276
+ export type GriffeMember = GriffeModule | GriffeClass | GriffeFunction | GriffeAttribute | GriffeAlias
277
+
278
+ /** Props for API documentation pages */
279
+ export interface APIPageProps {
280
+ /** Full API data (the entire module tree) */
281
+ apiData: GriffeModule
282
+ /** Current item being viewed (module, class, or function) */
283
+ currentItem?: GriffeMember
284
+ /** Current URL path */
285
+ currentPath: string
286
+ /** Current module name */
287
+ currentModule: string
288
+ /** Navigation structure for API sidebar */
289
+ apiNav: NavSection[]
290
+ /** URL prefix for API links (e.g., /docs/api-reference) */
291
+ prefix: string
292
+ /** Logo URL */
293
+ logoUrl?: string
294
+ /** Logo URL for dark mode */
295
+ logoInvertedUrl?: string
296
+ /** Footer logo URL */
297
+ footerLogoUrl?: string
298
+ /** Footer logo URL for dark mode */
299
+ footerLogoInvertedUrl?: string
300
+ /** GitHub URL */
301
+ githubUrl?: string
302
+ /** Navigation links */
303
+ navLinks?: Array<{ label: string; href: string }>
304
+ /** Custom header component (replaces entire header). Can be a ReactNode or a function that receives mobile menu props. */
305
+ header?: React.ReactNode | ((props: { mobileMenuOpen: boolean; toggleMobileMenu: () => void }) => React.ReactNode)
306
+ /** Header height in pixels. Used to calculate content offset. Defaults to 64 (h-16). */
307
+ headerHeight?: number
308
+ /** Custom footer component */
309
+ footer?: React.ReactNode
310
+ }
311
+
312
+ /** Props for ModuleDoc component */
313
+ export interface ModuleDocProps {
314
+ module: GriffeModule
315
+ /** URL prefix for links */
316
+ prefix?: string
317
+ }
318
+
319
+ /** Props for ClassDoc component */
320
+ export interface ClassDocProps {
321
+ cls: GriffeClass
322
+ /** URL prefix for links */
323
+ prefix?: string
324
+ }
325
+
326
+ /** Props for FunctionDoc component */
327
+ export interface FunctionDocProps {
328
+ fn: GriffeFunction
329
+ /** Whether this is a method (inside a class) */
330
+ isMethod?: boolean
331
+ }
332
+
333
+ /** Props for Signature component */
334
+ export interface SignatureProps {
335
+ fn: GriffeFunction
336
+ /** Show full path or just name */
337
+ showPath?: boolean
338
+ }
339
+
340
+ /** Props for Docstring component */
341
+ export interface DocstringProps {
342
+ docstring: GriffeDocstring
343
+ /** Show raw text instead of parsed sections */
344
+ raw?: boolean
345
+ }
346
+
347
+ /** Props for ParameterTable component */
348
+ export interface ParameterTableProps {
349
+ parameters: GriffeParameter[]
350
+ /** Docstring sections for parameter descriptions */
351
+ docstringSections?: GriffeDocstringSection[]
352
+ }
@@ -1,128 +0,0 @@
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
- text: string;
56
- level: number;
57
- }
58
- /** Document content structure */
59
- interface DocContent {
60
- title: string;
61
- description: string;
62
- body: string;
63
- toc?: TOCItem[];
64
- }
65
- /** Props for DocsLayout component */
66
- interface DocsLayoutProps {
67
- children: ReactNode;
68
- title: string;
69
- description?: string;
70
- /** Custom logo component (React node) */
71
- logo?: ReactNode;
72
- /** Custom logo for dark/inverted contexts (React node) */
73
- logoInverted?: ReactNode;
74
- /** Logo image URL (alternative to logo prop, can be passed from backend) */
75
- logoUrl?: string;
76
- /** Logo image URL for dark/inverted contexts */
77
- logoInvertedUrl?: string;
78
- /** GitHub repository URL (shows GitHub icon in nav) */
79
- githubUrl?: string;
80
- /** Additional navigation links */
81
- navLinks?: Array<{
82
- label: string;
83
- href: string;
84
- }>;
85
- /** Custom footer component */
86
- footer?: ReactNode;
87
- /** Table of contents items for the current page */
88
- toc?: TOCItem[];
89
- }
90
- /** Props for TableOfContents component */
91
- interface TableOfContentsProps {
92
- items: TOCItem[];
93
- className?: string;
94
- }
95
- /** Props for Sidebar component */
96
- interface SidebarProps {
97
- nav: NavSection[];
98
- currentPath: string;
99
- className?: string;
100
- /** Available documentation sets (multi-docs mode) */
101
- docSets?: DocSetMeta[];
102
- /** Current documentation set slug (multi-docs mode) */
103
- currentDocSet?: string;
104
- }
105
- /** Props for Markdown component */
106
- interface MarkdownProps {
107
- content: string;
108
- /** Override default markdown components */
109
- components?: Record<string, React.ComponentType<any>>;
110
- }
111
- /** Props for CodeBlock component */
112
- interface CodeBlockProps {
113
- code: string;
114
- language?: string;
115
- filename?: string;
116
- showLineNumbers?: boolean;
117
- theme?: string;
118
- className?: string;
119
- }
120
- /** Configuration for createDocsApp */
121
- interface DocsAppConfig {
122
- pages: Record<string, React.ComponentType<any>>;
123
- title?: (pageTitle: string) => string;
124
- /** Custom components to use in markdown (e.g., Alert, Card, etc.) */
125
- components?: Record<string, React.ComponentType<any>>;
126
- }
127
-
128
- export type { CodeBlockProps as C, DocSetMeta as D, MarkdownProps as M, NavItem as N, SidebarProps as S, TableOfContentsProps as T, DocsLayoutProps as a, DocContent as b, DocsAppConfig as c, NavSection as d, SharedProps as e, TOCItem as f };