@graphql-markdown/printer-legacy 1.14.0 → 1.16.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.
Files changed (71) hide show
  1. package/dist/badge.d.ts +10 -3
  2. package/dist/badge.d.ts.map +1 -1
  3. package/dist/badge.js +19 -9
  4. package/dist/code.d.ts +1 -1
  5. package/dist/code.d.ts.map +1 -1
  6. package/dist/common.d.ts +5 -13
  7. package/dist/common.d.ts.map +1 -1
  8. package/dist/common.js +5 -6
  9. package/dist/const/options.d.ts +11 -2
  10. package/dist/const/options.d.ts.map +1 -1
  11. package/dist/const/options.js +27 -10
  12. package/dist/const/strings.d.ts +1 -3
  13. package/dist/const/strings.d.ts.map +1 -1
  14. package/dist/const/strings.js +4 -6
  15. package/dist/directive.d.ts +4 -4
  16. package/dist/directive.d.ts.map +1 -1
  17. package/dist/directive.js +9 -12
  18. package/dist/events.d.ts +77 -0
  19. package/dist/events.d.ts.map +1 -0
  20. package/dist/events.js +85 -0
  21. package/dist/example.d.ts.map +1 -1
  22. package/dist/example.js +12 -7
  23. package/dist/format-helpers.d.ts +9 -0
  24. package/dist/format-helpers.d.ts.map +1 -1
  25. package/dist/format-helpers.js +10 -1
  26. package/dist/formatter.d.ts.map +1 -1
  27. package/dist/formatter.js +9 -30
  28. package/dist/frontmatter.d.ts.map +1 -1
  29. package/dist/graphql/directive.d.ts +4 -4
  30. package/dist/graphql/directive.d.ts.map +1 -1
  31. package/dist/graphql/directive.js +3 -3
  32. package/dist/graphql/enum.d.ts +4 -4
  33. package/dist/graphql/enum.d.ts.map +1 -1
  34. package/dist/graphql/enum.js +2 -2
  35. package/dist/graphql/input.d.ts.map +1 -1
  36. package/dist/graphql/input.js +1 -1
  37. package/dist/graphql/interface.d.ts.map +1 -1
  38. package/dist/graphql/interface.js +1 -1
  39. package/dist/graphql/object.d.ts +3 -3
  40. package/dist/graphql/object.d.ts.map +1 -1
  41. package/dist/graphql/object.js +4 -4
  42. package/dist/graphql/operation.d.ts +4 -12
  43. package/dist/graphql/operation.d.ts.map +1 -1
  44. package/dist/graphql/operation.js +43 -11
  45. package/dist/graphql/scalar.d.ts +6 -6
  46. package/dist/graphql/scalar.d.ts.map +1 -1
  47. package/dist/graphql/scalar.js +7 -7
  48. package/dist/graphql/union.d.ts +4 -4
  49. package/dist/graphql/union.d.ts.map +1 -1
  50. package/dist/graphql/union.js +2 -2
  51. package/dist/group.d.ts +2 -2
  52. package/dist/group.d.ts.map +1 -1
  53. package/dist/group.js +7 -6
  54. package/dist/index.d.ts +2 -0
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +6 -2
  57. package/dist/link.d.ts +6 -14
  58. package/dist/link.d.ts.map +1 -1
  59. package/dist/link.js +9 -9
  60. package/dist/mdx/index.d.ts +1 -1
  61. package/dist/mdx/index.d.ts.map +1 -1
  62. package/dist/mdx/index.js +2 -2
  63. package/dist/printer.d.ts +51 -34
  64. package/dist/printer.d.ts.map +1 -1
  65. package/dist/printer.js +234 -118
  66. package/dist/relation.d.ts +2 -2
  67. package/dist/relation.d.ts.map +1 -1
  68. package/dist/section.d.ts +5 -5
  69. package/dist/section.d.ts.map +1 -1
  70. package/dist/section.js +26 -11
  71. package/package.json +18 -6
