@openpkg-ts/doc-generator 0.1.2 → 0.2.1

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.
@@ -503,33 +503,34 @@ interface APIPageProps {
503
503
  spec?: OpenPkg7;
504
504
  /** Or docs instance from createDocs() */
505
505
  instance?: DocsInstance;
506
- /** Export ID to render */
507
- id: string;
506
+ /** Export ID to render, or undefined for index page */
507
+ id?: string;
508
+ /** Base href for index page links (required when id is undefined) */
509
+ baseHref?: string;
510
+ /** Description for index page */
511
+ description?: string;
508
512
  /** Custom code example renderer */
509
513
  renderExample?: (code: string, filename: string) => React.ReactNode;
510
514
  }
511
515
  /**
512
- * Main styled API page component that renders documentation for a single export.
516
+ * Main styled API page component that renders documentation.
517
+ *
518
+ * Renders either:
519
+ * - Index page (when id is undefined) showing all exports in a grid
520
+ * - Detail page (when id is provided) showing specific docs
513
521
  *
514
522
  * @example
515
523
  * ```tsx
516
- * import { APIPage } from '@openpkg-ts/doc-generator/react/styled'
517
- * import spec from './openpkg.json'
518
- *
519
- * <APIPage spec={spec} id="createClient" />
524
+ * // Index mode - show all exports
525
+ * <APIPage spec={spec} baseHref="/docs/api" />
520
526
  * ```
521
527
  *
522
528
  * @example
523
529
  * ```tsx
524
- * // With docs instance
525
- * import { APIPage } from '@openpkg-ts/doc-generator/react/styled'
526
- * import { createDocs } from '@openpkg-ts/doc-generator'
527
- *
528
- * const docs = createDocs('./openpkg.json')
529
- * <APIPage instance={docs} id="createClient" />
530
+ * // Detail mode - show specific * <APIPage spec={spec} id="createClient" />
530
531
  * ```
531
532
  */
532
- declare function APIPage({ spec, instance, id, renderExample }: APIPageProps): React.ReactNode;
533
+ declare function APIPage({ spec, instance, id, baseHref, description, renderExample }: APIPageProps): React.ReactNode;
533
534
  import { OpenPkg as OpenPkg8, SpecExport as SpecExport4 } from "@openpkg-ts/spec";
