@openpkg-ts/doc-generator 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { OpenPkg as OpenPkg10, SpecExample as SpecExample2, SpecExport as SpecExport6, SpecExportKind as SpecExportKind5, SpecMember as SpecMember2, SpecSchema as SpecSchema3, SpecSignature as SpecSignature2, SpecSignatureParameter as SpecSignatureParameter2, SpecTag, SpecType as SpecType3, SpecTypeKind, SpecTypeParameter as SpecTypeParameter2 } from "@openpkg-ts/spec";
1
+ import { OpenPkg as OpenPkg10, SpecExample as SpecExample2, SpecExport as SpecExport6, SpecExportKind as SpecExportKind5, SpecMember as SpecMember3, SpecSchema as SpecSchema3, SpecSignature as SpecSignature2, SpecSignatureParameter as SpecSignatureParameter2, SpecTag, SpecType as SpecType3, SpecTypeKind, SpecTypeParameter as SpecTypeParameter2 } from "@openpkg-ts/spec";
2
2
  import { OpenPkg, SpecExport } from "@openpkg-ts/spec";
3
3
  import { ComponentType, ReactNode } from "react";
4
4
  /**
@@ -669,7 +669,17 @@ declare function loadSpec(spec: OpenPkg8): DocsInstance;
669
669
  * ```
670
670
  */
671
671
  declare function createDocs(input: string | OpenPkg8): DocsInstance;
672
- import { OpenPkg as OpenPkg9, SpecExport as SpecExport5, SpecMember, SpecSchema as SpecSchema2, SpecSignature, SpecType as SpecType2, SpecTypeParameter } from "@openpkg-ts/spec";
672
+ import { SpecMember } from "@openpkg-ts/spec";
673
+ /**
674
+ * Extract badge strings from a member's visibility and flags.
675
+ * Handles: visibility (if not public), static, readonly, async, abstract
676
+ */
677
+ declare function getMemberBadges(member: SpecMember): string[];
678
+ /**
679
+ * Format badges array into a display string (space-separated).
680
+ */
681
+ declare function formatBadges(badges: string[]): string;
682
+ import { OpenPkg as OpenPkg9, SpecExport as SpecExport5, SpecMember as SpecMember2, SpecSchema as SpecSchema2, SpecSignature, SpecType as SpecType2, SpecTypeParameter } from "@openpkg-ts/spec";
673
683
  /**
674
684
  * Format a schema to a human-readable type string.
675
685
  *
@@ -767,28 +777,28 @@ declare function resolveTypeRef(ref: string, spec: OpenPkg9): SpecType2 | undefi
767
777
  * isMethod({ name: 'bar', schema: { type: 'string' } }) // false
768
778
  * ```
769
779
  */
770
- declare function isMethod(member: SpecMember): boolean;
780
+ declare function isMethod(member: SpecMember2): boolean;
771
781
  /**
772
782
  * Check if a member is a property (no signatures).
773
783
  *
774
784
  * @param member - The member to check
775
785
  * @returns True if the member is a property
776
786
  */
777
- declare function isProperty(member: SpecMember): boolean;
787
+ declare function isProperty(member: SpecMember2): boolean;
778
788
  /**
779
789
  * Get methods from members list.
780
790
  *
781
791
  * @param members - Array of members to filter
782
792
  * @returns Array of method members
783
793
  */
784
- declare function getMethods(members?: SpecMember[]): SpecMember[];
794
+ declare function getMethods(members?: SpecMember2[]): SpecMember2[];
785
795
  /**
786
796
  * Get properties from members list.
787
797
  *
788
798
  * @param members - Array of members to filter
789
799
  * @returns Array of property members
790
800
  */
791
- declare function getProperties(members?: SpecMember[]): SpecMember[];
801
+ declare function getProperties(members?: SpecMember2[]): SpecMember2[];
792
802
  /**
793
803
  * Group members by visibility (public, protected, private).
794
804
  *
@@ -802,10 +812,10 @@ declare function getProperties(members?: SpecMember[]): SpecMember[];
802
812
  * groups.private // [{ name: 'bar', visibility: 'private' }]
803
813
  * ```
804
814
  */