package/dist/group.js CHANGED
@@ -20,15 +20,16 @@ const getGroup = (type, groups, typeCategory) => {
20
20
  return "";
21
21
  }
22
22
  const graphQLNamedType = (0, graphql_1.getNamedType)(type);
23
- if (!graphQLNamedType) {
23
+ const typeName = (0, utils_1.hasStringProperty)(graphQLNamedType, "name")
24
+ ? graphQLNamedType.name
25
+ : "";
26
+ if (!typeName) {
24
27
  return "";
25
28
  }
26
- const typeName = "name" in graphQLNamedType
27
- ? graphQLNamedType.name
28
- : String(graphQLNamedType);
29
- if (!(typeCategory in groups && typeName in groups[typeCategory])) {
29
+ const categoryGroups = groups[typeCategory];
30
+ if (!categoryGroups || !(typeName in categoryGroups)) {
30
31
  return "";
31
32
  }
32
- return (0, utils_1.slugify)(groups[typeCategory][typeName]);
33
+ return (0, utils_1.slugify)(categoryGroups[typeName]);
33
34
  };
34
35
  exports.getGroup = getGroup;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export { Printer } from "./printer";
2
+ export { PrintCodeEvent, PrintTypeEvent, BeforeComposePageTypeEvent, } from "./events";
3
+ export type { PageSection, PageSections, PrintCodeEventData, PrintTypeEventData, ComposePageTypeEventData, } from "./events";
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,cAAc,EACd,cAAc,EACd,0BAA0B,GAC3B,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Printer = void 0;
4
- const printer_1 = require("./printer");
3
+ exports.BeforeComposePageTypeEvent = exports.PrintTypeEvent = exports.PrintCodeEvent = exports.Printer = void 0;
4
+ var printer_1 = require("./printer");
5
5
  Object.defineProperty(exports, "Printer", { enumerable: true, get: function () { return printer_1.Printer; } });
6
+ var events_1 = require("./events");
7
+ Object.defineProperty(exports, "PrintCodeEvent", { enumerable: true, get: function () { return events_1.PrintCodeEvent; } });
8
+ Object.defineProperty(exports, "PrintTypeEvent", { enumerable: true, get: function () { return events_1.PrintTypeEvent; } });
9
+ Object.defineProperty(exports, "BeforeComposePageTypeEvent", { enumerable: true, get: function () { return events_1.BeforeComposePageTypeEvent; } });
package/dist/link.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Provides utilities for creating, formatting, and managing links to GraphQL types and operations.
4
4
  * @packageDocumentation
5
5
  */
6
- import type { ApiGroupOverrideType, MDXString, Maybe, PrintLinkOptions, PrintTypeOptions, TypeDeprecatedOption, TypeLink, TypeLocale } from "@graphql-markdown/types";
6
+ import type { ApiGroupOverrideType, MDXString, Maybe, PrintLinkOptions, PrintTypeOptions, TypeLink, TypeLocale } from "@graphql-markdown/types";
7
7
  export declare const API_GROUPS: Required<ApiGroupOverrideType>;
8
8
  /**
9
9
  * Checks if a type has printable directives based on the provided options.
@@ -12,7 +12,7 @@ export declare const API_GROUPS: Required<ApiGroupOverrideType>;
12
12
  * @param options - Configuration options for directive printing (`deprecated`, `onlyDocDirectives`, `skipDocDirectives`)
13
13
  * @returns `true` if the type should be printed, `false` otherwise
14
14
  */
15
- export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives"> | undefined) => boolean;
15
+ export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives">) => boolean;
16
16
  /**
17
17
  * Gets the locale category for a given GraphQL type.
18
18
  *
@@ -49,15 +49,7 @@ export declare const hasOptionParentType: (options: PrintLinkOptions) => boolean
49
49
  * @param groups - The group options
50
50
  * @returns The folder name for the API group
51
51
  */
52
- export declare const getLinkApiGroupFolder: (type: unknown, groups?: Maybe<boolean | ApiGroupOverrideType>) => string;
53
- /**
54
- * Gets the folder name for deprecated types based on the GraphQL type and deprecation option.
55
- *
56
- * @param type - The GraphQL type to get the folder name for
57
- * @param option - The deprecation option
58
- * @returns The folder name for deprecated types
59
- */
60
- export declare const getLinkDeprecatedFolder: (type: unknown, option: Maybe<TypeDeprecatedOption>) => string;
52
+ export declare const getLinkApiGroupFolder: (type: unknown, groups?: Maybe<ApiGroupOverrideType | boolean>) => string;
61
53
  /**
62
54
  * Converts a GraphQL type to a link object.
63
55
  *
@@ -88,11 +80,11 @@ export declare const printLinkAttributes: (type: unknown, text?: Maybe<string>)
88
80
  /**
89
81
  * Prints a link for a GraphQL type based on the provided options.
90
82
  *
91
- * @param type - The GraphQL type to print a link for
83
+ * @param arg - The GraphQL type or link object to print a link for
92
84
  * @param options - Configuration options for link generation
93
85
  * @returns The formatted link as a string
94
86
  */
95
- export declare const printLink: <T>(arg: T | Maybe<TypeLink>, options: PrintLinkOptions) => string;
87
+ export declare const printLink: <T>(arg: Maybe<TypeLink> | T, options: PrintLinkOptions) => string;
96
88
  /**
97
89
  * Prints a parent link for a GraphQL type based on the provided options.
98
90
  *
@@ -100,5 +92,5 @@ export declare const printLink: <T>(arg: T | Maybe<TypeLink>, options: PrintLink
100
92
  * @param options - Configuration options for link generation
101
93
  * @returns The formatted parent link as a string or MDX string
102
94
  */
103
- export declare const printParentLink: (type: unknown, options: PrintLinkOptions) => string | MDXString;
95
+ export declare const printParentLink: (type: unknown, options: PrintLinkOptions) => MDXString | string;
104
96
  //# sourceMappingURL=link.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,oBAAoB,EAGpB,SAAS,EACT,KAAK,EACL,gBAAgB,EAChB,gBAAgB,EAEhB,oBAAoB,EAGpB,QAAQ,EACR,UAAU,EACX,MAAM,yBAAyB,CAAC;AAgCjC,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,oBAAoB,CAG5C,CAAC;AAEX;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,oIA+BjC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,sCAoB7B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,uEAuBjC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,wCAEnC,CAAC;AAEF;;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gBAAgB,KAAG,OAO/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,SAC1B,OAAO,WACJ,KAAK,CAAC,oBAAoB,GAAG,OAAO,CAAC,KAC7C,MAMF,CAAC;AAuBF;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,SACX,OAAO,QACP,MAAM,aACD,KAAK,CAAC,UAAU,CAAC,WACnB,gBAAgB,KACxB,QAkFF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,aAChB,KAAK,CAAC,UAAU,CAAC,QACrB,OAAO,WACJ,gBAAgB,KACxB,KAAK,CAAC,QAAQ,CAUhB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,SACxB,OAAO,SACP,KAAK,CAAC,MAAM,CAAC,KAClB,MAkBF,CAAC;AAoBF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,OACpB,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,WACf,gBAAgB,KACxB,MAgCF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,SACpB,OAAO,WACJ,gBAAgB,KACxB,SAAS,GAAG,MAWd,CAAC"}
package/dist/link.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * @packageDocumentation
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.printParentLink = exports.printLink = exports.printLinkAttributes = exports.getRelationLink = exports.toLink = exports.getLinkDeprecatedFolder = exports.getLinkApiGroupFolder = exports.hasOptionParentType = exports.hasOptionWithAttributes = exports.getLinkCategoryFolder = exports.getCategoryLocale = exports.hasPrintableDirective = exports.API_GROUPS = void 0;
8
+ exports.printParentLink = exports.printLink = exports.printLinkAttributes = exports.getRelationLink = exports.toLink = exports.getLinkApiGroupFolder = exports.hasOptionParentType = exports.hasOptionWithAttributes = exports.getLinkCategoryFolder = exports.getCategoryLocale = exports.hasPrintableDirective = exports.API_GROUPS = void 0;
9
9
  const graphql_1 = require("@graphql-markdown/graphql");
10
10
  const utils_1 = require("@graphql-markdown/utils");
11
11
  const group_1 = require("./group");
@@ -38,7 +38,7 @@ const hasPrintableDirective = (type, options) => {
38
38
  const onlyDirective = "onlyDocDirectives" in options && options.onlyDocDirectives
39
39
  ? (0, graphql_1.hasDirective)(type, options.onlyDocDirectives, true)
40
40
  : true;
41
- return !(skipDirective || skipDeprecated) && onlyDirective;
41
+ return !skipDirective && !skipDeprecated && onlyDirective;
42
42
  };
43
43
  exports.hasPrintableDirective = hasPrintableDirective;
44
44
  /**
@@ -143,7 +143,6 @@ exports.getLinkApiGroupFolder = getLinkApiGroupFolder;
143
143
  const getLinkDeprecatedFolder = (type, option) => {
144
144
  return option === "group" && (0, graphql_1.isDeprecated)(type) ? strings_1.DEPRECATED : "";
145
145
  };
146
- exports.getLinkDeprecatedFolder = getLinkDeprecatedFolder;
147
146
  const isHierarchy = (options, hierarchy) => {
148
147
  return options?.hierarchy?.[hierarchy] !== undefined;
149
148
  };
@@ -168,10 +167,9 @@ const toLink = (type, name, operation, options) => {
168
167
  if (typeof type !== "object" || !(0, exports.hasPrintableDirective)(type, options)) {
169
168
  return fallback;
170
169
  }
170
+ // GraphQL overload resolution can include a void branch in this monorepo; runtime value is a named type here.
171
+ // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
171
172
  const graphQLNamedType = (0, graphql_1.getNamedType)(type);
172
- if (!graphQLNamedType) {
173
- return fallback;
174
- }
175
173
  let category = "";
176
174
  let deprecatedFolder = "";
177
175
  let groupFolder = "";
@@ -182,7 +180,7 @@ const toLink = (type, name, operation, options) => {
182
180
  return fallback;
183
181
  }
184
182
  deprecatedFolder = options.deprecated
185
- ? (0, exports.getLinkDeprecatedFolder)(type, options.deprecated)
183
+ ? getLinkDeprecatedFolder(type, options.deprecated)
186
184
  : "";
187
185
  groupFolder = options.groups
188
186
  ? (0, group_1.getGroup)(type, options.groups, category)
@@ -191,7 +189,9 @@ const toLink = (type, name, operation, options) => {
191
189
  ? (0, exports.getLinkApiGroupFolder)(type)
192
190
  : "";
193
191
  }
194
- const text = graphQLNamedType.name || graphQLNamedType.toString();
192
+ const text = (0, utils_1.hasStringProperty)(graphQLNamedType, "name")
193
+ ? graphQLNamedType.name
194
+ : (0, utils_1.toString)(graphQLNamedType);
195
195
  const formatFolder = (folder) => {
196
196
  return folder && options.formatCategoryFolderName
197
197
  ? options.formatCategoryFolderName(folder)
@@ -274,7 +274,7 @@ const isLinkType = (arg) => {
274
274
  /**
275
275
  * Prints a link for a GraphQL type based on the provided options.
276
276
  *
277
- * @param type - The GraphQL type to print a link for
277
+ * @param arg - The GraphQL type or link object to print a link for
278
278
  * @param options - Configuration options for link generation
279
279
  * @returns The formatted link as a string
280
280
  */
@@ -14,6 +14,6 @@
14
14
  import type { MDXSupportType } from "@graphql-markdown/types";
15
15
  export declare const mdxDeclaration = "";
16
16
  declare const defaultModule: MDXSupportType;
17
- export declare const mdxModule: (mdxPackage?: Record<string, unknown> | undefined) => Promise<Readonly<MDXSupportType>>;
17
+ export declare const mdxModule: (mdxPackage?: Record<string, unknown>) => Promise<Readonly<MDXSupportType>>;
18
18
  export default defaultModule;
19
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mdx/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAOV,cAAc,EAGf,MAAM,yBAAyB,CAAC;AA0KjC,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,QAAA,MAAM,aAAa,gBASA,CAAC;AAEpB,eAAO,MAAM,SAAS,yFAoBrB,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mdx/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAOV,cAAc,EAGf,MAAM,yBAAyB,CAAC;AA0KjC,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,QAAA,MAAM,aAAa,EASd,cAAc,CAAC;AAEpB,eAAO,MAAM,SAAS,gBACP,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACnC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAkBlC,CAAC;eAEa,aAAa"}
package/dist/mdx/index.js CHANGED
@@ -79,13 +79,13 @@ const formatMDXBullet = (text = "") => {
79
79
  * ```typescript
80
80
  * const options = { dataOpen: "More Info" };
81
81
  * formatMDXDetails(options);
82
- * // '\n\n<details class="gqlmd-mdx-details">\n<summary class="gqlmd-mdx-details-summary"><span className="gqlmd-mdx-details-summary-open">MORE INFO</span></summary>\n</details>\n\n'
82
+ * // '\n\n<details class="gqlmd-mdx-details">\n<summary class="gqlmd-mdx-details-summary"><span className="gqlmd-mdx-details-summary-open">MORE INFO</span></summary>\n\r\n</details>\n\n'
83
83
  * ```
84
84
  * @see {@link mdxModule.formatMDXDetails} for the equivalent function in the MDX module.
85
85
  * @see {@link printer.formatDetails} for usage in the printer module.
86
86
  */
87
87
  const formatMDXDetails = ({ dataOpen }) => {
88
- return `${strings_1.MARKDOWN_EOP}<details class="gqlmd-mdx-details">${strings_1.MARKDOWN_EOL}<summary class="gqlmd-mdx-details-summary"><span className="gqlmd-mdx-details-summary-open">${dataOpen.toUpperCase()}</span></summary>${strings_1.MARKDOWN_EOL}</details>${strings_1.MARKDOWN_EOP}`;
88
+ return `${strings_1.MARKDOWN_EOP}<details class="gqlmd-mdx-details">${strings_1.MARKDOWN_EOL}<summary class="gqlmd-mdx-details-summary"><span className="gqlmd-mdx-details-summary-open">${dataOpen.toUpperCase()}</span></summary>${strings_1.MARKDOWN_EOL}\r${strings_1.MARKDOWN_EOL}</details>${strings_1.MARKDOWN_EOP}`;
89
89
  };
90
90
  /**
91
91
  * Formats a "Specified By" link into an MDX string.
package/dist/printer.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  * @module printer
8
8
  * @packageDocumentation
9
9
  */
10
- import type { CustomDirectiveMap, Formatter, GraphQLDirective, GraphQLSchema, IPrinter, MDXString, Maybe, MetaInfo, PrinterEventEmitter, PrintTypeOptions, PrinterConfigPrintTypeOptions, SchemaEntitiesGroupMap, TypeDeprecatedOption } from "@graphql-markdown/types";
10
+ import type { Formatter, GraphQLSchema, IPrinter, Maybe, MDXString, PageSection, PrinterEventEmitter, PrinterInitOptions, PrintTypeOptions } from "@graphql-markdown/types";
11
11
  /**
12
12
  * The Printer class implements the core functionality for generating Markdown documentation
13
13
  * from GraphQL schema types.
@@ -28,31 +28,37 @@ import type { CustomDirectiveMap, Formatter, GraphQLDirective, GraphQLSchema, IP
28
28
  */
29
29
  export declare class Printer implements IPrinter {
30
30
  /**
31
- * Global printer configuration options
31
+ * Prints type descriptions
32
32
  */
33
- static options: Readonly<Maybe<PrintTypeOptions>>;
33
+ static readonly printDescription: (type: unknown, options: PrintTypeOptions, noText?: string) => MDXString | string;
34
34
  /**
35
- * Optional event emitter for print events.
36
- * When set, the printer will emit events before/after printCode and printType,
37
- * allowing external code to intercept and modify the output.
35
+ * Prints custom directives
38
36
  */
39
- static eventEmitter: Maybe<PrinterEventEmitter>;
37
+ static readonly printCustomDirectives: (type: unknown, options: PrintTypeOptions) => Maybe<PageSection>;
40
38
  /**
41
- * Prints type descriptions
39
+ * Prints custom tags
42
40
  */
43
- static readonly printDescription: (type: unknown, options: PrintTypeOptions, noText?: string | undefined) => string | MDXString;
41
+ static readonly printCustomTags: (type: unknown, options: PrintTypeOptions) => MDXString | string;
42
+ private static _eventEmitter;
43
+ private static _options;
44
+ private static _mdxDeclaration;
44
45
  /**
45
- * Prints custom directives
46
+ * Global printer configuration options
46
47
  */
47
- static readonly printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
48
+ static get options(): Readonly<Maybe<PrintTypeOptions>>;
48
49
  /**
49
- * Prints custom tags
50
+ * Optional event emitter for print events.
51
+ * When set, the printer will emit events before/after printCode and printType,
52
+ * allowing external code to intercept and modify the output.
50
53
  */
51
- static readonly printCustomTags: (type: unknown, options: PrintTypeOptions) => string | MDXString;
54
+ static get eventEmitter(): Maybe<PrinterEventEmitter>;
52
55
  /**
53
56
  * Prints mdx modules import declaration
54
57
  */
55
- static mdxDeclaration: Readonly<Maybe<string>>;
58
+ static get mdxDeclaration(): Readonly<Maybe<string>>;
59
+ static set options(options: Readonly<Maybe<PrintTypeOptions>>);
60
+ static set eventEmitter(eventEmitter: Maybe<PrinterEventEmitter>);
61
+ static set mdxDeclaration(mdxDeclaration: Readonly<Maybe<string>>);
56
62
  /**
57
63
  * Initializes the printer with the given schema and configuration.
58
64
  *
@@ -64,17 +70,7 @@ export declare class Printer implements IPrinter {
64
70
  * @param mdxDeclaration - Optional MDX import declaration
65
71
  * @param eventEmitter - Optional event emitter for print events interception
66
72
  */
67
- static init(schema: Maybe<GraphQLSchema>, baseURL?: Maybe<string>, linkRoot?: Maybe<string>, { customDirectives, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, sectionHeaderId }?: {
68
- customDirectives?: CustomDirectiveMap;
69
- deprecated?: TypeDeprecatedOption;
70
- groups?: SchemaEntitiesGroupMap;
71
- meta?: Maybe<MetaInfo>;
72
- metatags?: Record<string, string>[];
73
- onlyDocDirectives?: GraphQLDirective[];
74
- printTypeOptions?: PrinterConfigPrintTypeOptions;
75
- skipDocDirectives?: GraphQLDirective[];
76
- sectionHeaderId?: boolean;
77
- }, formatter?: Partial<Formatter>, mdxDeclaration?: Maybe<string>, eventEmitter?: Maybe<PrinterEventEmitter>): Promise<void>;
73
+ static init(schema: Maybe<GraphQLSchema>, baseURL?: Maybe<string>, linkRoot?: Maybe<string>, { customDirectives, deprecated, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, sectionHeaderId, }?: PrinterInitOptions, formatter?: Partial<Formatter>, mdxDeclaration?: Maybe<string>, eventEmitter?: Maybe<PrinterEventEmitter>): Promise<void>;
78
74
  /**
79
75
  * Prints the header section of a type documentation
80
76
  *
@@ -116,18 +112,17 @@ export declare class Printer implements IPrinter {
116
112
  *
117
113
  * @param type - GraphQL type to generate example for
118
114
  * @param options - Printer configuration options
119
- * @returns Formatted example section string or empty string if no example
115
+ * @returns Example page section or undefined when no example is available
120
116
  */
121
- static readonly printExample: (type: unknown, options: PrintTypeOptions) => string;
117
+ static readonly printExample: (type: unknown, options: PrintTypeOptions) => Maybe<PageSection>;
122
118
  /**
123
119
  * Prints metadata information for a GraphQL type
124
120
  *
125
121
  * @param type - GraphQL type to print metadata for
126
122
  * @param options - Printer configuration options
127
- * @returns Formatted metadata string as MDX or plain string
128
- * @throws When type is not supported
123
+ * @returns Metadata section (or section list) for supported types, otherwise undefined
129
124
  */
130
- static readonly printTypeMetadata: (type: unknown, options: PrintTypeOptions) => string | MDXString;
125
+ static readonly printTypeMetadata: (type: unknown, options: PrintTypeOptions) => Maybe<PageSection | PageSection[]>;
131
126
  /**
132
127
  * Prints related type information
133
128
  *
@@ -135,7 +130,7 @@ export declare class Printer implements IPrinter {
135
130
  * @param options - Printer configuration options
136
131
  * @returns Formatted relations section as MDX or plain string
137
132
  */
138
- static readonly printRelations: (type: unknown, options: PrintTypeOptions) => string | MDXString;
133
+ static readonly printRelations: (type: unknown, options: PrintTypeOptions) => MDXString | string;
139
134
  /**
140
135
  * Prints HTML meta tags for the documentation
141
136
  *
@@ -143,7 +138,7 @@ export declare class Printer implements IPrinter {
143
138
  * @param options - Printer configuration options containing metatags
144
139
  * @returns Formatted HTML meta tags string
145
140
  */
146
- static readonly printMetaTags: (_type: unknown, { metatags }: PrintTypeOptions) => string | MDXString;
141
+ static readonly printMetaTags: (_type: unknown, { metatags }: PrintTypeOptions) => MDXString | string;
147
142
  /**
148
143
  * Main method to print complete documentation for a GraphQL type
149
144
  *
@@ -155,8 +150,7 @@ export declare class Printer implements IPrinter {
155
150
  * @example
156
151
  * ```typescript
157
152
  * const doc = await Printer.printType('User', UserType, {
158
- * frontMatter: true,
159
- * codeSection: true
153
+ * frontMatter: true
160
154
  * });
161
155
  * ```
162
156
  *
@@ -173,8 +167,31 @@ export declare class Printer implements IPrinter {
173
167
  *
174
168
  * When an event emitter is configured, emits events:
175
169
  * - `print:beforePrintType` - Before generating documentation
170
+ * - `print:beforeComposePageType` - Before composing section order and final page output
176
171
  * - `print:afterPrintType` - After generating documentation (output can be modified)
177
172
  */
178
173
  static readonly printType: (name: Maybe<string>, type: unknown, options?: Maybe<Partial<PrintTypeOptions>>) => Promise<Maybe<MDXString>>;
174
+ /**
175
+ * Renders a page section, optionally prefixing a heading when a title is present.
176
+ */
177
+ private static readonly renderPageSection;
178
+ /**
179
+ * Runtime guard for built-in page content section keys.
180
+ */
181
+ private static readonly isTypePageContentSection;
182
+ /**
183
+ * Runtime guard for header-only page section keys.
184
+ */
185
+ private static readonly isTypePageHeaderSection;
186
+ /**
187
+ * Normalizes event-driven section order, allowing built-in section keys and
188
+ * any custom keys that were added to the sections map by an event handler.
189
+ * Keys that are neither built-in nor present in the sections map are dropped.
190
+ */
191
+ private static readonly sanitizeTypePageSectionOrder;
192
+ /**
193
+ * Normalizes mixed section value shapes to the internal PageSection format.
194
+ */
195
+ private static readonly normalizePageSection;
179
196
  }
180
197
  //# sourceMappingURL=printer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAEhB,aAAa,EACb,QAAQ,EACR,SAAS,EACT,KAAK,EACL,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,6BAA6B,EAC7B,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AA2EjC;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,OAAQ,YAAW,QAAQ;IACtC;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC,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