@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/index.d.ts +164 -7
- package/dist/index.js +1304 -44
- package/dist/index.js.map +1 -1
- package/dist/ssr.d.ts +1 -1
- package/dist/types-_anC1UJu.d.ts +320 -0
- package/package.json +1 -1
- package/src/components/DocsLayout.tsx +75 -59
- package/src/components/Sidebar.tsx +171 -28
- package/src/components/TableOfContents.tsx +6 -6
- package/src/components/api/APILayout.tsx +231 -0
- package/src/components/api/APIPage.tsx +216 -0
- package/src/components/api/Breadcrumb.tsx +98 -0
- package/src/components/api/ClassDoc.tsx +257 -0
- package/src/components/api/CodeSpan.tsx +53 -0
- package/src/components/api/Docstring.tsx +269 -0
- package/src/components/api/FunctionDoc.tsx +130 -0
- package/src/components/api/ModuleDoc.tsx +298 -0
- package/src/components/api/ParameterTable.tsx +183 -0
- package/src/components/api/Signature.tsx +317 -0
- package/src/components/api/TableOfContents.tsx +50 -0
- package/src/components/api/index.ts +17 -0
- package/src/components/index.ts +13 -1
- package/src/index.ts +32 -0
- package/src/types.ts +222 -1
- package/dist/types-DlTTA3Dc.d.ts +0 -128
package/dist/index.js
CHANGED
|
@@ -307,36 +307,137 @@ function DocSetSelector({ docSets, currentDocSet, className }) {
|
|
|
307
307
|
|
|
308
308
|
// src/components/DocsLayout.tsx
|
|
309
309
|
import { Head, Link as Link2, usePage } from "@inertiajs/react";
|
|
310
|
-
import { useState as
|
|
310
|
+
import { useState as useState7 } from "react";
|
|
311
311
|
|
|
312
312
|
// src/components/Sidebar.tsx
|
|
313
|
+
import { useState as useState3 } from "react";
|
|
313
314
|
import { Link } from "@inertiajs/react";
|
|
314
315
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
315
|
-
function
|
|
316
|
+
function ChevronIcon({ expanded, className }) {
|
|
317
|
+
return /* @__PURE__ */ jsx3(
|
|
318
|
+
"svg",
|
|
319
|
+
{
|
|
320
|
+
className: cn("w-4 h-4 transition-transform duration-200", expanded && "rotate-90", className),
|
|
321
|
+
fill: "none",
|
|
322
|
+
viewBox: "0 0 24 24",
|
|
323
|
+
stroke: "currentColor",
|
|
324
|
+
children: /* @__PURE__ */ jsx3("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" })
|
|
325
|
+
}
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
function CollapsibleSection({
|
|
329
|
+
section,
|
|
330
|
+
currentPath,
|
|
331
|
+
defaultExpanded = true,
|
|
332
|
+
compact = false
|
|
333
|
+
}) {
|
|
334
|
+
const isActive = section.items.some(
|
|
335
|
+
(item) => currentPath === item.href || currentPath + "/" === item.href
|
|
336
|
+
);
|
|
337
|
+
const [expanded, setExpanded] = useState3(defaultExpanded || isActive);
|
|
338
|
+
return /* @__PURE__ */ jsxs3("div", { children: [
|
|
339
|
+
/* @__PURE__ */ jsxs3(
|
|
340
|
+
"button",
|
|
341
|
+
{
|
|
342
|
+
onClick: () => setExpanded(!expanded),
|
|
343
|
+
className: "w-full flex items-center justify-between mb-2 group",
|
|
344
|
+
children: [
|
|
345
|
+
/* @__PURE__ */ jsx3("h3", { className: cn(
|
|
346
|
+
"text-sm font-mono uppercase tracking-widest text-gray-500 dark:text-gray-400",
|
|
347
|
+
"group-hover:text-gray-700 dark:group-hover:text-gray-300 transition-colors"
|
|
348
|
+
), children: section.title }),
|
|
349
|
+
/* @__PURE__ */ jsx3(ChevronIcon, { expanded, className: "text-gray-400 dark:text-gray-500" })
|
|
350
|
+
]
|
|
351
|
+
}
|
|
352
|
+
),
|
|
353
|
+
expanded && /* @__PURE__ */ jsx3("ul", { className: cn(
|
|
354
|
+
"border-l-2 border-gray-200 dark:border-gray-700",
|
|
355
|
+
compact ? "space-y-0.5" : "space-y-1.5"
|
|
356
|
+
), children: section.items.map((item) => /* @__PURE__ */ jsx3("li", { children: /* @__PURE__ */ jsx3(
|
|
357
|
+
Link,
|
|
358
|
+
{
|
|
359
|
+
href: item.href,
|
|
360
|
+
className: cn(
|
|
361
|
+
"block border-l-2 py-1 pl-4 leading-snug transition-colors -ml-0.5",
|
|
362
|
+
compact ? "text-sm" : "text-[15px]",
|
|
363
|
+
currentPath === item.href || currentPath + "/" === item.href ? "border-primary-500 text-gray-900 dark:text-white font-semibold" : "border-transparent text-gray-600 dark:text-gray-400 hover:border-primary-300 dark:hover:border-primary-400 hover:text-gray-900 dark:hover:text-white"
|
|
364
|
+
),
|
|
365
|
+
children: item.title
|
|
366
|
+
}
|
|
367
|
+
) }, item.href)) })
|
|
368
|
+
] });
|
|
369
|
+
}
|
|
370
|
+
function StaticSection({
|
|
371
|
+
section,
|
|
372
|
+
currentPath,
|
|
373
|
+
compact = false
|
|
374
|
+
}) {
|
|
375
|
+
return /* @__PURE__ */ jsxs3("div", { children: [
|
|
376
|
+
/* @__PURE__ */ jsx3("h3", { className: "mb-3 text-sm font-mono uppercase tracking-widest text-gray-500 dark:text-gray-400", children: section.title }),
|
|
377
|
+
/* @__PURE__ */ jsx3("ul", { className: cn(
|
|
378
|
+
"border-l-2 border-gray-200 dark:border-gray-700",
|
|
379
|
+
compact ? "space-y-0.5" : "space-y-1.5"
|
|
380
|
+
), children: section.items.map((item) => /* @__PURE__ */ jsx3("li", { children: /* @__PURE__ */ jsx3(
|
|
381
|
+
Link,
|
|
382
|
+
{
|
|
383
|
+
href: item.href,
|
|
384
|
+
className: cn(
|
|
385
|
+
"block border-l-2 py-1 pl-4 leading-snug transition-colors -ml-0.5",
|
|
386
|
+
compact ? "text-sm" : "text-[15px]",
|
|
387
|
+
currentPath === item.href || currentPath + "/" === item.href ? "border-primary-500 text-gray-900 dark:text-white font-semibold" : "border-transparent text-gray-600 dark:text-gray-400 hover:border-primary-300 dark:hover:border-primary-400 hover:text-gray-900 dark:hover:text-white"
|
|
388
|
+
),
|
|
389
|
+
children: item.title
|
|
390
|
+
}
|
|
391
|
+
) }, item.href)) })
|
|
392
|
+
] });
|
|
393
|
+
}
|
|
394
|
+
function Sidebar({
|
|
395
|
+
nav,
|
|
396
|
+
currentPath,
|
|
397
|
+
className,
|
|
398
|
+
docSets,
|
|
399
|
+
currentDocSet,
|
|
400
|
+
compact = false,
|
|
401
|
+
collapsible = false,
|
|
402
|
+
collapseThreshold = 10
|
|
403
|
+
}) {
|
|
316
404
|
return /* @__PURE__ */ jsxs3("nav", { className: cn("space-y-6", className), children: [
|
|
317
405
|
docSets && docSets.length > 1 && /* @__PURE__ */ jsx3(DocSetSelector, { docSets, currentDocSet: currentDocSet ?? "", className: "mb-6" }),
|
|
318
|
-
/* @__PURE__ */ jsx3("div", { className: "space-y-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
406
|
+
/* @__PURE__ */ jsx3("div", { className: compact ? "space-y-4" : "space-y-6", children: nav.map((section) => {
|
|
407
|
+
const shouldCollapse = collapsible && section.items.length > collapseThreshold;
|
|
408
|
+
const isActive = section.items.some(
|
|
409
|
+
(item) => currentPath === item.href || currentPath + "/" === item.href
|
|
410
|
+
);
|
|
411
|
+
if (shouldCollapse) {
|
|
412
|
+
return /* @__PURE__ */ jsx3(
|
|
413
|
+
CollapsibleSection,
|
|
414
|
+
{
|
|
415
|
+
section,
|
|
416
|
+
currentPath,
|
|
417
|
+
defaultExpanded: isActive,
|
|
418
|
+
compact
|
|
419
|
+
},
|
|
420
|
+
section.title
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
return /* @__PURE__ */ jsx3(
|
|
424
|
+
StaticSection,
|
|
322
425
|
{
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
) }, item.href)) })
|
|
331
|
-
] }, section.title)) })
|
|
426
|
+
section,
|
|
427
|
+
currentPath,
|
|
428
|
+
compact
|
|
429
|
+
},
|
|
430
|
+
section.title
|
|
431
|
+
);
|
|
432
|
+
}) })
|
|
332
433
|
] });
|
|
333
434
|
}
|
|
334
435
|
|
|
335
436
|
// src/components/TableOfContents.tsx
|
|
336
|
-
import { useEffect as useEffect3, useState as
|
|
437
|
+
import { useEffect as useEffect3, useState as useState4, useRef as useRef2 } from "react";
|
|
337
438
|
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
338
|
-
function TableOfContents({ items, className = "" }) {
|
|
339
|
-
const [activeId, setActiveId] =
|
|
439
|
+
function TableOfContents({ items, className = "", ...props }) {
|
|
440
|
+
const [activeId, setActiveId] = useState4(() => {
|
|
340
441
|
if (typeof window !== "undefined" && window.location.hash) {
|
|
341
442
|
return window.location.hash.slice(1);
|
|
342
443
|
}
|
|
@@ -440,9 +541,9 @@ function TableOfContents({ items, className = "" }) {
|
|
|
440
541
|
if (items.length === 0) {
|
|
441
542
|
return null;
|
|
442
543
|
}
|
|
443
|
-
return /* @__PURE__ */ jsxs4("nav", { className, children: [
|
|
444
|
-
/* @__PURE__ */ jsx4("h3", { className: "mb-3 text-
|
|
445
|
-
/* @__PURE__ */ jsx4("ul", { className: "space-y-1 border-l-2 border-gray-200 dark:border-gray-700", children: items.map((item) => {
|
|
544
|
+
return /* @__PURE__ */ jsxs4("nav", { className, ...props, children: [
|
|
545
|
+
/* @__PURE__ */ jsx4("h3", { className: "mb-3 text-sm font-mono uppercase tracking-widest text-gray-500 dark:text-gray-400", children: "On this page" }),
|
|
546
|
+
/* @__PURE__ */ jsx4("ul", { className: "space-y-1.5 border-l-2 border-gray-200 dark:border-gray-700", children: items.map((item) => {
|
|
446
547
|
const isActive = activeId === item.id;
|
|
447
548
|
const indent = item.level === 3 ? "pl-6" : "pl-4";
|
|
448
549
|
return /* @__PURE__ */ jsx4("li", { children: /* @__PURE__ */ jsx4(
|
|
@@ -450,8 +551,8 @@ function TableOfContents({ items, className = "" }) {
|
|
|
450
551
|
{
|
|
451
552
|
href: `#${item.id}`,
|
|
452
553
|
onClick: (e) => handleClick(e, item.id),
|
|
453
|
-
className: `block border-l-2 py-1
|
|
454
|
-
children: item.text
|
|
554
|
+
className: `block border-l-2 py-1 ${indent} -ml-0.5 text-base leading-snug transition-colors ${isActive ? "border-primary-500 text-gray-900 dark:text-white font-bold" : "border-transparent text-gray-600 dark:text-gray-300 hover:border-primary-300 dark:hover:border-primary-400 hover:text-gray-900 dark:hover:text-white"}`,
|
|
555
|
+
children: item.text || item.title
|
|
455
556
|
}
|
|
456
557
|
) }, item.id);
|
|
457
558
|
}) })
|
|
@@ -459,10 +560,10 @@ function TableOfContents({ items, className = "" }) {
|
|
|
459
560
|
}
|
|
460
561
|
|
|
461
562
|
// src/components/ThemeToggle.tsx
|
|
462
|
-
import { useState as
|
|
563
|
+
import { useState as useState6, useRef as useRef3, useEffect as useEffect5 } from "react";
|
|
463
564
|
|
|
464
565
|
// src/components/ThemeProvider.tsx
|
|
465
|
-
import { createContext, useContext, useEffect as useEffect4, useState as
|
|
566
|
+
import { createContext, useContext, useEffect as useEffect4, useState as useState5 } from "react";
|
|
466
567
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
467
568
|
var ThemeContext = createContext(null);
|
|
468
569
|
var STORAGE_KEY = "cross-docs-theme";
|
|
@@ -483,11 +584,11 @@ function ThemeProvider({
|
|
|
483
584
|
defaultTheme: defaultTheme2 = "system",
|
|
484
585
|
forcedTheme
|
|
485
586
|
}) {
|
|
486
|
-
const [theme, setThemeState] =
|
|
587
|
+
const [theme, setThemeState] = useState5(() => {
|
|
487
588
|
if (typeof window === "undefined") return defaultTheme2;
|
|
488
589
|
return getStoredTheme() ?? defaultTheme2;
|
|
489
590
|
});
|
|
490
|
-
const [resolvedTheme, setResolvedTheme] =
|
|
591
|
+
const [resolvedTheme, setResolvedTheme] = useState5(() => {
|
|
491
592
|
if (forcedTheme) return forcedTheme;
|
|
492
593
|
if (typeof window === "undefined") return "light";
|
|
493
594
|
if (theme === "system") return getSystemTheme();
|
|
@@ -562,7 +663,7 @@ var themeOptions = [
|
|
|
562
663
|
];
|
|
563
664
|
function ThemeToggle({ className, size = "md" }) {
|
|
564
665
|
const { theme, resolvedTheme, setTheme } = useTheme();
|
|
565
|
-
const [isOpen, setIsOpen] =
|
|
666
|
+
const [isOpen, setIsOpen] = useState6(false);
|
|
566
667
|
const dropdownRef = useRef3(null);
|
|
567
668
|
useEffect5(() => {
|
|
568
669
|
const handleClickOutside = (event) => {
|
|
@@ -728,12 +829,14 @@ function DocsLayout({
|
|
|
728
829
|
logoInvertedUrl: propLogoInvertedUrl,
|
|
729
830
|
githubUrl: propGithubUrl,
|
|
730
831
|
navLinks: propNavLinks,
|
|
832
|
+
header,
|
|
833
|
+
headerHeight = 64,
|
|
731
834
|
footer,
|
|
732
835
|
toc
|
|
733
836
|
}) {
|
|
734
837
|
const sharedProps = usePage().props;
|
|
735
838
|
const { nav, currentPath, docSets, currentDocSet } = sharedProps;
|
|
736
|
-
const [mobileMenuOpen, setMobileMenuOpen] =
|
|
839
|
+
const [mobileMenuOpen, setMobileMenuOpen] = useState7(false);
|
|
737
840
|
const { resolvedTheme } = useTheme();
|
|
738
841
|
const logoUrl = propLogoUrl ?? sharedProps.logoUrl;
|
|
739
842
|
const logoInvertedUrl = propLogoInvertedUrl ?? sharedProps.logoInvertedUrl;
|
|
@@ -746,7 +849,7 @@ function DocsLayout({
|
|
|
746
849
|
const footerLogo = logo || (currentFooterLogoUrl ? /* @__PURE__ */ jsx7("img", { src: currentFooterLogoUrl, alt: "Logo", className: "h-6" }) : null);
|
|
747
850
|
return /* @__PURE__ */ jsxs6("div", { className: "min-h-screen bg-white dark:bg-[#0f0f0f] flex flex-col transition-colors duration-200", children: [
|
|
748
851
|
/* @__PURE__ */ jsx7(Head, { title }),
|
|
749
|
-
/* @__PURE__ */ jsx7("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", children: /* @__PURE__ */ jsx7("div", { className: "px-4 lg:px-10", children: /* @__PURE__ */ jsxs6("div", { className: "flex justify-between h-16 items-center", children: [
|
|
852
|
+
(typeof header === "function" ? header({ mobileMenuOpen, toggleMobileMenu: () => setMobileMenuOpen(!mobileMenuOpen) }) : header) || /* @__PURE__ */ jsx7("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", children: /* @__PURE__ */ jsx7("div", { className: "px-4 lg:px-10", children: /* @__PURE__ */ jsxs6("div", { className: "flex justify-between h-16 items-center", children: [
|
|
750
853
|
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", children: [
|
|
751
854
|
/* @__PURE__ */ jsx7(MobileMenuButton, { onClick: () => setMobileMenuOpen(!mobileMenuOpen), isOpen: mobileMenuOpen }),
|
|
752
855
|
headerLogo ? /* @__PURE__ */ jsx7(Link2, { href: "/", className: "flex items-center", children: headerLogo }) : /* @__PURE__ */ jsx7(Link2, { href: "/", className: "font-bold text-lg text-gray-900 dark:text-white", children: "Docs" })
|
|
@@ -776,15 +879,43 @@ function DocsLayout({
|
|
|
776
879
|
] }) }) }),
|
|
777
880
|
mobileMenuOpen && /* @__PURE__ */ jsxs6("div", { className: "fixed inset-0 z-40 lg:hidden", children: [
|
|
778
881
|
/* @__PURE__ */ jsx7("div", { className: "fixed inset-0 bg-black/50 dark:bg-black/70", onClick: () => setMobileMenuOpen(false) }),
|
|
779
|
-
/* @__PURE__ */ jsx7(
|
|
882
|
+
/* @__PURE__ */ jsx7(
|
|
883
|
+
"div",
|
|
884
|
+
{
|
|
885
|
+
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",
|
|
886
|
+
style: { paddingTop: headerHeight + 16 },
|
|
887
|
+
children: /* @__PURE__ */ jsx7(Sidebar, { nav, currentPath, docSets, currentDocSet })
|
|
888
|
+
}
|
|
889
|
+
)
|
|
780
890
|
] }),
|
|
781
|
-
/* @__PURE__ */ jsx7("div", { className: "bg-white dark:bg-[#0f0f0f]
|
|
782
|
-
/* @__PURE__ */ jsx7(
|
|
891
|
+
/* @__PURE__ */ jsx7("div", { className: "bg-white dark:bg-[#0f0f0f] w-full flex-1 transition-colors", style: { paddingTop: headerHeight }, children: /* @__PURE__ */ jsxs6("div", { className: "flex", children: [
|
|
892
|
+
/* @__PURE__ */ jsx7(
|
|
893
|
+
"aside",
|
|
894
|
+
{
|
|
895
|
+
className: "hidden lg:block w-[24rem] shrink-0 border-r border-gray-200 dark:border-gray-800 transition-colors",
|
|
896
|
+
style: { minHeight: `calc(100vh - ${headerHeight}px)` },
|
|
897
|
+
children: /* @__PURE__ */ jsx7(
|
|
898
|
+
"nav",
|
|
899
|
+
{
|
|
900
|
+
className: "sticky px-4 lg:px-10 py-6 overflow-y-auto",
|
|
901
|
+
style: { top: headerHeight, maxHeight: `calc(100vh - ${headerHeight}px)` },
|
|
902
|
+
children: /* @__PURE__ */ jsx7(Sidebar, { nav, currentPath, docSets, currentDocSet })
|
|
903
|
+
}
|
|
904
|
+
)
|
|
905
|
+
}
|
|
906
|
+
),
|
|
783
907
|
/* @__PURE__ */ jsxs6("div", { className: "flex-1 min-w-0 flex flex-col", children: [
|
|
784
|
-
/* @__PURE__ */ jsxs6("div", { className: "flex
|
|
785
|
-
/* @__PURE__ */ jsx7("main", { className: "
|
|
786
|
-
toc && toc.length > 0 && /* @__PURE__ */ jsx7("aside", { className: "hidden xl:block w-
|
|
787
|
-
|
|
908
|
+
/* @__PURE__ */ jsx7("div", { className: "flex-1 p-4 lg:px-10 lg:py-6", children: /* @__PURE__ */ jsxs6("div", { className: "flex gap-5", children: [
|
|
909
|
+
/* @__PURE__ */ jsx7("main", { className: "min-w-0 w-full max-w-4xl", children: /* @__PURE__ */ jsx7("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", children }) }),
|
|
910
|
+
toc && toc.length > 0 && /* @__PURE__ */ jsx7("aside", { className: "hidden xl:block w-56 shrink-0 transition-colors", children: /* @__PURE__ */ jsx7(
|
|
911
|
+
TableOfContents,
|
|
912
|
+
{
|
|
913
|
+
items: toc,
|
|
914
|
+
className: "sticky overflow-y-auto",
|
|
915
|
+
style: { top: headerHeight + 24, maxHeight: `calc(100vh - ${headerHeight + 24}px)` }
|
|
916
|
+
}
|
|
917
|
+
) })
|
|
918
|
+
] }) }),
|
|
788
919
|
footer || /* @__PURE__ */ jsx7("footer", { className: "border-t border-gray-200 dark:border-gray-800 py-8 px-4 lg:px-10 transition-colors", children: /* @__PURE__ */ jsxs6("div", { className: "flex flex-col md:flex-row justify-between items-center gap-6", children: [
|
|
789
920
|
footerLogo && /* @__PURE__ */ jsx7(Link2, { href: "/", children: footerLogo }),
|
|
790
921
|
/* @__PURE__ */ jsxs6("div", { className: "flex gap-8 text-sm text-gray-600 dark:text-gray-400", children: [
|
|
@@ -974,11 +1105,11 @@ function DocsPage({ content, ...layoutProps }) {
|
|
|
974
1105
|
}
|
|
975
1106
|
|
|
976
1107
|
// src/components/EmojiConfetti.tsx
|
|
977
|
-
import { useState as
|
|
1108
|
+
import { useState as useState8, useCallback } from "react";
|
|
978
1109
|
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
979
1110
|
function EmojiConfetti({ children, emoji }) {
|
|
980
|
-
const [particles, setParticles] =
|
|
981
|
-
const [isActive, setIsActive] =
|
|
1111
|
+
const [particles, setParticles] = useState8([]);
|
|
1112
|
+
const [isActive, setIsActive] = useState8(false);
|
|
982
1113
|
const triggerBurst = useCallback(() => {
|
|
983
1114
|
if (isActive) return;
|
|
984
1115
|
setIsActive(true);
|
|
@@ -1041,7 +1172,7 @@ function EmojiConfetti({ children, emoji }) {
|
|
|
1041
1172
|
|
|
1042
1173
|
// src/components/HomePage.tsx
|
|
1043
1174
|
import { Head as Head2, Link as Link3 } from "@inertiajs/react";
|
|
1044
|
-
import { createContext as createContext3, useContext as useContext3, useState as
|
|
1175
|
+
import { createContext as createContext3, useContext as useContext3, useState as useState9 } from "react";
|
|
1045
1176
|
import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1046
1177
|
var HomePageContext = createContext3(null);
|
|
1047
1178
|
function useHomePage() {
|
|
@@ -1052,7 +1183,7 @@ function useHomePage() {
|
|
|
1052
1183
|
return context;
|
|
1053
1184
|
}
|
|
1054
1185
|
function InstallCommand({ command }) {
|
|
1055
|
-
const [copied, setCopied] =
|
|
1186
|
+
const [copied, setCopied] = useState9(false);
|
|
1056
1187
|
const copyToClipboard = async () => {
|
|
1057
1188
|
await navigator.clipboard.writeText(command);
|
|
1058
1189
|
setCopied(true);
|
|
@@ -1302,10 +1433,1130 @@ HomePage.Feature = HomeFeatureItem;
|
|
|
1302
1433
|
HomePage.CTA = HomeCTA;
|
|
1303
1434
|
HomePage.Footer = HomeFooter;
|
|
1304
1435
|
|
|
1436
|
+
// src/components/api/APILayout.tsx
|
|
1437
|
+
import { Head as Head3, Link as Link4, usePage as usePage2 } from "@inertiajs/react";
|
|
1438
|
+
import { useState as useState10 } from "react";
|
|
1439
|
+
import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1440
|
+
function GitHubIcon3() {
|
|
1441
|
+
return /* @__PURE__ */ jsx13("svg", { className: "w-6 h-6", fill: "currentColor", viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ jsx13(
|
|
1442
|
+
"path",
|
|
1443
|
+
{
|
|
1444
|
+
fillRule: "evenodd",
|
|
1445
|
+
d: "M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z",
|
|
1446
|
+
clipRule: "evenodd"
|
|
1447
|
+
}
|
|
1448
|
+
) });
|
|
1449
|
+
}
|
|
1450
|
+
function APILayout({
|
|
1451
|
+
children,
|
|
1452
|
+
title,
|
|
1453
|
+
apiNav,
|
|
1454
|
+
currentPath,
|
|
1455
|
+
logoUrl: propLogoUrl,
|
|
1456
|
+
logoInvertedUrl: propLogoInvertedUrl,
|
|
1457
|
+
footerLogoUrl: propFooterLogoUrl,
|
|
1458
|
+
footerLogoInvertedUrl: propFooterLogoInvertedUrl,
|
|
1459
|
+
githubUrl: propGithubUrl,
|
|
1460
|
+
navLinks: propNavLinks,
|
|
1461
|
+
rightSidebar,
|
|
1462
|
+
header,
|
|
1463
|
+
headerHeight: propHeaderHeight = 64,
|
|
1464
|
+
footer
|
|
1465
|
+
}) {
|
|
1466
|
+
const sharedProps = usePage2().props;
|
|
1467
|
+
const [mobileMenuOpen, setMobileMenuOpen] = useState10(false);
|
|
1468
|
+
const { resolvedTheme } = useTheme();
|
|
1469
|
+
const headerHeight = propHeaderHeight;
|
|
1470
|
+
const logoUrl = propLogoUrl ?? sharedProps.logoUrl;
|
|
1471
|
+
const logoInvertedUrl = propLogoInvertedUrl ?? sharedProps.logoInvertedUrl;
|
|
1472
|
+
const githubUrl = propGithubUrl ?? sharedProps.githubUrl;
|
|
1473
|
+
const navLinks = propNavLinks ?? sharedProps.navLinks ?? [];
|
|
1474
|
+
const headerLogo = logoInvertedUrl ? /* @__PURE__ */ jsx13("img", { src: logoInvertedUrl, alt: "Logo", className: "h-8" }) : logoUrl ? /* @__PURE__ */ jsx13("img", { src: logoUrl, alt: "Logo", className: "h-8" }) : null;
|
|
1475
|
+
const footerLogoUrl = propFooterLogoUrl || sharedProps.footerLogoUrl || logoUrl;
|
|
1476
|
+
const footerLogoInvertedUrl = propFooterLogoInvertedUrl || sharedProps.footerLogoInvertedUrl || logoInvertedUrl;
|
|
1477
|
+
const currentFooterLogoUrl = resolvedTheme === "dark" ? footerLogoInvertedUrl || footerLogoUrl : footerLogoUrl;
|
|
1478
|
+
const footerLogo = currentFooterLogoUrl ? /* @__PURE__ */ jsx13("img", { src: currentFooterLogoUrl, alt: "Logo", className: "h-6" }) : null;
|
|
1479
|
+
return /* @__PURE__ */ jsxs9("div", { className: "min-h-screen bg-white dark:bg-[#0f0f0f] flex flex-col transition-colors duration-200", children: [
|
|
1480
|
+
/* @__PURE__ */ jsx13(Head3, { title }),
|
|
1481
|
+
(typeof header === "function" ? header({ mobileMenuOpen, toggleMobileMenu: () => setMobileMenuOpen(!mobileMenuOpen) }) : header) || /* @__PURE__ */ jsx13("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", children: /* @__PURE__ */ jsx13("div", { className: "px-4 lg:px-10", children: /* @__PURE__ */ jsxs9("div", { className: "flex justify-between h-16 items-center", children: [
|
|
1482
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2", children: [
|
|
1483
|
+
/* @__PURE__ */ jsx13(MobileMenuButton, { onClick: () => setMobileMenuOpen(!mobileMenuOpen), isOpen: mobileMenuOpen }),
|
|
1484
|
+
headerLogo ? /* @__PURE__ */ jsx13(Link4, { href: "/", className: "flex items-center", children: headerLogo }) : /* @__PURE__ */ jsx13(Link4, { href: "/", className: "font-bold text-lg text-gray-900 dark:text-white", children: "Docs" })
|
|
1485
|
+
] }),
|
|
1486
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-6", children: [
|
|
1487
|
+
/* @__PURE__ */ jsx13("div", { className: "-mr-2", children: /* @__PURE__ */ jsx13(ThemeToggle, { size: "sm" }) }),
|
|
1488
|
+
navLinks.map((link) => /* @__PURE__ */ jsx13(
|
|
1489
|
+
Link4,
|
|
1490
|
+
{
|
|
1491
|
+
href: link.href,
|
|
1492
|
+
className: "hidden sm:block text-gray-700 dark:text-gray-300 font-medium hover:text-primary-600 dark:hover:text-primary-400 transition-colors",
|
|
1493
|
+
children: link.label
|
|
1494
|
+
},
|
|
1495
|
+
link.href
|
|
1496
|
+
)),
|
|
1497
|
+
githubUrl && /* @__PURE__ */ jsx13(
|
|
1498
|
+
"a",
|
|
1499
|
+
{
|
|
1500
|
+
href: githubUrl,
|
|
1501
|
+
target: "_blank",
|
|
1502
|
+
rel: "noopener noreferrer",
|
|
1503
|
+
className: "text-gray-700 dark:text-gray-300 hover:text-primary-600 dark:hover:text-primary-400 transition-colors",
|
|
1504
|
+
children: /* @__PURE__ */ jsx13(GitHubIcon3, {})
|
|
1505
|
+
}
|
|
1506
|
+
)
|
|
1507
|
+
] })
|
|
1508
|
+
] }) }) }),
|
|
1509
|
+
mobileMenuOpen && /* @__PURE__ */ jsxs9("div", { className: "fixed inset-0 z-40 lg:hidden", children: [
|
|
1510
|
+
/* @__PURE__ */ jsx13("div", { className: "fixed inset-0 bg-black/50 dark:bg-black/70", onClick: () => setMobileMenuOpen(false) }),
|
|
1511
|
+
/* @__PURE__ */ jsx13(
|
|
1512
|
+
"div",
|
|
1513
|
+
{
|
|
1514
|
+
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",
|
|
1515
|
+
style: { paddingTop: headerHeight + 16 },
|
|
1516
|
+
children: /* @__PURE__ */ jsx13(
|
|
1517
|
+
Sidebar,
|
|
1518
|
+
{
|
|
1519
|
+
nav: apiNav,
|
|
1520
|
+
currentPath
|
|
1521
|
+
}
|
|
1522
|
+
)
|
|
1523
|
+
}
|
|
1524
|
+
)
|
|
1525
|
+
] }),
|
|
1526
|
+
/* @__PURE__ */ jsx13("div", { className: "bg-white dark:bg-[#0f0f0f] w-full flex-1 transition-colors", style: { paddingTop: headerHeight }, children: /* @__PURE__ */ jsxs9("div", { className: "flex", children: [
|
|
1527
|
+
/* @__PURE__ */ jsx13(
|
|
1528
|
+
"aside",
|
|
1529
|
+
{
|
|
1530
|
+
className: "hidden lg:block w-64 shrink-0 border-r border-gray-200 dark:border-gray-800 transition-colors",
|
|
1531
|
+
style: { minHeight: `calc(100vh - ${headerHeight}px)` },
|
|
1532
|
+
children: /* @__PURE__ */ jsx13(
|
|
1533
|
+
"div",
|
|
1534
|
+
{
|
|
1535
|
+
className: "sticky px-6 py-6 overflow-y-auto",
|
|
1536
|
+
style: { top: headerHeight, maxHeight: `calc(100vh - ${headerHeight}px)` },
|
|
1537
|
+
children: /* @__PURE__ */ jsx13(
|
|
1538
|
+
Sidebar,
|
|
1539
|
+
{
|
|
1540
|
+
nav: apiNav,
|
|
1541
|
+
currentPath
|
|
1542
|
+
}
|
|
1543
|
+
)
|
|
1544
|
+
}
|
|
1545
|
+
)
|
|
1546
|
+
}
|
|
1547
|
+
),
|
|
1548
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex-1 min-w-0 flex flex-col", children: [
|
|
1549
|
+
/* @__PURE__ */ jsx13("div", { className: "flex-1 p-4 lg:px-10 lg:py-6", children: /* @__PURE__ */ jsxs9("div", { className: "flex gap-5", children: [
|
|
1550
|
+
/* @__PURE__ */ jsx13("main", { className: "min-w-0 w-full max-w-4xl", children }),
|
|
1551
|
+
rightSidebar && /* @__PURE__ */ jsx13("aside", { className: "hidden xl:block w-56 shrink-0 transition-colors", children: /* @__PURE__ */ jsx13(
|
|
1552
|
+
"div",
|
|
1553
|
+
{
|
|
1554
|
+
className: "sticky overflow-y-auto",
|
|
1555
|
+
style: { top: headerHeight + 24, maxHeight: `calc(100vh - ${headerHeight + 24}px)` },
|
|
1556
|
+
children: rightSidebar
|
|
1557
|
+
}
|
|
1558
|
+
) })
|
|
1559
|
+
] }) }),
|
|
1560
|
+
footer || /* @__PURE__ */ jsx13("footer", { className: "border-t border-gray-200 dark:border-gray-800 py-8 px-4 lg:px-10 transition-colors", children: /* @__PURE__ */ jsxs9("div", { className: "flex flex-col md:flex-row justify-between items-center gap-6", children: [
|
|
1561
|
+
footerLogo && /* @__PURE__ */ jsx13(Link4, { href: "/", children: footerLogo }),
|
|
1562
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex gap-8 text-sm text-gray-600 dark:text-gray-400", children: [
|
|
1563
|
+
navLinks.map((link) => /* @__PURE__ */ jsx13(Link4, { href: link.href, className: "hover:text-black dark:hover:text-white transition-colors", children: link.label }, link.href)),
|
|
1564
|
+
githubUrl && /* @__PURE__ */ jsx13(
|
|
1565
|
+
"a",
|
|
1566
|
+
{
|
|
1567
|
+
href: githubUrl,
|
|
1568
|
+
target: "_blank",
|
|
1569
|
+
rel: "noopener noreferrer",
|
|
1570
|
+
className: "hover:text-black dark:hover:text-white transition-colors",
|
|
1571
|
+
children: "GitHub"
|
|
1572
|
+
}
|
|
1573
|
+
)
|
|
1574
|
+
] })
|
|
1575
|
+
] }) })
|
|
1576
|
+
] })
|
|
1577
|
+
] }) })
|
|
1578
|
+
] });
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
// src/components/api/ModuleDoc.tsx
|
|
1582
|
+
import { Link as Link5 } from "@inertiajs/react";
|
|
1583
|
+
|
|
1584
|
+
// src/components/api/Docstring.tsx
|
|
1585
|
+
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1586
|
+
function renderExpression(expr) {
|
|
1587
|
+
if (!expr) return "";
|
|
1588
|
+
if (typeof expr === "string") return expr;
|
|
1589
|
+
if (expr.str) return expr.str;
|
|
1590
|
+
if (expr.canonical) return expr.canonical;
|
|
1591
|
+
const exprAny = expr;
|
|
1592
|
+
if (expr.name && typeof expr.name === "string") return expr.name;
|
|
1593
|
+
if (exprAny.cls === "ExprBoolOp" && exprAny.operator && Array.isArray(exprAny.values)) {
|
|
1594
|
+
return exprAny.values.map((v) => renderExpression(v)).join(` ${exprAny.operator} `);
|
|
1595
|
+
}
|
|
1596
|
+
if (exprAny.cls === "ExprBinOp" && exprAny.left && exprAny.right) {
|
|
1597
|
+
const left = renderExpression(exprAny.left);
|
|
1598
|
+
const right = renderExpression(exprAny.right);
|
|
1599
|
+
const op = exprAny.operator || "|";
|
|
1600
|
+
return `${left} ${op} ${right}`;
|
|
1601
|
+
}
|
|
1602
|
+
if (exprAny.cls === "ExprCall" && exprAny.function) {
|
|
1603
|
+
const funcName = renderExpression(exprAny.function);
|
|
1604
|
+
const args = Array.isArray(exprAny.arguments) ? exprAny.arguments.map((a) => renderExpression(a)).join(", ") : "";
|
|
1605
|
+
return `${funcName}(${args})`;
|
|
1606
|
+
}
|
|
1607
|
+
if (exprAny.cls === "ExprAttribute" && Array.isArray(exprAny.values)) {
|
|
1608
|
+
return exprAny.values.map((v) => renderExpression(v)).join(".");
|
|
1609
|
+
}
|
|
1610
|
+
if ("elements" in exprAny && Array.isArray(exprAny.elements)) {
|
|
1611
|
+
const inner = exprAny.elements.map((el) => renderExpression(el)).join(", ");
|
|
1612
|
+
return exprAny.cls === "ExprTuple" ? `(${inner})` : `[${inner}]`;
|
|
1613
|
+
}
|
|
1614
|
+
if (exprAny.cls === "ExprDict" && Array.isArray(exprAny.keys) && Array.isArray(exprAny.values)) {
|
|
1615
|
+
const pairs = exprAny.keys.map(
|
|
1616
|
+
(k, i) => `${renderExpression(k)}: ${renderExpression(exprAny.values[i])}`
|
|
1617
|
+
).join(", ");
|
|
1618
|
+
return `{${pairs}}`;
|
|
1619
|
+
}
|
|
1620
|
+
if (exprAny.left && exprAny.slice) {
|
|
1621
|
+
const left = renderExpression(exprAny.left);
|
|
1622
|
+
const slice = renderExpression(exprAny.slice);
|
|
1623
|
+
return `${left}[${slice}]`;
|
|
1624
|
+
}
|
|
1625
|
+
if ("slice" in exprAny && exprAny.slice && !exprAny.left) {
|
|
1626
|
+
return renderExpression(exprAny.slice);
|
|
1627
|
+
}
|
|
1628
|
+
if (typeof expr === "object") {
|
|
1629
|
+
return JSON.stringify(expr);
|
|
1630
|
+
}
|
|
1631
|
+
return String(expr);
|
|
1632
|
+
}
|
|
1633
|
+
function DocstringSection({ section }) {
|
|
1634
|
+
switch (section.kind) {
|
|
1635
|
+
case "text":
|
|
1636
|
+
return /* @__PURE__ */ jsx14("div", { className: "prose prose-sm dark:prose-invert max-w-none", children: /* @__PURE__ */ jsx14(Markdown, { content: section.value }) });
|
|
1637
|
+
case "parameters":
|
|
1638
|
+
return /* @__PURE__ */ jsxs10("div", { className: "mt-4", children: [
|
|
1639
|
+
/* @__PURE__ */ jsx14("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-2", children: "Parameters" }),
|
|
1640
|
+
/* @__PURE__ */ jsx14("dl", { className: "space-y-2", children: section.value?.map((param) => /* @__PURE__ */ jsxs10("div", { className: "grid grid-cols-[auto_1fr] gap-x-3", children: [
|
|
1641
|
+
/* @__PURE__ */ jsxs10("dt", { className: "font-mono text-sm", children: [
|
|
1642
|
+
/* @__PURE__ */ jsx14("span", { className: "text-orange-600 dark:text-orange-400", children: param.name }),
|
|
1643
|
+
param.annotation && /* @__PURE__ */ jsxs10("span", { className: "text-gray-500 dark:text-gray-400", children: [
|
|
1644
|
+
" ",
|
|
1645
|
+
"(",
|
|
1646
|
+
renderExpression(param.annotation),
|
|
1647
|
+
")"
|
|
1648
|
+
] })
|
|
1649
|
+
] }),
|
|
1650
|
+
/* @__PURE__ */ jsx14("dd", { className: "text-sm text-gray-600 dark:text-gray-300", children: param.description })
|
|
1651
|
+
] }, param.name)) })
|
|
1652
|
+
] });
|
|
1653
|
+
case "returns":
|
|
1654
|
+
return /* @__PURE__ */ jsxs10("div", { className: "mt-4", children: [
|
|
1655
|
+
/* @__PURE__ */ jsx14("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-2", children: "Returns" }),
|
|
1656
|
+
/* @__PURE__ */ jsx14("div", { className: "text-sm text-gray-600 dark:text-gray-300", children: Array.isArray(section.value) ? section.value.map((ret, i) => /* @__PURE__ */ jsxs10("div", { children: [
|
|
1657
|
+
ret.annotation && /* @__PURE__ */ jsx14("span", { className: "font-mono text-green-600 dark:text-green-400", children: renderExpression(ret.annotation) }),
|
|
1658
|
+
ret.description && /* @__PURE__ */ jsxs10("span", { children: [
|
|
1659
|
+
" - ",
|
|
1660
|
+
ret.description
|
|
1661
|
+
] })
|
|
1662
|
+
] }, i)) : section.value })
|
|
1663
|
+
] });
|
|
1664
|
+
case "raises":
|
|
1665
|
+
return /* @__PURE__ */ jsxs10("div", { className: "mt-4", children: [
|
|
1666
|
+
/* @__PURE__ */ jsx14("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-2", children: "Raises" }),
|
|
1667
|
+
/* @__PURE__ */ jsx14("dl", { className: "space-y-2", children: section.value?.map((exc, i) => /* @__PURE__ */ jsxs10("div", { className: "grid grid-cols-[auto_1fr] gap-x-3", children: [
|
|
1668
|
+
/* @__PURE__ */ jsx14("dt", { className: "font-mono text-sm text-red-600 dark:text-red-400", children: exc.annotation ? renderExpression(exc.annotation) : exc.name }),
|
|
1669
|
+
/* @__PURE__ */ jsx14("dd", { className: "text-sm text-gray-600 dark:text-gray-300", children: exc.description })
|
|
1670
|
+
] }, i)) })
|
|
1671
|
+
] });
|
|
1672
|
+
case "examples":
|
|
1673
|
+
return /* @__PURE__ */ jsxs10("div", { className: "mt-4", children: [
|
|
1674
|
+
/* @__PURE__ */ jsx14("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-2", children: "Examples" }),
|
|
1675
|
+
/* @__PURE__ */ jsx14("pre", { className: "bg-gray-100 dark:bg-gray-800 rounded-lg p-4 overflow-x-auto text-sm", children: /* @__PURE__ */ jsx14("code", { children: section.value }) })
|
|
1676
|
+
] });
|
|
1677
|
+
case "attributes":
|
|
1678
|
+
return /* @__PURE__ */ jsxs10("div", { className: "mt-4", children: [
|
|
1679
|
+
/* @__PURE__ */ jsx14("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-2", children: "Attributes" }),
|
|
1680
|
+
/* @__PURE__ */ jsx14("dl", { className: "space-y-2", children: section.value?.map((attr) => /* @__PURE__ */ jsxs10("div", { className: "grid grid-cols-[auto_1fr] gap-x-3", children: [
|
|
1681
|
+
/* @__PURE__ */ jsxs10("dt", { className: "font-mono text-sm", children: [
|
|
1682
|
+
/* @__PURE__ */ jsx14("span", { className: "text-orange-600 dark:text-orange-400", children: attr.name }),
|
|
1683
|
+
attr.annotation && /* @__PURE__ */ jsxs10("span", { className: "text-gray-500 dark:text-gray-400", children: [
|
|
1684
|
+
" ",
|
|
1685
|
+
"(",
|
|
1686
|
+
renderExpression(attr.annotation),
|
|
1687
|
+
")"
|
|
1688
|
+
] })
|
|
1689
|
+
] }),
|
|
1690
|
+
/* @__PURE__ */ jsx14("dd", { className: "text-sm text-gray-600 dark:text-gray-300", children: attr.description })
|
|
1691
|
+
] }, attr.name)) })
|
|
1692
|
+
] });
|
|
1693
|
+
case "deprecated":
|
|
1694
|
+
return /* @__PURE__ */ jsxs10("div", { className: "mt-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg", children: [
|
|
1695
|
+
/* @__PURE__ */ jsx14("h4", { className: "text-sm font-semibold text-yellow-800 dark:text-yellow-200 mb-1", children: "Deprecated" }),
|
|
1696
|
+
/* @__PURE__ */ jsx14("p", { className: "text-sm text-yellow-700 dark:text-yellow-300", children: section.value })
|
|
1697
|
+
] });
|
|
1698
|
+
case "admonition":
|
|
1699
|
+
return /* @__PURE__ */ jsxs10("div", { className: "mt-4 p-3 bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg", children: [
|
|
1700
|
+
section.title && /* @__PURE__ */ jsx14("h4", { className: "text-sm font-semibold text-blue-800 dark:text-blue-200 mb-1", children: section.title }),
|
|
1701
|
+
/* @__PURE__ */ jsx14("p", { className: "text-sm text-blue-700 dark:text-blue-300", children: section.value })
|
|
1702
|
+
] });
|
|
1703
|
+
default:
|
|
1704
|
+
if (section.title) {
|
|
1705
|
+
return /* @__PURE__ */ jsxs10("div", { className: "mt-4", children: [
|
|
1706
|
+
/* @__PURE__ */ jsx14("h4", { className: "text-sm font-semibold text-gray-900 dark:text-white mb-2", children: section.title }),
|
|
1707
|
+
/* @__PURE__ */ jsx14("div", { className: "text-sm text-gray-600 dark:text-gray-300", children: typeof section.value === "string" ? section.value : JSON.stringify(section.value) })
|
|
1708
|
+
] });
|
|
1709
|
+
}
|
|
1710
|
+
return null;
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
function Docstring({ docstring, raw = false, showOnlyText = false, className = "" }) {
|
|
1714
|
+
if (!docstring) return null;
|
|
1715
|
+
if (raw || !docstring.parsed || docstring.parsed.length === 0) {
|
|
1716
|
+
return /* @__PURE__ */ jsx14("div", { className: `prose prose-sm dark:prose-invert max-w-none ${className}`, children: /* @__PURE__ */ jsx14("p", { className: "whitespace-pre-wrap text-gray-600 dark:text-gray-300", children: docstring.value }) });
|
|
1717
|
+
}
|
|
1718
|
+
if (showOnlyText) {
|
|
1719
|
+
const firstTextSection = docstring.parsed.find((s) => s.kind === "text");
|
|
1720
|
+
if (!firstTextSection) return null;
|
|
1721
|
+
return /* @__PURE__ */ jsx14("div", { className: `prose prose-sm dark:prose-invert max-w-none ${className}`, children: /* @__PURE__ */ jsx14(Markdown, { content: firstTextSection.value }) });
|
|
1722
|
+
}
|
|
1723
|
+
return /* @__PURE__ */ jsx14("div", { className, children: docstring.parsed.map((section, i) => /* @__PURE__ */ jsx14(DocstringSection, { section }, `${section.kind}-${i}`)) });
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
// src/components/api/ClassDoc.tsx
|
|
1727
|
+
import { useState as useState12 } from "react";
|
|
1728
|
+
|
|
1729
|
+
// src/components/api/Signature.tsx
|
|
1730
|
+
import { useState as useState11 } from "react";
|
|
1731
|
+
import { Fragment as Fragment3, jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1732
|
+
function renderExpression2(expr) {
|
|
1733
|
+
if (!expr) return "";
|
|
1734
|
+
if (typeof expr === "string") return expr;
|
|
1735
|
+
if (expr.str) return expr.str;
|
|
1736
|
+
if (expr.canonical) return expr.canonical;
|
|
1737
|
+
const exprAny = expr;
|
|
1738
|
+
if (expr.name && typeof expr.name === "string") return expr.name;
|
|
1739
|
+
if (exprAny.cls === "ExprBoolOp" && exprAny.operator && Array.isArray(exprAny.values)) {
|
|
1740
|
+
return exprAny.values.map((v) => renderExpression2(v)).join(` ${exprAny.operator} `);
|
|
1741
|
+
}
|
|
1742
|
+
if (exprAny.cls === "ExprBinOp" && exprAny.left && exprAny.right) {
|
|
1743
|
+
const left = renderExpression2(exprAny.left);
|
|
1744
|
+
const right = renderExpression2(exprAny.right);
|
|
1745
|
+
const op = exprAny.operator || "|";
|
|
1746
|
+
return `${left} ${op} ${right}`;
|
|
1747
|
+
}
|
|
1748
|
+
if (exprAny.cls === "ExprCall" && exprAny.function) {
|
|
1749
|
+
const funcName = renderExpression2(exprAny.function);
|
|
1750
|
+
const args = Array.isArray(exprAny.arguments) ? exprAny.arguments.map((a) => renderExpression2(a)).join(", ") : "";
|
|
1751
|
+
return `${funcName}(${args})`;
|
|
1752
|
+
}
|
|
1753
|
+
if (exprAny.cls === "ExprAttribute" && Array.isArray(exprAny.values)) {
|
|
1754
|
+
return exprAny.values.map((v) => renderExpression2(v)).join(".");
|
|
1755
|
+
}
|
|
1756
|
+
if ("elements" in exprAny && Array.isArray(exprAny.elements)) {
|
|
1757
|
+
const inner = exprAny.elements.map((el) => renderExpression2(el)).join(", ");
|
|
1758
|
+
return exprAny.cls === "ExprTuple" ? `(${inner})` : `[${inner}]`;
|
|
1759
|
+
}
|
|
1760
|
+
if (exprAny.cls === "ExprDict" && Array.isArray(exprAny.keys) && Array.isArray(exprAny.values)) {
|
|
1761
|
+
const pairs = exprAny.keys.map(
|
|
1762
|
+
(k, i) => `${renderExpression2(k)}: ${renderExpression2(exprAny.values[i])}`
|
|
1763
|
+
).join(", ");
|
|
1764
|
+
return `{${pairs}}`;
|
|
1765
|
+
}
|
|
1766
|
+
if (exprAny.left && exprAny.slice) {
|
|
1767
|
+
const left = renderExpression2(exprAny.left);
|
|
1768
|
+
const slice = renderExpression2(exprAny.slice);
|
|
1769
|
+
return `${left}[${slice}]`;
|
|
1770
|
+
}
|
|
1771
|
+
if ("slice" in exprAny && exprAny.slice && !exprAny.left) {
|
|
1772
|
+
return renderExpression2(exprAny.slice);
|
|
1773
|
+
}
|
|
1774
|
+
if (typeof expr === "object") {
|
|
1775
|
+
return JSON.stringify(expr);
|
|
1776
|
+
}
|
|
1777
|
+
return String(expr);
|
|
1778
|
+
}
|
|
1779
|
+
function renderParameter(param) {
|
|
1780
|
+
let result = "";
|
|
1781
|
+
if (param.kind === "var-positional") {
|
|
1782
|
+
result = `*${param.name}`;
|
|
1783
|
+
} else if (param.kind === "var-keyword") {
|
|
1784
|
+
result = `**${param.name}`;
|
|
1785
|
+
} else {
|
|
1786
|
+
result = param.name;
|
|
1787
|
+
}
|
|
1788
|
+
if (param.annotation) {
|
|
1789
|
+
const annotation = renderExpression2(param.annotation);
|
|
1790
|
+
if (annotation) {
|
|
1791
|
+
result += `: ${annotation}`;
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
if (param.default) {
|
|
1795
|
+
result += ` = ${renderExpression2(param.default)}`;
|
|
1796
|
+
}
|
|
1797
|
+
return result;
|
|
1798
|
+
}
|
|
1799
|
+
function CopyIcon() {
|
|
1800
|
+
return /* @__PURE__ */ jsx15("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx15("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" }) });
|
|
1801
|
+
}
|
|
1802
|
+
function CheckIcon2() {
|
|
1803
|
+
return /* @__PURE__ */ jsx15("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx15("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) });
|
|
1804
|
+
}
|
|
1805
|
+
function Signature({ fn, showPath = false, className = "" }) {
|
|
1806
|
+
const [copied, setCopied] = useState11(false);
|
|
1807
|
+
const name = showPath && fn.path ? fn.path : fn.name;
|
|
1808
|
+
const isAsync = fn.is_async;
|
|
1809
|
+
const displayParams = fn.parameters?.filter((p) => p.name !== "self") ?? [];
|
|
1810
|
+
const returnType = renderExpression2(fn.returns);
|
|
1811
|
+
const buildParamString = (params) => {
|
|
1812
|
+
const parts = [];
|
|
1813
|
+
const hasVarPositional = params.some((p) => p.kind === "var-positional");
|
|
1814
|
+
let addedBareAsterisk = false;
|
|
1815
|
+
for (let i = 0; i < params.length; i++) {
|
|
1816
|
+
const param = params[i];
|
|
1817
|
+
const nextParam = params[i + 1];
|
|
1818
|
+
parts.push(renderParameter(param));
|
|
1819
|
+
if (param.kind === "positional-only" && nextParam && nextParam.kind !== "positional-only") {
|
|
1820
|
+
parts.push("/");
|
|
1821
|
+
}
|
|
1822
|
+
if (!hasVarPositional && !addedBareAsterisk && nextParam?.kind === "keyword-only" && param.kind !== "keyword-only") {
|
|
1823
|
+
parts.push("*");
|
|
1824
|
+
addedBareAsterisk = true;
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
return parts.join(", ");
|
|
1828
|
+
};
|
|
1829
|
+
const plainSignature = (() => {
|
|
1830
|
+
const params = buildParamString(displayParams);
|
|
1831
|
+
const prefix = isAsync ? "async def " : "def ";
|
|
1832
|
+
return returnType ? `${prefix}${name}(${params}) -> ${returnType}` : `${prefix}${name}(${params})`;
|
|
1833
|
+
})();
|
|
1834
|
+
const handleCopy = async () => {
|
|
1835
|
+
await navigator.clipboard.writeText(plainSignature);
|
|
1836
|
+
setCopied(true);
|
|
1837
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
1838
|
+
};
|
|
1839
|
+
const buildParamTokens = (params) => {
|
|
1840
|
+
const tokens = [];
|
|
1841
|
+
const hasVarPositional = params.some((p) => p.kind === "var-positional");
|
|
1842
|
+
let addedBareAsterisk = false;
|
|
1843
|
+
for (let i = 0; i < params.length; i++) {
|
|
1844
|
+
const param = params[i];
|
|
1845
|
+
const nextParam = params[i + 1];
|
|
1846
|
+
tokens.push({ type: "param", param });
|
|
1847
|
+
if (param.kind === "positional-only" && nextParam && nextParam.kind !== "positional-only") {
|
|
1848
|
+
tokens.push({ type: "separator", value: "/" });
|
|
1849
|
+
}
|
|
1850
|
+
if (!hasVarPositional && !addedBareAsterisk && nextParam?.kind === "keyword-only" && param.kind !== "keyword-only") {
|
|
1851
|
+
tokens.push({ type: "separator", value: "*" });
|
|
1852
|
+
addedBareAsterisk = true;
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
return tokens;
|
|
1856
|
+
};
|
|
1857
|
+
const paramTokens = buildParamTokens(displayParams);
|
|
1858
|
+
const renderParamElement = (param, multiline) => /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
1859
|
+
param.kind === "var-positional" && /* @__PURE__ */ jsx15("span", { className: "text-gray-400", children: "*" }),
|
|
1860
|
+
param.kind === "var-keyword" && /* @__PURE__ */ jsx15("span", { className: "text-gray-400", children: "**" }),
|
|
1861
|
+
/* @__PURE__ */ jsx15("span", { className: "text-orange-300", children: param.name }),
|
|
1862
|
+
param.annotation && /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
1863
|
+
/* @__PURE__ */ jsx15("span", { className: "text-gray-400", children: ": " }),
|
|
1864
|
+
/* @__PURE__ */ jsx15("span", { className: "text-emerald-400", children: renderExpression2(param.annotation) })
|
|
1865
|
+
] }),
|
|
1866
|
+
param.default && /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
1867
|
+
/* @__PURE__ */ jsx15("span", { className: "text-gray-400", children: " = " }),
|
|
1868
|
+
/* @__PURE__ */ jsx15("span", { className: "text-blue-300", children: renderExpression2(param.default) })
|
|
1869
|
+
] }),
|
|
1870
|
+
multiline && /* @__PURE__ */ jsx15("span", { className: "text-gray-400", children: "," })
|
|
1871
|
+
] });
|
|
1872
|
+
const needsMultiline = displayParams.length > 3;
|
|
1873
|
+
return /* @__PURE__ */ jsxs11("div", { className: `relative group ${className}`, children: [
|
|
1874
|
+
/* @__PURE__ */ jsx15("div", { className: "font-mono text-sm bg-gray-900 dark:bg-gray-950 rounded-lg p-4 overflow-x-auto", children: /* @__PURE__ */ jsxs11("code", { className: "text-gray-100", children: [
|
|
1875
|
+
isAsync && /* @__PURE__ */ jsx15("span", { className: "text-purple-400", children: "async " }),
|
|
1876
|
+
/* @__PURE__ */ jsx15("span", { className: "text-blue-400", children: "def" }),
|
|
1877
|
+
" ",
|
|
1878
|
+
/* @__PURE__ */ jsx15("span", { className: "text-yellow-300", children: name }),
|
|
1879
|
+
/* @__PURE__ */ jsx15("span", { className: "text-gray-400", children: "(" }),
|
|
1880
|
+
paramTokens.length > 0 && (needsMultiline ? (
|
|
1881
|
+
// Multi-line for many parameters
|
|
1882
|
+
/* @__PURE__ */ jsx15(Fragment3, { children: paramTokens.map((token, i) => token.type === "param" ? /* @__PURE__ */ jsx15("span", { className: "block pl-4", children: renderParamElement(token.param, true) }, token.param.name) : /* @__PURE__ */ jsx15("span", { className: "block pl-4", children: /* @__PURE__ */ jsxs11("span", { className: "text-gray-400", children: [
|
|
1883
|
+
token.value,
|
|
1884
|
+
","
|
|
1885
|
+
] }) }, `sep-${i}`)) })
|
|
1886
|
+
) : (
|
|
1887
|
+
// Single line for few parameters
|
|
1888
|
+
paramTokens.map((token, i) => token.type === "param" ? /* @__PURE__ */ jsxs11("span", { children: [
|
|
1889
|
+
i > 0 && /* @__PURE__ */ jsx15("span", { className: "text-gray-400", children: ", " }),
|
|
1890
|
+
renderParamElement(token.param, false)
|
|
1891
|
+
] }, token.param.name) : /* @__PURE__ */ jsx15("span", { children: /* @__PURE__ */ jsxs11("span", { className: "text-gray-400", children: [
|
|
1892
|
+
", ",
|
|
1893
|
+
token.value
|
|
1894
|
+
] }) }, `sep-${i}`))
|
|
1895
|
+
)),
|
|
1896
|
+
/* @__PURE__ */ jsx15("span", { className: "text-gray-400", children: ")" }),
|
|
1897
|
+
returnType && /* @__PURE__ */ jsxs11(Fragment3, { children: [
|
|
1898
|
+
/* @__PURE__ */ jsx15("span", { className: "text-gray-400", children: " -> " }),
|
|
1899
|
+
/* @__PURE__ */ jsx15("span", { className: "text-emerald-400", children: returnType })
|
|
1900
|
+
] }),
|
|
1901
|
+
/* @__PURE__ */ jsx15("span", { className: "text-gray-400", children: ":" }),
|
|
1902
|
+
/* @__PURE__ */ jsx15("span", { className: "block pl-2 text-gray-500", children: "..." })
|
|
1903
|
+
] }) }),
|
|
1904
|
+
/* @__PURE__ */ jsx15(
|
|
1905
|
+
"button",
|
|
1906
|
+
{
|
|
1907
|
+
onClick: handleCopy,
|
|
1908
|
+
className: "absolute top-3 right-3 p-1.5 rounded bg-gray-700 hover:bg-gray-600 opacity-0 group-hover:opacity-100 transition-opacity text-gray-300 hover:text-white",
|
|
1909
|
+
title: "Copy to clipboard",
|
|
1910
|
+
children: copied ? /* @__PURE__ */ jsx15(CheckIcon2, {}) : /* @__PURE__ */ jsx15(CopyIcon, {})
|
|
1911
|
+
}
|
|
1912
|
+
)
|
|
1913
|
+
] });
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
// src/components/api/CodeSpan.tsx
|
|
1917
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1918
|
+
function CodeSpan({ children, variant = "default", allowCopy = false, className }) {
|
|
1919
|
+
const handleCopy = () => {
|
|
1920
|
+
if (allowCopy && typeof children === "string") {
|
|
1921
|
+
navigator.clipboard.writeText(children);
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
if (variant === "simple") {
|
|
1925
|
+
return /* @__PURE__ */ jsx16(
|
|
1926
|
+
"code",
|
|
1927
|
+
{
|
|
1928
|
+
onClick: allowCopy ? handleCopy : void 0,
|
|
1929
|
+
className: cn(
|
|
1930
|
+
"font-mono text-[0.9em] font-semibold text-gray-900 dark:text-white",
|
|
1931
|
+
allowCopy && "cursor-pointer hover:text-primary-600 dark:hover:text-primary-400",
|
|
1932
|
+
className
|
|
1933
|
+
),
|
|
1934
|
+
children
|
|
1935
|
+
}
|
|
1936
|
+
);
|
|
1937
|
+
}
|
|
1938
|
+
return /* @__PURE__ */ jsx16(
|
|
1939
|
+
"code",
|
|
1940
|
+
{
|
|
1941
|
+
onClick: allowCopy ? handleCopy : void 0,
|
|
1942
|
+
className: cn(
|
|
1943
|
+
"inline-flex items-center px-2 py-0.5 rounded font-mono text-sm",
|
|
1944
|
+
"bg-red-50 text-red-600 border border-red-200",
|
|
1945
|
+
"dark:bg-red-900/20 dark:text-red-400 dark:border-red-800/50",
|
|
1946
|
+
allowCopy && "cursor-pointer hover:bg-red-100 dark:hover:bg-red-900/30",
|
|
1947
|
+
className
|
|
1948
|
+
),
|
|
1949
|
+
children
|
|
1950
|
+
}
|
|
1951
|
+
);
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
// src/components/api/ParameterTable.tsx
|
|
1955
|
+
import { Fragment as Fragment4, jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1956
|
+
function renderExpression3(expr) {
|
|
1957
|
+
if (!expr) return "";
|
|
1958
|
+
if (typeof expr === "string") return expr;
|
|
1959
|
+
if (expr.str) return expr.str;
|
|
1960
|
+
if (expr.canonical) return expr.canonical;
|
|
1961
|
+
const exprAny = expr;
|
|
1962
|
+
if (expr.name && typeof expr.name === "string") return expr.name;
|
|
1963
|
+
if (exprAny.cls === "ExprBoolOp" && exprAny.operator && Array.isArray(exprAny.values)) {
|
|
1964
|
+
return exprAny.values.map((v) => renderExpression3(v)).join(` ${exprAny.operator} `);
|
|
1965
|
+
}
|
|
1966
|
+
if (exprAny.cls === "ExprBinOp" && exprAny.left && exprAny.right) {
|
|
1967
|
+
const left = renderExpression3(exprAny.left);
|
|
1968
|
+
const right = renderExpression3(exprAny.right);
|
|
1969
|
+
const op = exprAny.operator || "|";
|
|
1970
|
+
return `${left} ${op} ${right}`;
|
|
1971
|
+
}
|
|
1972
|
+
if (exprAny.cls === "ExprCall" && exprAny.function) {
|
|
1973
|
+
const funcName = renderExpression3(exprAny.function);
|
|
1974
|
+
const args = Array.isArray(exprAny.arguments) ? exprAny.arguments.map((a) => renderExpression3(a)).join(", ") : "";
|
|
1975
|
+
return `${funcName}(${args})`;
|
|
1976
|
+
}
|
|
1977
|
+
if (exprAny.cls === "ExprAttribute" && Array.isArray(exprAny.values)) {
|
|
1978
|
+
return exprAny.values.map((v) => renderExpression3(v)).join(".");
|
|
1979
|
+
}
|
|
1980
|
+
if ("elements" in exprAny && Array.isArray(exprAny.elements)) {
|
|
1981
|
+
const inner = exprAny.elements.map((el) => renderExpression3(el)).join(", ");
|
|
1982
|
+
return exprAny.cls === "ExprTuple" ? `(${inner})` : `[${inner}]`;
|
|
1983
|
+
}
|
|
1984
|
+
if (exprAny.cls === "ExprDict" && Array.isArray(exprAny.keys) && Array.isArray(exprAny.values)) {
|
|
1985
|
+
const pairs = exprAny.keys.map(
|
|
1986
|
+
(k, i) => `${renderExpression3(k)}: ${renderExpression3(exprAny.values[i])}`
|
|
1987
|
+
).join(", ");
|
|
1988
|
+
return `{${pairs}}`;
|
|
1989
|
+
}
|
|
1990
|
+
if (exprAny.left && exprAny.slice) {
|
|
1991
|
+
const left = renderExpression3(exprAny.left);
|
|
1992
|
+
const slice = renderExpression3(exprAny.slice);
|
|
1993
|
+
return `${left}[${slice}]`;
|
|
1994
|
+
}
|
|
1995
|
+
if ("slice" in exprAny && exprAny.slice && !exprAny.left) {
|
|
1996
|
+
return renderExpression3(exprAny.slice);
|
|
1997
|
+
}
|
|
1998
|
+
if (typeof expr === "object") {
|
|
1999
|
+
return JSON.stringify(expr);
|
|
2000
|
+
}
|
|
2001
|
+
return String(expr);
|
|
2002
|
+
}
|
|
2003
|
+
function getParamDescription(paramName, docstringSections) {
|
|
2004
|
+
if (!docstringSections) return void 0;
|
|
2005
|
+
for (const section of docstringSections) {
|
|
2006
|
+
if (section.kind === "parameters" && Array.isArray(section.value)) {
|
|
2007
|
+
const param = section.value.find(
|
|
2008
|
+
(p) => p.name === paramName
|
|
2009
|
+
);
|
|
2010
|
+
if (param) return param.description;
|
|
2011
|
+
}
|
|
2012
|
+
}
|
|
2013
|
+
return void 0;
|
|
2014
|
+
}
|
|
2015
|
+
function ParameterTable({ parameters, docstringSections, className = "" }) {
|
|
2016
|
+
if (!parameters || parameters.length === 0) return null;
|
|
2017
|
+
const displayParams = parameters.filter((p) => p.name !== "self");
|
|
2018
|
+
if (displayParams.length === 0) return null;
|
|
2019
|
+
return /* @__PURE__ */ jsx17("ol", { className: `list-none p-0 ${className}`, children: displayParams.map((param, index) => {
|
|
2020
|
+
const description = getParamDescription(param.name, docstringSections);
|
|
2021
|
+
const annotation = renderExpression3(param.annotation);
|
|
2022
|
+
const defaultValue = renderExpression3(param.default);
|
|
2023
|
+
const isLast = index === displayParams.length - 1;
|
|
2024
|
+
return /* @__PURE__ */ jsx17(
|
|
2025
|
+
"li",
|
|
2026
|
+
{
|
|
2027
|
+
className: "contents",
|
|
2028
|
+
children: /* @__PURE__ */ jsxs12("div", { className: `grid grid-cols-[max-content_1fr] items-baseline gap-x-8 gap-y-2 py-6 ${!isLast ? "border-b border-gray-200 dark:border-gray-700" : ""}`, children: [
|
|
2029
|
+
/* @__PURE__ */ jsx17("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsxs12(CodeSpan, { children: [
|
|
2030
|
+
param.kind === "var-positional" && "*",
|
|
2031
|
+
param.kind === "var-keyword" && "**",
|
|
2032
|
+
param.name,
|
|
2033
|
+
":"
|
|
2034
|
+
] }) }),
|
|
2035
|
+
/* @__PURE__ */ jsxs12("div", { className: "space-y-3", children: [
|
|
2036
|
+
description && /* @__PURE__ */ jsx17("p", { className: "text-gray-700 dark:text-gray-300 leading-relaxed", children: description }),
|
|
2037
|
+
/* @__PURE__ */ jsxs12("dl", { className: "grid grid-cols-[auto_1fr] gap-x-4 gap-y-2", children: [
|
|
2038
|
+
annotation && /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
2039
|
+
/* @__PURE__ */ jsx17("dt", { className: "font-semibold text-gray-500 dark:text-gray-400", children: "Type" }),
|
|
2040
|
+
/* @__PURE__ */ jsx17("dd", { className: "m-0", children: /* @__PURE__ */ jsx17(CodeSpan, { children: annotation }) })
|
|
2041
|
+
] }),
|
|
2042
|
+
defaultValue && /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
2043
|
+
/* @__PURE__ */ jsx17("dt", { className: "font-semibold text-gray-500 dark:text-gray-400", children: "Default" }),
|
|
2044
|
+
/* @__PURE__ */ jsx17("dd", { className: "m-0", children: /* @__PURE__ */ jsx17(CodeSpan, { children: defaultValue }) })
|
|
2045
|
+
] })
|
|
2046
|
+
] })
|
|
2047
|
+
] })
|
|
2048
|
+
] })
|
|
2049
|
+
},
|
|
2050
|
+
param.name
|
|
2051
|
+
);
|
|
2052
|
+
}) });
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
// src/components/api/FunctionDoc.tsx
|
|
2056
|
+
import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2057
|
+
function FunctionDoc({ fn, isMethod = false, showName = true, githubUrl, className = "", displayPath }) {
|
|
2058
|
+
const hasParams = fn.parameters && fn.parameters.filter((p) => p.name !== "self").length > 0;
|
|
2059
|
+
const returnsSection = fn.docstring?.parsed?.find((s) => s.kind === "returns");
|
|
2060
|
+
const returnsValue = returnsSection?.value;
|
|
2061
|
+
const returnsDescription = Array.isArray(returnsValue) ? returnsValue[0]?.description : void 0;
|
|
2062
|
+
const textSections = fn.docstring?.parsed?.filter((s) => s.kind === "text") || [];
|
|
2063
|
+
const additionalTextSections = textSections.slice(1);
|
|
2064
|
+
const relativeFilepath = fn.relative_package_filepath || fn.relative_filepath || fn.filepath;
|
|
2065
|
+
const githubSourceUrl = githubUrl && relativeFilepath && fn.lineno ? `${githubUrl}/blob/main/${relativeFilepath}#L${fn.lineno}-L${fn.endlineno || fn.lineno}` : void 0;
|
|
2066
|
+
return /* @__PURE__ */ jsxs13("article", { id: fn.name, className: `scroll-mt-20 ${className}`, children: [
|
|
2067
|
+
showName && /* @__PURE__ */ jsx18("h1", { className: "font-mono text-2xl font-normal text-gray-900 dark:text-white mb-8", children: displayPath || fn.path || fn.name }),
|
|
2068
|
+
fn.docstring && /* @__PURE__ */ jsx18("div", { className: "mb-6", children: /* @__PURE__ */ jsx18(Docstring, { docstring: fn.docstring, showOnlyText: true }) }),
|
|
2069
|
+
returnsDescription && /* @__PURE__ */ jsxs13("section", { className: "mb-6", children: [
|
|
2070
|
+
/* @__PURE__ */ jsx18("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white mb-4", children: "Returns:" }),
|
|
2071
|
+
/* @__PURE__ */ jsx18("p", { className: "text-gray-700 dark:text-gray-300", children: returnsDescription })
|
|
2072
|
+
] }),
|
|
2073
|
+
/* @__PURE__ */ jsxs13("section", { className: "mb-6", children: [
|
|
2074
|
+
/* @__PURE__ */ jsx18("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white mb-4", children: "Signature:" }),
|
|
2075
|
+
/* @__PURE__ */ jsx18(Signature, { fn })
|
|
2076
|
+
] }),
|
|
2077
|
+
hasParams && /* @__PURE__ */ jsxs13("section", { id: "parameters", className: "mb-6", children: [
|
|
2078
|
+
/* @__PURE__ */ jsx18("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white mb-4", children: "Parameters:" }),
|
|
2079
|
+
/* @__PURE__ */ jsx18(
|
|
2080
|
+
ParameterTable,
|
|
2081
|
+
{
|
|
2082
|
+
parameters: fn.parameters,
|
|
2083
|
+
docstringSections: fn.docstring?.parsed
|
|
2084
|
+
}
|
|
2085
|
+
)
|
|
2086
|
+
] }),
|
|
2087
|
+
additionalTextSections.length > 0 && /* @__PURE__ */ jsx18("section", { className: "mb-6 prose prose-sm dark:prose-invert max-w-none", children: additionalTextSections.map((section, i) => /* @__PURE__ */ jsx18(Markdown, { content: section.value }, i)) }),
|
|
2088
|
+
!isMethod && relativeFilepath && /* @__PURE__ */ jsxs13("footer", { className: "mt-8 pt-6 border-t border-gray-200 dark:border-gray-700 space-y-4", children: [
|
|
2089
|
+
/* @__PURE__ */ jsxs13("p", { className: "flex items-center gap-2", children: [
|
|
2090
|
+
/* @__PURE__ */ jsx18("span", { className: "text-sm font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide", children: "File path:" }),
|
|
2091
|
+
/* @__PURE__ */ jsx18(CodeSpan, { allowCopy: true, children: relativeFilepath })
|
|
2092
|
+
] }),
|
|
2093
|
+
githubSourceUrl && /* @__PURE__ */ jsx18("p", { children: /* @__PURE__ */ jsx18(
|
|
2094
|
+
"a",
|
|
2095
|
+
{
|
|
2096
|
+
href: githubSourceUrl,
|
|
2097
|
+
target: "_blank",
|
|
2098
|
+
rel: "noopener noreferrer",
|
|
2099
|
+
className: "text-sm font-semibold text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 uppercase tracking-wide",
|
|
2100
|
+
children: "Open in GitHub"
|
|
2101
|
+
}
|
|
2102
|
+
) })
|
|
2103
|
+
] })
|
|
2104
|
+
] });
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
// src/components/api/ClassDoc.tsx
|
|
2108
|
+
import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2109
|
+
function renderExpression4(expr) {
|
|
2110
|
+
if (!expr) return "";
|
|
2111
|
+
if (typeof expr === "string") return expr;
|
|
2112
|
+
if (expr.str) return expr.str;
|
|
2113
|
+
if (expr.canonical) return expr.canonical;
|
|
2114
|
+
const exprAny = expr;
|
|
2115
|
+
if (expr.name && typeof expr.name === "string") return expr.name;
|
|
2116
|
+
if (exprAny.cls === "ExprBoolOp" && exprAny.operator && Array.isArray(exprAny.values)) {
|
|
2117
|
+
return exprAny.values.map((v) => renderExpression4(v)).join(` ${exprAny.operator} `);
|
|
2118
|
+
}
|
|
2119
|
+
if (exprAny.cls === "ExprBinOp" && exprAny.left && exprAny.right) {
|
|
2120
|
+
const left = renderExpression4(exprAny.left);
|
|
2121
|
+
const right = renderExpression4(exprAny.right);
|
|
2122
|
+
const op = exprAny.operator || "|";
|
|
2123
|
+
return `${left} ${op} ${right}`;
|
|
2124
|
+
}
|
|
2125
|
+
if (exprAny.cls === "ExprCall" && exprAny.function) {
|
|
2126
|
+
const funcName = renderExpression4(exprAny.function);
|
|
2127
|
+
const args = Array.isArray(exprAny.arguments) ? exprAny.arguments.map((a) => renderExpression4(a)).join(", ") : "";
|
|
2128
|
+
return `${funcName}(${args})`;
|
|
2129
|
+
}
|
|
2130
|
+
if (exprAny.cls === "ExprAttribute" && Array.isArray(exprAny.values)) {
|
|
2131
|
+
return exprAny.values.map((v) => renderExpression4(v)).join(".");
|
|
2132
|
+
}
|
|
2133
|
+
if ("elements" in exprAny && Array.isArray(exprAny.elements)) {
|
|
2134
|
+
const inner = exprAny.elements.map((el) => renderExpression4(el)).join(", ");
|
|
2135
|
+
return exprAny.cls === "ExprTuple" ? `(${inner})` : `[${inner}]`;
|
|
2136
|
+
}
|
|
2137
|
+
if (exprAny.cls === "ExprDict" && Array.isArray(exprAny.keys) && Array.isArray(exprAny.values)) {
|
|
2138
|
+
const pairs = exprAny.keys.map(
|
|
2139
|
+
(k, i) => `${renderExpression4(k)}: ${renderExpression4(exprAny.values[i])}`
|
|
2140
|
+
).join(", ");
|
|
2141
|
+
return `{${pairs}}`;
|
|
2142
|
+
}
|
|
2143
|
+
if (exprAny.left && exprAny.slice) {
|
|
2144
|
+
const left = renderExpression4(exprAny.left);
|
|
2145
|
+
const slice = renderExpression4(exprAny.slice);
|
|
2146
|
+
return `${left}[${slice}]`;
|
|
2147
|
+
}
|
|
2148
|
+
if ("slice" in exprAny && exprAny.slice && !exprAny.left) {
|
|
2149
|
+
return renderExpression4(exprAny.slice);
|
|
2150
|
+
}
|
|
2151
|
+
if (typeof expr === "object") {
|
|
2152
|
+
return JSON.stringify(expr);
|
|
2153
|
+
}
|
|
2154
|
+
return String(expr);
|
|
2155
|
+
}
|
|
2156
|
+
function CollapsibleMethod({ method }) {
|
|
2157
|
+
const [expanded, setExpanded] = useState12(false);
|
|
2158
|
+
return /* @__PURE__ */ jsxs14("div", { className: "border-b border-gray-200 dark:border-gray-700 last:border-b-0", children: [
|
|
2159
|
+
/* @__PURE__ */ jsxs14(
|
|
2160
|
+
"button",
|
|
2161
|
+
{
|
|
2162
|
+
onClick: () => setExpanded(!expanded),
|
|
2163
|
+
className: "w-full flex items-center gap-2 py-3 text-left hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",
|
|
2164
|
+
children: [
|
|
2165
|
+
/* @__PURE__ */ jsx19("span", { className: "font-mono text-base font-semibold text-gray-900 dark:text-white", children: method.name }),
|
|
2166
|
+
/* @__PURE__ */ jsx19("span", { className: "text-gray-400 text-sm", children: expanded ? "\u25B2" : "\u25BC" })
|
|
2167
|
+
]
|
|
2168
|
+
}
|
|
2169
|
+
),
|
|
2170
|
+
expanded && /* @__PURE__ */ jsx19("div", { className: "pb-6", children: /* @__PURE__ */ jsx19(FunctionDoc, { fn: method, isMethod: true, showName: false }) })
|
|
2171
|
+
] });
|
|
2172
|
+
}
|
|
2173
|
+
function ClassDoc({ cls, prefix: _prefix = "/api", currentPath: _currentPath, githubUrl, className = "", displayPath }) {
|
|
2174
|
+
const members = cls.members ?? {};
|
|
2175
|
+
const methods = [];
|
|
2176
|
+
const attributes = [];
|
|
2177
|
+
for (const member of Object.values(members)) {
|
|
2178
|
+
if (member.name.startsWith("_") && !member.name.startsWith("__")) continue;
|
|
2179
|
+
if (member.kind === "function") {
|
|
2180
|
+
methods.push(member);
|
|
2181
|
+
} else if (member.kind === "attribute") {
|
|
2182
|
+
attributes.push(member);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
const initMethod = methods.find((m) => m.name === "__init__");
|
|
2186
|
+
const publicMethods = methods.filter((m) => m.name !== "__init__" && !m.name.startsWith("_")).sort((a, b) => a.name.localeCompare(b.name));
|
|
2187
|
+
const publicAttributes = attributes.filter((a) => !a.name.startsWith("_")).sort((a, b) => a.name.localeCompare(b.name));
|
|
2188
|
+
const relativeFilepath = cls.relative_package_filepath || cls.relative_filepath || cls.filepath;
|
|
2189
|
+
const githubSourceUrl = githubUrl && relativeFilepath && cls.lineno ? `${githubUrl}/blob/main/${relativeFilepath}#L${cls.lineno}-L${cls.endlineno || cls.lineno}` : void 0;
|
|
2190
|
+
return /* @__PURE__ */ jsxs14("div", { className, children: [
|
|
2191
|
+
/* @__PURE__ */ jsx19("h1", { id: cls.name, className: "font-mono text-2xl font-normal text-gray-900 dark:text-white mb-8", children: displayPath || cls.path || cls.name }),
|
|
2192
|
+
initMethod && /* @__PURE__ */ jsxs14("section", { id: "constructor", className: "mb-8", children: [
|
|
2193
|
+
/* @__PURE__ */ jsx19("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white mb-4", children: "Constructor:" }),
|
|
2194
|
+
initMethod.docstring && /* @__PURE__ */ jsx19("div", { className: "mb-6", children: /* @__PURE__ */ jsx19(Docstring, { docstring: initMethod.docstring, showOnlyText: true }) }),
|
|
2195
|
+
/* @__PURE__ */ jsx19(FunctionDoc, { fn: initMethod, isMethod: true, showName: false })
|
|
2196
|
+
] }),
|
|
2197
|
+
!initMethod && cls.docstring && /* @__PURE__ */ jsx19("section", { className: "mb-8", children: /* @__PURE__ */ jsx19(Docstring, { docstring: cls.docstring }) }),
|
|
2198
|
+
publicMethods.length > 0 && /* @__PURE__ */ jsxs14("section", { id: "methods", className: "mb-8", children: [
|
|
2199
|
+
/* @__PURE__ */ jsx19("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white mb-4", children: "Methods:" }),
|
|
2200
|
+
/* @__PURE__ */ jsx19("div", { children: publicMethods.map((method) => /* @__PURE__ */ jsx19(CollapsibleMethod, { method }, method.name)) })
|
|
2201
|
+
] }),
|
|
2202
|
+
publicAttributes.length > 0 && /* @__PURE__ */ jsxs14("section", { id: "attributes", className: "mb-8", children: [
|
|
2203
|
+
/* @__PURE__ */ jsx19("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white mb-4", children: "Attributes:" }),
|
|
2204
|
+
/* @__PURE__ */ jsx19("div", { className: "space-y-2", children: publicAttributes.map((attr) => /* @__PURE__ */ jsxs14("div", { className: "flex items-baseline gap-2", children: [
|
|
2205
|
+
/* @__PURE__ */ jsxs14(CodeSpan, { children: [
|
|
2206
|
+
attr.name,
|
|
2207
|
+
":"
|
|
2208
|
+
] }),
|
|
2209
|
+
attr.annotation && /* @__PURE__ */ jsx19("span", { className: "text-sm text-gray-600 dark:text-gray-400 font-mono", children: renderExpression4(attr.annotation) })
|
|
2210
|
+
] }, attr.name)) })
|
|
2211
|
+
] }),
|
|
2212
|
+
relativeFilepath && /* @__PURE__ */ jsxs14("footer", { className: "mt-8 pt-6 border-t border-gray-200 dark:border-gray-700 space-y-4", children: [
|
|
2213
|
+
/* @__PURE__ */ jsxs14("p", { className: "flex items-center gap-2", children: [
|
|
2214
|
+
/* @__PURE__ */ jsx19("span", { className: "text-sm font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide", children: "File path:" }),
|
|
2215
|
+
/* @__PURE__ */ jsx19(CodeSpan, { allowCopy: true, children: relativeFilepath })
|
|
2216
|
+
] }),
|
|
2217
|
+
githubSourceUrl && /* @__PURE__ */ jsx19("p", { children: /* @__PURE__ */ jsx19(
|
|
2218
|
+
"a",
|
|
2219
|
+
{
|
|
2220
|
+
href: githubSourceUrl,
|
|
2221
|
+
target: "_blank",
|
|
2222
|
+
rel: "noopener noreferrer",
|
|
2223
|
+
className: "text-sm font-semibold text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 uppercase tracking-wide",
|
|
2224
|
+
children: "Open in GitHub"
|
|
2225
|
+
}
|
|
2226
|
+
) })
|
|
2227
|
+
] })
|
|
2228
|
+
] });
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
// src/components/api/ModuleDoc.tsx
|
|
2232
|
+
import { Fragment as Fragment5, jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2233
|
+
function renderValue(value) {
|
|
2234
|
+
if (!value) return "";
|
|
2235
|
+
if (typeof value === "string") return value;
|
|
2236
|
+
if (value.str) return value.str;
|
|
2237
|
+
if (value.canonical) return value.canonical;
|
|
2238
|
+
const exprAny = value;
|
|
2239
|
+
if (value.name && typeof value.name === "string") return value.name;
|
|
2240
|
+
if (exprAny.cls === "ExprBoolOp" && exprAny.operator && Array.isArray(exprAny.values)) {
|
|
2241
|
+
return exprAny.values.map((v) => renderValue(v)).join(` ${exprAny.operator} `);
|
|
2242
|
+
}
|
|
2243
|
+
if (exprAny.cls === "ExprBinOp" && exprAny.left && exprAny.right) {
|
|
2244
|
+
const left = renderValue(exprAny.left);
|
|
2245
|
+
const right = renderValue(exprAny.right);
|
|
2246
|
+
const op = exprAny.operator || "|";
|
|
2247
|
+
return `${left} ${op} ${right}`;
|
|
2248
|
+
}
|
|
2249
|
+
if (exprAny.cls === "ExprCall" && exprAny.function) {
|
|
2250
|
+
const funcName = renderValue(exprAny.function);
|
|
2251
|
+
const args = Array.isArray(exprAny.arguments) ? exprAny.arguments.map((a) => renderValue(a)).join(", ") : "";
|
|
2252
|
+
return `${funcName}(${args})`;
|
|
2253
|
+
}
|
|
2254
|
+
if (exprAny.cls === "ExprAttribute" && Array.isArray(exprAny.values)) {
|
|
2255
|
+
return exprAny.values.map((v) => renderValue(v)).join(".");
|
|
2256
|
+
}
|
|
2257
|
+
if ("elements" in exprAny && Array.isArray(exprAny.elements)) {
|
|
2258
|
+
const inner = exprAny.elements.map((el) => renderValue(el)).join(", ");
|
|
2259
|
+
return exprAny.cls === "ExprTuple" ? `(${inner})` : `[${inner}]`;
|
|
2260
|
+
}
|
|
2261
|
+
if (exprAny.cls === "ExprDict" && Array.isArray(exprAny.keys) && Array.isArray(exprAny.values)) {
|
|
2262
|
+
const pairs = exprAny.keys.map(
|
|
2263
|
+
(k, i) => `${renderValue(k)}: ${renderValue(exprAny.values[i])}`
|
|
2264
|
+
).join(", ");
|
|
2265
|
+
return `{${pairs}}`;
|
|
2266
|
+
}
|
|
2267
|
+
if (exprAny.left && exprAny.slice) {
|
|
2268
|
+
const left = renderValue(exprAny.left);
|
|
2269
|
+
const slice = renderValue(exprAny.slice);
|
|
2270
|
+
return `${left}[${slice}]`;
|
|
2271
|
+
}
|
|
2272
|
+
if ("slice" in exprAny && exprAny.slice && !exprAny.left) {
|
|
2273
|
+
return renderValue(exprAny.slice);
|
|
2274
|
+
}
|
|
2275
|
+
if (typeof value === "object") {
|
|
2276
|
+
return JSON.stringify(value);
|
|
2277
|
+
}
|
|
2278
|
+
return String(value);
|
|
2279
|
+
}
|
|
2280
|
+
function ModuleDoc({ module, prefix = "/api", showFull = true, className = "", displayPath, githubUrl }) {
|
|
2281
|
+
const members = module.members ?? {};
|
|
2282
|
+
const submodules = [];
|
|
2283
|
+
const classes = [];
|
|
2284
|
+
const functions = [];
|
|
2285
|
+
const attributes = [];
|
|
2286
|
+
for (const member of Object.values(members)) {
|
|
2287
|
+
switch (member.kind) {
|
|
2288
|
+
case "module":
|
|
2289
|
+
submodules.push(member);
|
|
2290
|
+
break;
|
|
2291
|
+
case "class":
|
|
2292
|
+
classes.push(member);
|
|
2293
|
+
break;
|
|
2294
|
+
case "function":
|
|
2295
|
+
functions.push(member);
|
|
2296
|
+
break;
|
|
2297
|
+
case "attribute":
|
|
2298
|
+
attributes.push(member);
|
|
2299
|
+
break;
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
submodules.sort((a, b) => a.name.localeCompare(b.name));
|
|
2303
|
+
classes.sort((a, b) => a.name.localeCompare(b.name));
|
|
2304
|
+
functions.sort((a, b) => a.name.localeCompare(b.name));
|
|
2305
|
+
attributes.sort((a, b) => a.name.localeCompare(b.name));
|
|
2306
|
+
const memberHref = (member) => {
|
|
2307
|
+
const modulePath = module.path || module.name;
|
|
2308
|
+
return `${prefix}/${modulePath}.${member.name}`;
|
|
2309
|
+
};
|
|
2310
|
+
return /* @__PURE__ */ jsxs15("div", { className, children: [
|
|
2311
|
+
/* @__PURE__ */ jsxs15("h1", { id: module.name, className: "text-3xl font-bold text-gray-900 dark:text-white mb-2", children: [
|
|
2312
|
+
/* @__PURE__ */ jsx20("span", { className: "text-gray-500 dark:text-gray-400 font-normal", children: "module " }),
|
|
2313
|
+
displayPath || module.path || module.name
|
|
2314
|
+
] }),
|
|
2315
|
+
module.docstring && /* @__PURE__ */ jsx20("div", { className: "mb-8", children: /* @__PURE__ */ jsx20(Docstring, { docstring: module.docstring }) }),
|
|
2316
|
+
submodules.length > 0 && /* @__PURE__ */ jsxs15("div", { className: "mb-8", children: [
|
|
2317
|
+
/* @__PURE__ */ jsx20("h2", { className: "text-xl font-semibold text-gray-900 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700", children: "Submodules" }),
|
|
2318
|
+
/* @__PURE__ */ jsx20("ul", { className: "grid grid-cols-1 md:grid-cols-2 gap-2", children: submodules.map((submodule) => /* @__PURE__ */ jsx20("li", { children: /* @__PURE__ */ jsxs15(
|
|
2319
|
+
Link5,
|
|
2320
|
+
{
|
|
2321
|
+
href: `${prefix}/${submodule.path || submodule.name}`,
|
|
2322
|
+
className: "block p-3 rounded-lg border border-gray-200 dark:border-gray-700 hover:border-primary-300 dark:hover:border-primary-600 transition-colors",
|
|
2323
|
+
children: [
|
|
2324
|
+
/* @__PURE__ */ jsx20("div", { className: "font-mono text-sm text-primary-600 dark:text-primary-400", children: submodule.path || submodule.name }),
|
|
2325
|
+
submodule.docstring && /* @__PURE__ */ jsx20("div", { className: "text-sm text-gray-600 dark:text-gray-300 mt-1 line-clamp-2", children: submodule.docstring.value.split("\n")[0] })
|
|
2326
|
+
]
|
|
2327
|
+
}
|
|
2328
|
+
) }, submodule.name)) })
|
|
2329
|
+
] }),
|
|
2330
|
+
classes.length > 0 && /* @__PURE__ */ jsxs15("div", { id: "classes", className: "mb-8", children: [
|
|
2331
|
+
/* @__PURE__ */ jsx20("h2", { className: "text-xl font-semibold text-gray-900 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700", children: "Classes" }),
|
|
2332
|
+
showFull ? /* @__PURE__ */ jsx20("div", { className: "space-y-12", children: classes.map((cls) => /* @__PURE__ */ jsx20(ClassDoc, { cls, prefix, githubUrl }, cls.name)) }) : /* @__PURE__ */ jsx20("ul", { className: "grid grid-cols-1 md:grid-cols-2 gap-2", children: classes.map((cls) => /* @__PURE__ */ jsx20("li", { children: /* @__PURE__ */ jsxs15(
|
|
2333
|
+
Link5,
|
|
2334
|
+
{
|
|
2335
|
+
href: memberHref(cls),
|
|
2336
|
+
className: "block p-3 rounded-lg border border-gray-200 dark:border-gray-700 hover:border-primary-300 dark:hover:border-primary-600 transition-colors",
|
|
2337
|
+
children: [
|
|
2338
|
+
/* @__PURE__ */ jsx20("div", { className: "font-mono text-sm text-primary-600 dark:text-primary-400", children: cls.name }),
|
|
2339
|
+
cls.docstring && /* @__PURE__ */ jsx20("div", { className: "text-sm text-gray-600 dark:text-gray-300 mt-1 line-clamp-2", children: cls.docstring.value.split("\n")[0] })
|
|
2340
|
+
]
|
|
2341
|
+
}
|
|
2342
|
+
) }, cls.name)) })
|
|
2343
|
+
] }),
|
|
2344
|
+
functions.length > 0 && /* @__PURE__ */ jsxs15("div", { id: "functions", className: "mb-8", children: [
|
|
2345
|
+
/* @__PURE__ */ jsx20("h2", { className: "text-xl font-semibold text-gray-900 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700", children: "Functions" }),
|
|
2346
|
+
showFull ? /* @__PURE__ */ jsx20("div", { className: "space-y-8", children: functions.map((fn) => /* @__PURE__ */ jsx20(FunctionDoc, { fn, githubUrl }, fn.name)) }) : /* @__PURE__ */ jsx20("ul", { className: "grid grid-cols-1 md:grid-cols-2 gap-2", children: functions.map((fn) => /* @__PURE__ */ jsx20("li", { children: /* @__PURE__ */ jsxs15(
|
|
2347
|
+
Link5,
|
|
2348
|
+
{
|
|
2349
|
+
href: memberHref(fn),
|
|
2350
|
+
className: "block p-3 rounded-lg border border-gray-200 dark:border-gray-700 hover:border-primary-300 dark:hover:border-primary-600 transition-colors",
|
|
2351
|
+
children: [
|
|
2352
|
+
/* @__PURE__ */ jsxs15("div", { className: "font-mono text-sm text-primary-600 dark:text-primary-400", children: [
|
|
2353
|
+
fn.name,
|
|
2354
|
+
"()"
|
|
2355
|
+
] }),
|
|
2356
|
+
fn.docstring && /* @__PURE__ */ jsx20("div", { className: "text-sm text-gray-600 dark:text-gray-300 mt-1 line-clamp-2", children: fn.docstring.value.split("\n")[0] })
|
|
2357
|
+
]
|
|
2358
|
+
}
|
|
2359
|
+
) }, fn.name)) })
|
|
2360
|
+
] }),
|
|
2361
|
+
attributes.length > 0 && /* @__PURE__ */ jsxs15("div", { className: "mb-8", children: [
|
|
2362
|
+
/* @__PURE__ */ jsx20("h2", { className: "text-xl font-semibold text-gray-900 dark:text-white mb-4 pb-2 border-b border-gray-200 dark:border-gray-700", children: "Attributes" }),
|
|
2363
|
+
/* @__PURE__ */ jsx20("dl", { className: "space-y-3", children: attributes.map((attr) => /* @__PURE__ */ jsxs15("div", { id: attr.name, className: "scroll-mt-20", children: [
|
|
2364
|
+
/* @__PURE__ */ jsxs15("dt", { className: "font-mono text-sm", children: [
|
|
2365
|
+
/* @__PURE__ */ jsx20("span", { className: "text-orange-600 dark:text-orange-400 font-semibold", children: attr.name }),
|
|
2366
|
+
attr.annotation && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
2367
|
+
/* @__PURE__ */ jsx20("span", { className: "text-gray-600 dark:text-gray-400", children: ": " }),
|
|
2368
|
+
/* @__PURE__ */ jsx20("span", { className: "text-green-600 dark:text-green-400", children: typeof attr.annotation === "string" ? attr.annotation : attr.annotation.str || attr.annotation.name })
|
|
2369
|
+
] }),
|
|
2370
|
+
attr.value && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
2371
|
+
/* @__PURE__ */ jsx20("span", { className: "text-gray-600 dark:text-gray-400", children: " = " }),
|
|
2372
|
+
/* @__PURE__ */ jsx20("span", { className: "text-cyan-600 dark:text-cyan-400", children: renderValue(attr.value) })
|
|
2373
|
+
] })
|
|
2374
|
+
] }),
|
|
2375
|
+
attr.docstring && /* @__PURE__ */ jsx20("dd", { className: "mt-1 text-sm text-gray-600 dark:text-gray-300 ml-4", children: attr.docstring.value })
|
|
2376
|
+
] }, attr.name)) })
|
|
2377
|
+
] }),
|
|
2378
|
+
(module.relative_package_filepath || module.filepath) && /* @__PURE__ */ jsx20("div", { className: "mt-4 text-xs text-gray-500 dark:text-gray-400", children: /* @__PURE__ */ jsx20("span", { className: "font-mono", children: module.relative_package_filepath || module.filepath }) })
|
|
2379
|
+
] });
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
// src/components/api/TableOfContents.tsx
|
|
2383
|
+
function generateClassToc(cls) {
|
|
2384
|
+
const items = [];
|
|
2385
|
+
items.push({ id: cls.name, title: cls.name, level: 1 });
|
|
2386
|
+
if (!cls.members) return items;
|
|
2387
|
+
const members = Object.values(cls.members);
|
|
2388
|
+
const methods = members.filter((m) => m.kind === "function");
|
|
2389
|
+
const initMethod = methods.find((m) => m.name === "__init__");
|
|
2390
|
+
const publicMethods = methods.filter((m) => m.name !== "__init__" && !m.name.startsWith("_")).sort((a, b) => a.name.localeCompare(b.name));
|
|
2391
|
+
const publicAttributes = members.filter((m) => m.kind === "attribute" && !m.name.startsWith("_")).sort((a, b) => a.name.localeCompare(b.name));
|
|
2392
|
+
if (initMethod) {
|
|
2393
|
+
items.push({ id: "constructor", title: "Constructor", level: 2 });
|
|
2394
|
+
}
|
|
2395
|
+
if (publicMethods.length > 0) {
|
|
2396
|
+
items.push({ id: "methods", title: "Methods", level: 2 });
|
|
2397
|
+
}
|
|
2398
|
+
if (publicAttributes.length > 0) {
|
|
2399
|
+
items.push({ id: "attributes", title: "Attributes", level: 2 });
|
|
2400
|
+
}
|
|
2401
|
+
return items;
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
// src/components/api/APIPage.tsx
|
|
2405
|
+
import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2406
|
+
function resolveAlias(alias, apiData) {
|
|
2407
|
+
const targetPath = alias.target_path;
|
|
2408
|
+
if (!targetPath) return null;
|
|
2409
|
+
const parts = targetPath.split(".");
|
|
2410
|
+
const packageName = apiData.name;
|
|
2411
|
+
let current = apiData;
|
|
2412
|
+
for (let i = 0; i < parts.length; i++) {
|
|
2413
|
+
const part = parts[i];
|
|
2414
|
+
if (i === 0 && part === packageName) continue;
|
|
2415
|
+
if (current.members) {
|
|
2416
|
+
const member = current.members[part];
|
|
2417
|
+
if (member) {
|
|
2418
|
+
if (member.kind === "module" || member.kind === "class") {
|
|
2419
|
+
current = member;
|
|
2420
|
+
} else {
|
|
2421
|
+
return member;
|
|
2422
|
+
}
|
|
2423
|
+
} else {
|
|
2424
|
+
return null;
|
|
2425
|
+
}
|
|
2426
|
+
} else {
|
|
2427
|
+
return null;
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
return current;
|
|
2431
|
+
}
|
|
2432
|
+
function generateTocItems(item, apiData) {
|
|
2433
|
+
if (item.kind === "alias") {
|
|
2434
|
+
const resolved = resolveAlias(item, apiData);
|
|
2435
|
+
if (resolved) {
|
|
2436
|
+
return generateTocItems(resolved, apiData);
|
|
2437
|
+
}
|
|
2438
|
+
return [];
|
|
2439
|
+
}
|
|
2440
|
+
if (item.kind === "class") {
|
|
2441
|
+
return generateClassToc(item);
|
|
2442
|
+
}
|
|
2443
|
+
if (item.kind === "function") {
|
|
2444
|
+
const fn = item;
|
|
2445
|
+
const items = [{ id: fn.name, title: fn.name, level: 1 }];
|
|
2446
|
+
if (fn.parameters && fn.parameters.length > 0) {
|
|
2447
|
+
items.push({ id: "parameters", title: "Parameters", level: 2 });
|
|
2448
|
+
}
|
|
2449
|
+
return items;
|
|
2450
|
+
}
|
|
2451
|
+
if (item.kind === "module") {
|
|
2452
|
+
const mod = item;
|
|
2453
|
+
const items = [{ id: mod.name, title: mod.name, level: 1 }];
|
|
2454
|
+
if (mod.members) {
|
|
2455
|
+
const members = Object.values(mod.members);
|
|
2456
|
+
const classes = members.filter((m) => m.kind === "class");
|
|
2457
|
+
const functions = members.filter((m) => m.kind === "function");
|
|
2458
|
+
if (classes.length > 0) {
|
|
2459
|
+
items.push({ id: "classes", title: "Classes", level: 2 });
|
|
2460
|
+
}
|
|
2461
|
+
if (functions.length > 0) {
|
|
2462
|
+
items.push({ id: "functions", title: "Functions", level: 2 });
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
return items;
|
|
2466
|
+
}
|
|
2467
|
+
return [];
|
|
2468
|
+
}
|
|
2469
|
+
function APIContent({
|
|
2470
|
+
item,
|
|
2471
|
+
prefix,
|
|
2472
|
+
currentPath,
|
|
2473
|
+
apiData,
|
|
2474
|
+
displayPath,
|
|
2475
|
+
githubUrl
|
|
2476
|
+
}) {
|
|
2477
|
+
if (item.kind === "alias") {
|
|
2478
|
+
const alias = item;
|
|
2479
|
+
const resolved = resolveAlias(alias, apiData);
|
|
2480
|
+
if (resolved) {
|
|
2481
|
+
const aliasDisplayPath = alias.path || `${apiData.name}.${alias.name}`;
|
|
2482
|
+
return /* @__PURE__ */ jsx21(APIContent, { item: resolved, prefix, currentPath, apiData, displayPath: aliasDisplayPath, githubUrl });
|
|
2483
|
+
}
|
|
2484
|
+
return /* @__PURE__ */ jsx21("div", { className: "text-gray-600 dark:text-gray-300", children: /* @__PURE__ */ jsxs16("p", { children: [
|
|
2485
|
+
"Could not resolve alias: ",
|
|
2486
|
+
alias.target_path
|
|
2487
|
+
] }) });
|
|
2488
|
+
}
|
|
2489
|
+
switch (item.kind) {
|
|
2490
|
+
case "module":
|
|
2491
|
+
return /* @__PURE__ */ jsx21(ModuleDoc, { module: item, prefix, showFull: true, displayPath, githubUrl });
|
|
2492
|
+
case "class":
|
|
2493
|
+
return /* @__PURE__ */ jsx21(ClassDoc, { cls: item, prefix, currentPath, displayPath, githubUrl });
|
|
2494
|
+
case "function":
|
|
2495
|
+
return /* @__PURE__ */ jsx21(FunctionDoc, { fn: item, displayPath, githubUrl });
|
|
2496
|
+
default:
|
|
2497
|
+
return /* @__PURE__ */ jsxs16("div", { className: "text-gray-600 dark:text-gray-300", children: [
|
|
2498
|
+
/* @__PURE__ */ jsxs16("p", { children: [
|
|
2499
|
+
"Unknown item type: ",
|
|
2500
|
+
item.kind
|
|
2501
|
+
] }),
|
|
2502
|
+
/* @__PURE__ */ jsx21("pre", { className: "mt-4 text-xs bg-gray-100 dark:bg-gray-800 p-4 rounded overflow-auto", children: JSON.stringify(item, null, 2) })
|
|
2503
|
+
] });
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
function APIPage({
|
|
2507
|
+
apiData,
|
|
2508
|
+
currentItem,
|
|
2509
|
+
currentPath,
|
|
2510
|
+
currentModule,
|
|
2511
|
+
apiNav,
|
|
2512
|
+
prefix,
|
|
2513
|
+
logoUrl,
|
|
2514
|
+
logoInvertedUrl,
|
|
2515
|
+
footerLogoUrl,
|
|
2516
|
+
footerLogoInvertedUrl,
|
|
2517
|
+
githubUrl,
|
|
2518
|
+
navLinks,
|
|
2519
|
+
header,
|
|
2520
|
+
headerHeight,
|
|
2521
|
+
footer
|
|
2522
|
+
}) {
|
|
2523
|
+
const itemToRender = currentItem || apiData;
|
|
2524
|
+
let title = "API Reference";
|
|
2525
|
+
if (itemToRender) {
|
|
2526
|
+
const name = itemToRender.name || currentModule;
|
|
2527
|
+
const kind = itemToRender.kind;
|
|
2528
|
+
title = `${name} (${kind}) - API Reference`;
|
|
2529
|
+
}
|
|
2530
|
+
const tocItems = itemToRender ? generateTocItems(itemToRender, apiData) : [];
|
|
2531
|
+
return /* @__PURE__ */ jsx21(
|
|
2532
|
+
APILayout,
|
|
2533
|
+
{
|
|
2534
|
+
title,
|
|
2535
|
+
apiNav,
|
|
2536
|
+
currentPath,
|
|
2537
|
+
logoUrl,
|
|
2538
|
+
logoInvertedUrl,
|
|
2539
|
+
footerLogoUrl,
|
|
2540
|
+
footerLogoInvertedUrl,
|
|
2541
|
+
githubUrl,
|
|
2542
|
+
navLinks,
|
|
2543
|
+
rightSidebar: tocItems.length > 0 ? /* @__PURE__ */ jsx21(TableOfContents, { items: tocItems }) : void 0,
|
|
2544
|
+
header,
|
|
2545
|
+
headerHeight,
|
|
2546
|
+
footer,
|
|
2547
|
+
children: /* @__PURE__ */ jsx21(APIContent, { item: itemToRender, prefix, currentPath, apiData, githubUrl })
|
|
2548
|
+
}
|
|
2549
|
+
);
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
// src/components/api/Breadcrumb.tsx
|
|
2553
|
+
import { Link as Link6 } from "@inertiajs/react";
|
|
2554
|
+
import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2555
|
+
|
|
1305
2556
|
// src/app.tsx
|
|
1306
2557
|
import { createInertiaApp } from "@inertiajs/react";
|
|
1307
2558
|
import { createRoot, hydrateRoot } from "react-dom/client";
|
|
1308
|
-
import { jsx as
|
|
2559
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1309
2560
|
function createDocsApp(config) {
|
|
1310
2561
|
const { pages, title, components } = config;
|
|
1311
2562
|
if (typeof window !== "undefined") {
|
|
@@ -1322,7 +2573,7 @@ function createDocsApp(config) {
|
|
|
1322
2573
|
return page;
|
|
1323
2574
|
},
|
|
1324
2575
|
setup({ el, App, props }) {
|
|
1325
|
-
const appElement = /* @__PURE__ */
|
|
2576
|
+
const appElement = /* @__PURE__ */ jsx23(ThemeProvider, { children: /* @__PURE__ */ jsx23(ComponentsProvider, { components, children: /* @__PURE__ */ jsx23(App, { ...props }) }) });
|
|
1326
2577
|
if (el.hasChildNodes()) {
|
|
1327
2578
|
hydrateRoot(el, appElement);
|
|
1328
2579
|
} else {
|
|
@@ -1332,11 +2583,16 @@ function createDocsApp(config) {
|
|
|
1332
2583
|
});
|
|
1333
2584
|
}
|
|
1334
2585
|
export {
|
|
2586
|
+
APILayout,
|
|
2587
|
+
APIPage,
|
|
2588
|
+
ClassDoc,
|
|
1335
2589
|
CodeBlock,
|
|
1336
2590
|
DocSetSelector,
|
|
1337
2591
|
DocsLayout,
|
|
1338
2592
|
DocsPage,
|
|
2593
|
+
Docstring,
|
|
1339
2594
|
EmojiConfetti,
|
|
2595
|
+
FunctionDoc,
|
|
1340
2596
|
HomeCTA,
|
|
1341
2597
|
HomeFeatureItem,
|
|
1342
2598
|
HomeFeatures,
|
|
@@ -1346,7 +2602,11 @@ export {
|
|
|
1346
2602
|
HomePage,
|
|
1347
2603
|
InlineCode,
|
|
1348
2604
|
Markdown,
|
|
2605
|
+
MobileMenuButton,
|
|
2606
|
+
ModuleDoc,
|
|
2607
|
+
ParameterTable,
|
|
1349
2608
|
Sidebar,
|
|
2609
|
+
Signature,
|
|
1350
2610
|
TableOfContents,
|
|
1351
2611
|
ThemeProvider,
|
|
1352
2612
|
ThemeToggle,
|