805
- declare function groupByVisibility(members?: SpecMember[]): {
806
- public: SpecMember[];
807
- protected: SpecMember[];
808
- private: SpecMember[];
815
+ declare function groupByVisibility(members?: SpecMember2[]): {
816
+ public: SpecMember2[];
817
+ protected: SpecMember2[];
818
+ private: SpecMember2[];
809
819
  };
810
820
  /**
811
821
  * Sort exports alphabetically by name.
@@ -816,4 +826,4 @@ declare function groupByVisibility(members?: SpecMember[]): {
816
826
  declare function sortByName<T extends {
817
827
  name: string;
818
828
  }>(items: T[]): T[];
819
- export { toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toPagefindRecords2 as toPagefindRecords, toNavigation2 as toNavigation, toMarkdown2 as toMarkdown, toJSONString, toJSON2 as toJSON, toHTML2 as toHTML, toFumadocsMetaJSON, toDocusaurusSidebarJS, toAlgoliaRecords2 as toAlgoliaRecords, sortByName, resolveTypeRef, loadSpec, isProperty, isMethod, groupByVisibility, getProperties, getMethods, formatTypeParameters, formatSchema, formatReturnType, formatParameters, exportToMarkdown, createDocs, createAdapterRegistry, buildSignatureString, adapterRegistry, SpecTypeParameter2 as SpecTypeParameter, SpecTypeKind, SpecType3 as SpecType, SpecTag, SpecSignatureParameter2 as SpecSignatureParameter, SpecSignature2 as SpecSignature, SpecSchema3 as SpecSchema, SpecMember2 as SpecMember, SpecExportKind5 as SpecExportKind, SpecExport6 as SpecExport, SpecExample2 as SpecExample, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SearchRecord, SearchOptions, SearchIndex, SearchGeneratorOptions, PagefindRecord, PageGeneratorOptions, OpenPkg10 as OpenPkg, NavOptions, NavItem, NavGroup, NavGeneratorOptions, NavFormat, MarkdownOptions, LoadOptions, JSONOptions, HTMLOptions, GroupBy, GenericNav, GeneratedFile, FumadocsMetaItem, FumadocsMeta, FileGenerator, ExportPageProps, ExportMarkdownOptions, DocusaurusSidebarItem, DocusaurusSidebar, DocsInstance, DocFrameworkAdapter, ConfigValidationResult, ConfigOptions, ConfigHelper, AlgoliaRecord, AdapterRegistry, AdapterComponents, APIPageComponentProps };
829
+ export { toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toPagefindRecords2 as toPagefindRecords, toNavigation2 as toNavigation, toMarkdown2 as toMarkdown, toJSONString, toJSON2 as toJSON, toHTML2 as toHTML, toFumadocsMetaJSON, toDocusaurusSidebarJS, toAlgoliaRecords2 as toAlgoliaRecords, sortByName, resolveTypeRef, loadSpec, isProperty, isMethod, groupByVisibility, getProperties, getMethods, getMemberBadges, formatTypeParameters, formatSchema, formatReturnType, formatParameters, formatBadges, exportToMarkdown, createDocs, createAdapterRegistry, buildSignatureString, adapterRegistry, SpecTypeParameter2 as SpecTypeParameter, SpecTypeKind, SpecType3 as SpecType, SpecTag, SpecSignatureParameter2 as SpecSignatureParameter, SpecSignature2 as SpecSignature, SpecSchema3 as SpecSchema, SpecMember3 as SpecMember, SpecExportKind5 as SpecExportKind, SpecExport6 as SpecExport, SpecExample2 as SpecExample, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SearchRecord, SearchOptions, SearchIndex, SearchGeneratorOptions, PagefindRecord, PageGeneratorOptions, OpenPkg10 as OpenPkg, NavOptions, NavItem, NavGroup, NavGeneratorOptions, NavFormat, MarkdownOptions, LoadOptions, JSONOptions, HTMLOptions, GroupBy, GenericNav, GeneratedFile, FumadocsMetaItem, FumadocsMeta, FileGenerator, ExportPageProps, ExportMarkdownOptions, DocusaurusSidebarItem, DocusaurusSidebar, DocsInstance, DocFrameworkAdapter, ConfigValidationResult, ConfigOptions, ConfigHelper, AlgoliaRecord, AdapterRegistry, AdapterComponents, APIPageComponentProps };
package/dist/index.js CHANGED
@@ -43,6 +43,27 @@ function createAdapterRegistry() {
43
43
  };
44
44
  }
45
45
  var adapterRegistry = createAdapterRegistry();
46
+ // src/core/format.ts
47
+ function getMemberBadges(member) {
48
+ const badges = [];
49
+ const visibility = member.visibility ?? "public";
50
+ if (visibility !== "public") {
51
+ badges.push(visibility);
52
+ }
53
+ const flags = member.flags;
54
+ if (flags?.static)
55
+ badges.push("static");
56
+ if (flags?.readonly)
57
+ badges.push("readonly");
58
+ if (flags?.async)
59
+ badges.push("async");
60
+ if (flags?.abstract)
61
+ badges.push("abstract");
62
+ return badges;
63
+ }
64
+ function formatBadges(badges) {
65
+ return badges.join(" ");
66
+ }
46
67
  export {
47
68
  toSearchIndexJSON,
48
69
  toSearchIndex,
@@ -63,10 +84,12 @@ export {
63
84
  groupByVisibility,
64
85
  getProperties,
65
86
  getMethods,
87
+ getMemberBadges,
66
88
  formatTypeParameters,
67
89
  formatSchema,
68
90
  formatReturnType,
69
91
  formatParameters,
92
+ formatBadges,
70
93
  exportToMarkdown,
71
94
  createDocs,
72
95
  createAdapterRegistry,
@@ -670,6 +670,9 @@ interface NestedPropertyItemProps {
670
670
  /**
671
671
  * Single parameter with expand capability for nested objects.
672
672
  * Features expandable nested params, type annotations, and required/optional badges.
673
+ *
674
+ * @deprecated Use APIParameterItem from @doccov/ui with specParamToAPIParam adapter.
675
+ * Will be removed in next major version.
673
676
  */
674
677
  declare function ParameterItem({ param, depth, className }: ParameterItemProps): React.ReactNode;
675
678
  import { OpenPkg as OpenPkg14, SpecExport as SpecExport8 } from "@openpkg-ts/spec";
@@ -3432,6 +3432,25 @@ var require_link = __commonJS((exports, module) => {
3432
3432
  // src/components/headless/CollapsibleMethod.tsx
3433
3433
  import { useEffect, useState } from "react";
3434
3434
 
3435
+ // src/core/format.ts
3436
+ function getMemberBadges(member) {
3437
+ const badges = [];
3438
+ const visibility = member.visibility ?? "public";
3439
+ if (visibility !== "public") {
3440
+ badges.push(visibility);
3441
+ }
3442
+ const flags = member.flags;
3443
+ if (flags?.static)
3444
+ badges.push("static");
3445
+ if (flags?.readonly)
3446
+ badges.push("readonly");
3447
+ if (flags?.async)
3448
+ badges.push("async");
3449
+ if (flags?.abstract)
3450
+ badges.push("abstract");
3451
+ return badges;
3452
+ }
3453
+
3435
3454
  // src/core/query.ts
3436
3455
  function formatSchema(schema) {
3437
3456
  if (!schema)
@@ -3552,25 +3571,15 @@ function CollapsibleMethod({
3552
3571
  const [expanded, setExpanded] = useState(defaultExpanded);
3553
3572
  const sig = member.signatures?.[0];
3554
3573
  const hasParams = sig?.parameters && sig.parameters.length > 0;
3555
- const visibility = member.visibility ?? "public";
3556
- const flags = member.flags;
3557
- const isStatic = flags?.static;
3558
- const isAsync = flags?.async;
3559
3574
  const returnType = formatReturnType(sig);
3560
3575
  const paramPreview = formatParamPreview(sig?.parameters);
3576
+ const badges = getMemberBadges(member);
3561
3577
  const toggle = () => setExpanded(!expanded);
3562
3578
  useEffect(() => {
3563
3579
  if (typeof window !== "undefined" && window.location.hash === `#${member.name}`) {
3564
3580
  setExpanded(true);
3565
3581
  }
3566
3582
  }, [member.name]);
3567
- const badges = [];
3568
- if (visibility !== "public")
3569
- badges.push(visibility);
3570
- if (isStatic)
3571
- badges.push("static");
3572
- if (isAsync)
3573
- badges.push("async");
3574
3583
  return /* @__PURE__ */ jsxs("div", {
3575
3584
  id: member.name,
3576
3585
  className,
@@ -3911,11 +3920,6 @@ function groupMembersByKind(members) {
3911
3920
  return groups;
3912
3921
  }
3913
3922
  function MemberRow({ member }) {
3914
- const visibility = member.visibility ?? "public";
3915
- const flags = member.flags;
3916
- const isStatic = flags?.static;
3917
- const isAbstract = flags?.abstract;
3918
- const isReadonly = flags?.readonly;
3919
3923
  const type = formatSchema(member.schema);
3920
3924
  const sig = member.signatures?.[0];
3921
3925
  let signature = "";
@@ -3927,15 +3931,7 @@ function MemberRow({ member }) {
3927
3931
  const returnType = formatSchema(sig.returns?.schema) ?? "void";
3928
3932
  signature = `(${params.join(", ")}): ${returnType}`;
3929
3933
  }
3930
- const badges = [];
3931
- if (visibility !== "public")
3932
- badges.push(visibility);
3933
- if (isStatic)
3934
- badges.push("static");
3935
- if (isAbstract)
3936
- badges.push("abstract");
3937
- if (isReadonly)
3938
- badges.push("readonly");
3934
+ const badges = getMemberBadges(member);
3939
3935
  return /* @__PURE__ */ jsxs4("div", {
3940
3936
  "data-member": member.name,
3941
3937
  children: [
@@ -4338,7 +4334,7 @@ function formatMethodSignature(member) {
4338
4334
  const paramStr = params.map((p) => `${p.name}${p.required === false ? "?" : ""}: ${formatSchema(p.schema)}`).join(", ");
4339
4335
  return `(${paramStr}): ${returnType}`;
4340
4336
  }
4341
- function getMemberBadges(member) {
4337
+ function getMemberBadges2(member) {
4342
4338
  const badges = [];
4343
4339
  const flags = member.flags;
4344
4340
  if (member.visibility && member.visibility !== "public") {
@@ -4418,7 +4414,7 @@ const instance = new ${exp.name}(${constructorParams.map((p) => p.name).join(",
4418
4414
  className: "mt-6",
4419
4415
  children: [
4420
4416
  staticProperties.map((member) => {
4421
- const badges = getMemberBadges(member);
4417
+ const badges = getMemberBadges2(member);
4422
4418
  return /* @__PURE__ */ jsx8(APIParameterItem, {
4423
4419
  name: member.name,
4424
4420
  type: formatSchema(member.schema),
@@ -4426,7 +4422,7 @@ const instance = new ${exp.name}(${constructorParams.map((p) => p.name).join(",
4426
4422
  }, member.name);
4427
4423
  }),
4428
4424
  staticMethods.map((member) => {
4429
- const badges = getMemberBadges(member);
4425
+ const badges = getMemberBadges2(member);
4430
4426
  return /* @__PURE__ */ jsx8(APIParameterItem, {
4431
4427
  name: `${member.name}()`,
4432
4428
  type: formatMethodSignature(member),
@@ -4439,7 +4435,7 @@ const instance = new ${exp.name}(${constructorParams.map((p) => p.name).join(",
4439
4435
  title: "Methods",
4440
4436
  className: "mt-6",
4441
4437
  children: instanceMethods.map((member) => {
4442
- const badges = getMemberBadges(member);
4438
+ const badges = getMemberBadges2(member);
4443
4439
  return /* @__PURE__ */ jsx8(APIParameterItem, {
4444
4440
  name: `${member.name}()`,
4445
4441
  type: formatMethodSignature(member),
@@ -4451,7 +4447,7 @@ const instance = new ${exp.name}(${constructorParams.map((p) => p.name).join(",
4451
4447
  title: "Properties",
4452
4448
  className: "mt-6",
4453
4449
  children: instanceProperties.map((member) => {
4454
- const badges = getMemberBadges(member);
4450
+ const badges = getMemberBadges2(member);
4455
4451
  return /* @__PURE__ */ jsx8(APIParameterItem, {
4456
4452
  name: member.name,
4457
4453
  type: formatSchema(member.schema),
@@ -22716,7 +22712,7 @@ function ExportIndexPage({
22716
22712
  const availableKinds = useMemo(() => allGroups.map((g) => g.kind), [allGroups]);
22717
22713
  const totalExports = filteredGroups.reduce((sum, g) => sum + g.exports.length, 0);
22718
22714
  return /* @__PURE__ */ jsxs10("div", {
22719
- className: cn2("space-y-8 not-prose", className),
22715
+ className: cn2("doccov-index-page space-y-8 not-prose", className),
22720
22716
  children: [
22721
22717
  /* @__PURE__ */ jsxs10("div", {
22722
22718
  children: [
@@ -23394,7 +23390,7 @@ function FullAPIReferencePage({
23394
23390
  });
23395
23391
  const shouldShowFilters = showFilters && !kinds?.length && availableKinds.length > 1;
23396
23392
  return /* @__PURE__ */ jsxs15("div", {
23397
- className: cn3("not-prose", showTOC && "lg:grid lg:grid-cols-[220px_1fr] lg:gap-8", className),
23393
+ className: cn3("doccov-full-reference-page not-prose", showTOC && "lg:grid lg:grid-cols-[220px_1fr] lg:gap-8", className),
23398
23394
  children: [
23399
23395
  showTOC && /* @__PURE__ */ jsx22("aside", {
23400
23396
  className: "hidden lg:block",
package/dist/react.js CHANGED
@@ -20,6 +20,25 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
20
20
  // src/components/headless/CollapsibleMethod.tsx
21
21
  import { useEffect, useState } from "react";
22
22
 
23
+ // src/core/format.ts
24
+ function getMemberBadges(member) {
25
+ const badges = [];
26
+ const visibility = member.visibility ?? "public";
27
+ if (visibility !== "public") {
28
+ badges.push(visibility);
29
+ }
30
+ const flags = member.flags;
31
+ if (flags?.static)
32
+ badges.push("static");
33
+ if (flags?.readonly)
34
+ badges.push("readonly");
35
+ if (flags?.async)
36
+ badges.push("async");
37
+ if (flags?.abstract)
38
+ badges.push("abstract");
39
+ return badges;
40
+ }
41
+
23
42
  // src/core/query.ts
24
43
  function formatSchema(schema) {
25
44
  if (!schema)
@@ -140,25 +159,15 @@ function CollapsibleMethod({
140
159
  const [expanded, setExpanded] = useState(defaultExpanded);
141
160
  const sig = member.signatures?.[0];
142
161
  const hasParams = sig?.parameters && sig.parameters.length > 0;
143
- const visibility = member.visibility ?? "public";
144
- const flags = member.flags;
145
- const isStatic = flags?.static;
146
- const isAsync = flags?.async;
147
162
  const returnType = formatReturnType(sig);
148
163
  const paramPreview = formatParamPreview(sig?.parameters);
164
+ const badges = getMemberBadges(member);
149
165
  const toggle = () => setExpanded(!expanded);
150
166
  useEffect(() => {
151
167
  if (typeof window !== "undefined" && window.location.hash === `#${member.name}`) {
152
168
  setExpanded(true);
153
169
  }
154
170
  }, [member.name]);
155
- const badges = [];
156
- if (visibility !== "public")
157
- badges.push(visibility);
158
- if (isStatic)
159
- badges.push("static");
160
- if (isAsync)
161
- badges.push("async");
162
171
  return /* @__PURE__ */ jsxs("div", {
163
172
  id: member.name,
164
173
  className,
@@ -499,11 +508,6 @@ function groupMembersByKind(members) {
499
508
  return groups;
500
509
  }
501
510
  function MemberRow({ member }) {
502
- const visibility = member.visibility ?? "public";
503
- const flags = member.flags;
504
- const isStatic = flags?.static;
505
- const isAbstract = flags?.abstract;
506
- const isReadonly = flags?.readonly;
507
511
  const type = formatSchema(member.schema);
508
512
  const sig = member.signatures?.[0];
509
513
  let signature = "";
@@ -515,15 +519,7 @@ function MemberRow({ member }) {
515
519
  const returnType = formatSchema(sig.returns?.schema) ?? "void";
516
520
  signature = `(${params.join(", ")}): ${returnType}`;
517
521
  }
518
- const badges = [];
519
- if (visibility !== "public")
520
- badges.push(visibility);
521
- if (isStatic)
522
- badges.push("static");
523
- if (isAbstract)
524
- badges.push("abstract");
525
- if (isReadonly)
526
- badges.push("readonly");
522
+ const badges = getMemberBadges(member);
527
523
  return /* @__PURE__ */ jsxs4("div", {
528
524
  "data-member": member.name,
529
525
  children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/doc-generator",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "API doc generator consuming OpenPkg specs. TypeDoc alternative for modern doc frameworks.",
5
5
  "keywords": [
6
6
  "openpkg",
@@ -55,7 +55,7 @@
55
55
  "test:watch": "bun test --watch"
56
56
  },
57
57
  "dependencies": {
58
- "@doccov/ui": "^0.3.0",
58
+ "@doccov/ui": "^0.3.1",
59
59
  "@openpkg-ts/spec": "^0.11.1",
60
60
  "commander": "^14.0.0"
61
61
  },