534
535
  interface ClassPageProps {
535
536
  export: SpecExport4;
@@ -541,6 +542,28 @@ interface ClassPageProps {
541
542
  * Styled class page component with Tailwind.
542
543
  */
543
544
  declare function ClassPage({ export: exp, spec, renderExample }: ClassPageProps): React.ReactNode;
545
+ import { ReactNode as ReactNode2 } from "react";
546
+ interface CodeTab {
547
+ /** Tab label */
548
+ label: string;
549
+ /** Tab content (code block) */
550
+ content: ReactNode2;
551
+ /** Raw code for copy button */
552
+ code: string;
553
+ }
554
+ interface CodeTabsProps {
555
+ /** Array of tabs */
556
+ tabs: CodeTab[];
557
+ /** Default selected tab index */
558
+ defaultIndex?: number;
559
+ /** Custom className */
560
+ className?: string;
561
+ }
562
+ /**
563
+ * Tabbed code block wrapper with copy button per tab.
564
+ * Integrates with any code rendering component.
565
+ */
566
+ declare function CodeTabs({ tabs, defaultIndex, className }: CodeTabsProps): React.ReactNode2;
544
567
  import { OpenPkg as OpenPkg9, SpecExport as SpecExport5 } from "@openpkg-ts/spec";
545
568
  interface EnumPageProps {
546
569
  export: SpecExport5;
@@ -552,21 +575,68 @@ interface EnumPageProps {
552
575
  * Styled enum page component with Tailwind.
553
576
  */
554
577
  declare function EnumPage({ export: exp, spec, renderExample }: EnumPageProps): React.ReactNode;
555
- import { OpenPkg as OpenPkg10, SpecExport as SpecExport6 } from "@openpkg-ts/spec";
578
+ interface ExportCardProps {
579
+ /** Function/name */
580
+ name: string;
581
+ /** Description snippet */
582
+ description?: string;
583
+ /** Link to detail page */
584
+ href: string;
585
+ /** Export kind: function, type, variable, class, interface, enum */
586
+ kind?: "function" | "type" | "variable" | "class" | "interface" | "enum";
587
+ /** Custom className */
588
+ className?: string;
589
+ }
590
+ /**
591
+ * Card component for displaying exports in an index grid.
592
+ * Features function name styling, description, and hover effects.
593
+ */
594
+ declare function ExportCard({ name, description, href, kind, className }: ExportCardProps): React.ReactNode;
595
+ import { OpenPkg as OpenPkg10 } from "@openpkg-ts/spec";
596
+ import { ReactNode as ReactNode3 } from "react";
597
+ interface ExportIndexPageProps {
598
+ /** OpenPkg spec */
599
+ spec: OpenPkg10;
600
+ /** Base href for links (e.g., '/docs/api') */
601
+ baseHref: string;
602
+ /** Optional intro description */
603
+ description?: string;
604
+ /** Custom className */
605
+ className?: string;
606
+ }
607
+ /**
608
+ * Index page showing all exports in a grid, grouped by category.
609
+ * AI SDK-style clean layout with responsive 2-column grid.
610
+ */
611
+ declare function ExportIndexPage({ spec, baseHref, description, className }: ExportIndexPageProps): ReactNode3;
612
+ import { OpenPkg as OpenPkg11, SpecExport as SpecExport6 } from "@openpkg-ts/spec";
613
+ import { ReactNode as ReactNode4 } from "react";
556
614
  interface FunctionPageProps {
557
615
  export: SpecExport6;
558
- spec: OpenPkg10;
616
+ spec: OpenPkg11;
559
617
  /** Custom code example renderer */
560
- renderExample?: (code: string, filename: string) => React.ReactNode;
618
+ renderExample?: (code: string, filename: string) => ReactNode4;
561
619
  }
562
620
  /**
563
- * Styled function page component with Tailwind.
621
+ * AI SDK-style function page with two-column layout.
622
+ * Left: parameters, returns. Right: sticky code examples.
564
623
  */
565
- declare function FunctionPage({ export: exp, spec, renderExample }: FunctionPageProps): React.ReactNode;
566
- import { OpenPkg as OpenPkg11, SpecExport as SpecExport7 } from "@openpkg-ts/spec";
624
+ declare function FunctionPage({ export: exp, spec, renderExample }: FunctionPageProps): ReactNode4;
625
+ interface ImportSectionProps {
626
+ /** Import statement text */
627
+ importStatement: string;
628
+ /** Custom className */
629
+ className?: string;
630
+ }
631
+ /**
632
+ * Displays a copyable import statement with one-click copy.
633
+ * Monospace styling with copy button.
634
+ */
635
+ declare function ImportSection({ importStatement, className }: ImportSectionProps): React.ReactNode;
636
+ import { OpenPkg as OpenPkg12, SpecExport as SpecExport7 } from "@openpkg-ts/spec";
567
637
  interface InterfacePageProps {
568
638
  export: SpecExport7;
569
- spec: OpenPkg11;
639
+ spec: OpenPkg12;
570
640
  /** Custom code example renderer */
571
641
  renderExample?: (code: string, filename: string) => React.ReactNode;
572
642
  }
@@ -574,10 +644,34 @@ interface InterfacePageProps {
574
644
  * Styled interface/type page component with Tailwind.
575
645
  */
576
646
  declare function InterfacePage({ export: exp, spec, renderExample }: InterfacePageProps): React.ReactNode;
577
- import { OpenPkg as OpenPkg12, SpecExport as SpecExport8 } from "@openpkg-ts/spec";
647
+ import { SpecSchema as SpecSchema2, SpecSignatureParameter as SpecSignatureParameter4 } from "@openpkg-ts/spec";
648
+ interface ParameterItemProps {
649
+ /** Parameter to display */
650
+ param: SpecSignatureParameter4;
651
+ /** Nesting depth for indentation */
652
+ depth?: number;
653
+ /** Custom className */
654
+ className?: string;
655
+ }
656
+ interface NestedPropertyItemProps {
657
+ /** Property name */
658
+ name: string;
659
+ /** Property schema */
660
+ schema: SpecSchema2;
661
+ /** Is this property required */
662
+ required?: boolean;
663
+ /** Nesting depth */
664
+ depth?: number;
665
+ }
666
+ /**
667
+ * Single parameter with expand capability for nested objects.
668
+ * Features expandable nested params, type annotations, and required/optional badges.
669
+ */
670
+ declare function ParameterItem({ param, depth, className }: ParameterItemProps): React.ReactNode;
671
+ import { OpenPkg as OpenPkg13, SpecExport as SpecExport8 } from "@openpkg-ts/spec";
578
672
  interface VariablePageProps {
579
673
  export: SpecExport8;
580
- spec: OpenPkg12;
674
+ spec: OpenPkg13;
581
675
  /** Custom code example renderer */
582
676
  renderExample?: (code: string, filename: string) => React.ReactNode;
583
677
  }
@@ -585,4 +679,4 @@ interface VariablePageProps {
585
679
  * Styled variable/constant page component with Tailwind.
586
680
  */
587
681
  declare function VariablePage({ export: exp, spec, renderExample }: VariablePageProps): React.ReactNode;
588
- export { groupMembersByKind, getExampleTitle, getExampleLanguage, getExampleCode, cleanCode, VariablePageProps, VariablePage, TypeTableProps, TypeTable, SignatureProps, Signature, ParamTableProps, ParamTable, ParamRowProps, ParamRow, NestedPropertyProps, NestedProperty, MembersTableProps, MembersTable, MemberRowProps, MemberRow, MemberGroups, InterfacePageProps, InterfacePage, FunctionPageProps, FunctionPage, ExpandablePropertyProps, ExpandableProperty, ExampleBlockProps, ExampleBlock, EnumPageProps, EnumPage, CollapsibleMethodProps, CollapsibleMethod, ClassPageProps, ClassPage, APIPageProps, APIPage };
682
+ export { groupMembersByKind, getExampleTitle, getExampleLanguage, getExampleCode, cleanCode, VariablePageProps, VariablePage, TypeTableProps, TypeTable, SignatureProps, Signature, ParameterItemProps, ParameterItem, ParamTableProps, ParamTable, ParamRowProps, ParamRow, NestedPropertyProps, NestedPropertyItemProps, NestedProperty, MembersTableProps, MembersTable, MemberRowProps, MemberRow, MemberGroups, InterfacePageProps, InterfacePage, ImportSectionProps, ImportSection, FunctionPageProps, FunctionPage, ExportIndexPageProps, ExportIndexPage, ExportCardProps, ExportCard, ExpandablePropertyProps, ExpandableProperty, ExampleBlockProps, ExampleBlock, EnumPageProps, EnumPage, CollapsibleMethodProps, CollapsibleMethod, CodeTabsProps, CodeTabs, CodeTab, ClassPageProps, ClassPage, APIPageProps, APIPage };