@graphql-markdown/printer-legacy 1.12.0 → 1.12.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.
package/dist/badge.d.ts CHANGED
@@ -1,9 +1,33 @@
1
+ /**
2
+ * Module for handling GraphQL type badges in MDX documentation.
3
+ * Provides functionality to generate and format badges for different GraphQL types
4
+ * and their properties like deprecation status, nullability, and relationships.
5
+ * @module
6
+ */
1
7
  import type { Badge, MDXString, Maybe, PrintTypeOptions, SchemaEntitiesGroupMap } from "@graphql-markdown/types";
2
8
  export declare const CSS_BADGE_CLASSNAME: {
3
9
  DEPRECATED: string;
4
10
  RELATION: string;
5
11
  NON_NULL: string;
6
12
  };
13
+ /**
14
+ * Gets an array of badges for a given GraphQL type.
15
+ * @param type - The GraphQL type to generate badges for
16
+ * @param groups - Optional map of schema entities to their groups
17
+ * @returns Array of Badge objects containing text and optional classnames
18
+ */
7
19
  export declare const getTypeBadges: (type: unknown, groups?: Maybe<SchemaEntitiesGroupMap>) => Badge[];
20
+ /**
21
+ * Formats a single badge into MDX string format.
22
+ * @param badge - The badge object containing text and optional classname
23
+ * @param options - Options for printing/formatting the badge
24
+ * @returns Formatted MDX string representation of the badge
25
+ */
8
26
  export declare const printBadge: ({ text, classname }: Badge, options: PrintTypeOptions) => MDXString;
27
+ /**
28
+ * Generates and formats all applicable badges for a GraphQL type.
29
+ * @param type - The GraphQL type to generate badges for
30
+ * @param options - Options for printing/formatting the badges
31
+ * @returns Formatted MDX string containing all badges, or empty string if no badges or badges disabled
32
+ */
9
33
  export declare const printBadges: (type: unknown, options: PrintTypeOptions) => MDXString | string;
package/dist/badge.js CHANGED
@@ -1,4 +1,10 @@
1
1
  "use strict";
2
+ /**
3
+ * Module for handling GraphQL type badges in MDX documentation.
4
+ * Provides functionality to generate and format badges for different GraphQL types
5
+ * and their properties like deprecation status, nullability, and relationships.
6
+ * @module
7
+ */
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.printBadges = exports.printBadge = exports.getTypeBadges = exports.CSS_BADGE_CLASSNAME = void 0;
4
10
  const utils_1 = require("@graphql-markdown/utils");
@@ -11,6 +17,12 @@ exports.CSS_BADGE_CLASSNAME = {
11
17
  RELATION: "RELATION",
12
18
  NON_NULL: "NON_NULL",
13
19
  };
20
+ /**
21
+ * Gets an array of badges for a given GraphQL type.
22
+ * @param type - The GraphQL type to generate badges for
23
+ * @param groups - Optional map of schema entities to their groups
24
+ * @returns Array of Badge objects containing text and optional classnames
25
+ */
14
26
  const getTypeBadges = (type, groups) => {
15
27
  const badges = [];
16
28
  if (typeof type !== "object" || type === null) {
@@ -46,6 +58,12 @@ const getTypeBadges = (type, groups) => {
46
58
  return badges;
47
59
  };
48
60
  exports.getTypeBadges = getTypeBadges;
61
+ /**
62
+ * Formats a single badge into MDX string format.
63
+ * @param badge - The badge object containing text and optional classname
64
+ * @param options - Options for printing/formatting the badge
65
+ * @returns Formatted MDX string representation of the badge
66
+ */
49
67
  const printBadge = ({ text, classname }, options) => {
50
68
  const textString = typeof text === "object" ? text.singular : text;
51
69
  const formattedText = (0, utils_1.escapeMDX)(textString);
@@ -55,6 +73,12 @@ const printBadge = ({ text, classname }, options) => {
55
73
  });
56
74
  };
57
75
  exports.printBadge = printBadge;
76
+ /**
77
+ * Generates and formats all applicable badges for a GraphQL type.
78
+ * @param type - The GraphQL type to generate badges for
79
+ * @param options - Options for printing/formatting the badges
80
+ * @returns Formatted MDX string containing all badges, or empty string if no badges or badges disabled
81
+ */
58
82
  const printBadges = (type, options) => {
59
83
  if (!("typeBadges" in options) ||
60
84
  typeof options.typeBadges !== "boolean" ||
package/dist/code.d.ts CHANGED
@@ -1,3 +1,41 @@
1
+ /**
2
+ * Provides utility functions for generating code representations of GraphQL types
3
+ * in Markdown format. This module handles the formatting of arguments and fields
4
+ * with proper indentation and deprecation notices.
5
+ * @module
6
+ *
7
+ */
1
8
  import type { MDXString, PrintTypeOptions } from "@graphql-markdown/types";
9
+ /**
10
+ * Generates a string representation of GraphQL arguments with proper formatting and indentation.
11
+ *
12
+ * @param type - The GraphQL type object containing arguments to print
13
+ * @param indentationLevel - The level of indentation to apply (default: 1)
14
+ * @returns A formatted string of arguments or an empty string if no arguments exist
15
+ * @example
16
+ * ```
17
+ * printCodeArguments({ args: [{ name: 'id', type: 'ID!' }] })
18
+ * // Returns:
19
+ * // (
20
+ * // id: ID!
21
+ * // )
22
+ * ```
23
+ */
2
24
  export declare const printCodeArguments: (type: unknown, indentationLevel?: number) => string;
25
+ /**
26
+ * Generates a string representation of a GraphQL field including its arguments,
27
+ * return type, and deprecation status.
28
+ *
29
+ * @param type - The GraphQL field type object to print
30
+ * @param options - Optional configuration for printing the type
31
+ * @param indentationLevel - The level of indentation to apply (default: 0)
32
+ * @returns A formatted string representing the field or an empty string if the field should not be printed
33
+ * @example
34
+ * ```
35
+ * printCodeField({ name: 'user', type: 'User!', args: [{ name: 'id', type: 'ID!' }] })
36
+ * // Returns: user(
37
+ * // id: ID!
38
+ * // ): User!
39
+ * ```
40
+ */
3
41
  export declare const printCodeField: (type: unknown, options?: PrintTypeOptions, indentationLevel?: number) => MDXString | string;
package/dist/code.js CHANGED
@@ -1,9 +1,31 @@
1
1
  "use strict";
2
+ /**
3
+ * Provides utility functions for generating code representations of GraphQL types
4
+ * in Markdown format. This module handles the formatting of arguments and fields
5
+ * with proper indentation and deprecation notices.
6
+ * @module
7
+ *
8
+ */
2
9
  Object.defineProperty(exports, "__esModule", { value: true });
3
10
  exports.printCodeField = exports.printCodeArguments = void 0;
4
11
  const graphql_1 = require("@graphql-markdown/graphql");
5
12
  const strings_1 = require("./const/strings");
6
13
  const link_1 = require("./link");
14
+ /**
15
+ * Generates a string representation of GraphQL arguments with proper formatting and indentation.
16
+ *
17
+ * @param type - The GraphQL type object containing arguments to print
18
+ * @param indentationLevel - The level of indentation to apply (default: 1)
19
+ * @returns A formatted string of arguments or an empty string if no arguments exist
20
+ * @example
21
+ * ```
22
+ * printCodeArguments({ args: [{ name: 'id', type: 'ID!' }] })
23
+ * // Returns:
24
+ * // (
25
+ * // id: ID!
26
+ * // )
27
+ * ```
28
+ */
7
29
  const printCodeArguments = (type, indentationLevel = 1) => {
8
30
  if (typeof type !== "object" ||
9
31
  type === null ||
@@ -29,6 +51,22 @@ const printCodeArguments = (type, indentationLevel = 1) => {
29
51
  return code;
30
52
  };
31
53
  exports.printCodeArguments = printCodeArguments;
54
+ /**
55
+ * Generates a string representation of a GraphQL field including its arguments,
56
+ * return type, and deprecation status.
57
+ *
58
+ * @param type - The GraphQL field type object to print
59
+ * @param options - Optional configuration for printing the type
60
+ * @param indentationLevel - The level of indentation to apply (default: 0)
61
+ * @returns A formatted string representing the field or an empty string if the field should not be printed
62
+ * @example
63
+ * ```
64
+ * printCodeField({ name: 'user', type: 'User!', args: [{ name: 'id', type: 'ID!' }] })
65
+ * // Returns: user(
66
+ * // id: ID!
67
+ * // ): User!
68
+ * ```
69
+ */
32
70
  const printCodeField = (type, options, indentationLevel = 0) => {
33
71
  if (typeof type !== "object" || type === null || !("type" in type)) {
34
72
  return "";
package/dist/common.d.ts CHANGED
@@ -1,9 +1,48 @@
1
+ /**
2
+ * Common printer utility functions for handling descriptions, directives, and warnings.
3
+ * @module
4
+ */
1
5
  import type { Maybe, MDXString, PrintTypeOptions } from "@graphql-markdown/types";
6
+ /**
7
+ * Prints documentation for custom directives applied to a type.
8
+ *
9
+ * @param type - GraphQL type to get directives from
10
+ * @param options - Printer configuration options
11
+ * @returns Formatted directive documentation string
12
+ */
2
13
  export declare const printCustomDirectives: (type: unknown, options?: PrintTypeOptions) => string;
14
+ /**
15
+ * Formats a GraphQL type description or falls back to a default message.
16
+ *
17
+ * @param type - GraphQL type to get description from
18
+ * @param replacement - Optional fallback text if no description exists
19
+ * @returns Formatted description string or MDX content
20
+ */
3
21
  export declare const formatDescription: (type: unknown, replacement?: Maybe<string>) => MDXString | string;
22
+ /**
23
+ * Generates a warning message block in MDX format.
24
+ * @param param0 - Warning configuration object
25
+ * @param param0.text - The warning message text
26
+ * @param param0.title - Optional title for the warning block
27
+ * @param options - Configuration options for printing
28
+ * @returns Formatted warning message as MDX string
29
+ */
4
30
  export declare const printWarning: ({ text, title }: {
5
31
  text?: string;
6
32
  title?: string;
7
33
  }, options: PrintTypeOptions) => string;
34
+ /**
35
+ * Prints deprecation information for a GraphQL type if it is deprecated.
36
+ * @param type - The GraphQL type to check for deprecation
37
+ * @param options - Configuration options for printing
38
+ * @returns Formatted deprecation warning as MDX string, or empty string if not deprecated
39
+ */
8
40
  export declare const printDeprecation: (type: unknown, options: PrintTypeOptions) => string;
41
+ /**
42
+ * Prints the complete description for a GraphQL type, including deprecation warnings and custom directives.
43
+ * @param type - The GraphQL type to document
44
+ * @param options - Configuration options for printing
45
+ * @param noText - Optional text to display when no description exists
46
+ * @returns Combined description, deprecation notices, and custom directives as MDX content
47
+ */
9
48
  export declare const printDescription: (type: unknown, options: PrintTypeOptions, noText?: string) => MDXString | string;
package/dist/common.js CHANGED
@@ -1,10 +1,21 @@
1
1
  "use strict";
2
+ /**
3
+ * Common printer utility functions for handling descriptions, directives, and warnings.
4
+ * @module
5
+ */
2
6
  Object.defineProperty(exports, "__esModule", { value: true });
3
7
  exports.printDescription = exports.printDeprecation = exports.printWarning = exports.formatDescription = exports.printCustomDirectives = void 0;
4
8
  const utils_1 = require("@graphql-markdown/utils");
5
9
  const graphql_1 = require("@graphql-markdown/graphql");
6
10
  const strings_1 = require("./const/strings");
7
11
  const directive_1 = require("./directive");
12
+ /**
13
+ * Prints documentation for custom directives applied to a type.
14
+ *
15
+ * @param type - GraphQL type to get directives from
16
+ * @param options - Printer configuration options
17
+ * @returns Formatted directive documentation string
18
+ */
8
19
  const printCustomDirectives = (type, options) => {
9
20
  const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options?.customDirectives);
10
21
  if ((0, utils_1.isEmpty)(constDirectiveMap)) {
@@ -24,6 +35,13 @@ const printCustomDirectives = (type, options) => {
24
35
  return `${strings_1.MARKDOWN_EOP}${content}`;
25
36
  };
26
37
  exports.printCustomDirectives = printCustomDirectives;
38
+ /**
39
+ * Formats a GraphQL type description or falls back to a default message.
40
+ *
41
+ * @param type - GraphQL type to get description from
42
+ * @param replacement - Optional fallback text if no description exists
43
+ * @returns Formatted description string or MDX content
44
+ */
27
45
  const formatDescription = (type, replacement = strings_1.NO_DESCRIPTION_TEXT) => {
28
46
  if (typeof type !== "object" || type === null) {
29
47
  return `${strings_1.MARKDOWN_EOP}${(0, utils_1.escapeMDX)(replacement)}`;
@@ -34,6 +52,14 @@ const formatDescription = (type, replacement = strings_1.NO_DESCRIPTION_TEXT) =>
34
52
  return `${strings_1.MARKDOWN_EOP}${(0, utils_1.escapeMDX)(description)}`;
35
53
  };
36
54
  exports.formatDescription = formatDescription;
55
+ /**
56
+ * Generates a warning message block in MDX format.
57
+ * @param param0 - Warning configuration object
58
+ * @param param0.text - The warning message text
59
+ * @param param0.title - Optional title for the warning block
60
+ * @param options - Configuration options for printing
61
+ * @returns Formatted warning message as MDX string
62
+ */
37
63
  const printWarning = ({ text, title }, options) => {
38
64
  const formattedText = typeof text !== "string" || text.trim() === ""
39
65
  ? strings_1.MARKDOWN_EOP
@@ -41,6 +67,12 @@ const printWarning = ({ text, title }, options) => {
41
67
  return options.formatMDXAdmonition({ text: formattedText, type: "warning", icon: "⚠️", title }, options.meta);
42
68
  };
43
69
  exports.printWarning = printWarning;
70
+ /**
71
+ * Prints deprecation information for a GraphQL type if it is deprecated.
72
+ * @param type - The GraphQL type to check for deprecation
73
+ * @param options - Configuration options for printing
74
+ * @returns Formatted deprecation warning as MDX string, or empty string if not deprecated
75
+ */
44
76
  const printDeprecation = (type, options) => {
45
77
  if (typeof type !== "object" || type === null || !(0, graphql_1.isDeprecated)(type)) {
46
78
  return "";
@@ -51,6 +83,13 @@ const printDeprecation = (type, options) => {
51
83
  return (0, exports.printWarning)({ text: reason, title: strings_1.DEPRECATED.toUpperCase() }, options);
52
84
  };
53
85
  exports.printDeprecation = printDeprecation;
86
+ /**
87
+ * Prints the complete description for a GraphQL type, including deprecation warnings and custom directives.
88
+ * @param type - The GraphQL type to document
89
+ * @param options - Configuration options for printing
90
+ * @param noText - Optional text to display when no description exists
91
+ * @returns Combined description, deprecation notices, and custom directives as MDX content
92
+ */
54
93
  const printDescription = (type, options, noText) => {
55
94
  const description = (0, exports.formatDescription)(type, noText);
56
95
  const customDirectives = (0, exports.printCustomDirectives)(type, options);
@@ -1,6 +1,43 @@
1
+ /**
2
+ * Provides utilities for handling and printing GraphQL directives in Markdown format
3
+ * @module
4
+ */
1
5
  import type { Badge, PrintTypeOptions, MDXString, CustomDirectiveMapItem, CustomDirectiveResolver, Maybe } from "@graphql-markdown/types";
6
+ /**
7
+ * Resolves a custom directive using the provided resolver function
8
+ * @param resolver - The resolver function name to execute
9
+ * @param type - The GraphQL type to resolve the directive for
10
+ * @param constDirectiveOption - The directive configuration options
11
+ * @param fallback - Optional fallback value if resolution fails
12
+ * @returns The resolved directive value or fallback/undefined
13
+ */
2
14
  export declare const getCustomDirectiveResolver: (resolver: CustomDirectiveResolver, type: unknown, constDirectiveOption: CustomDirectiveMapItem, fallback?: Maybe<string>) => Maybe<string>;
15
+ /**
16
+ * Prints a custom directive as a Markdown string
17
+ * @param type - The GraphQL type to print the directive for
18
+ * @param constDirectiveOption - The directive configuration options
19
+ * @param options - General printing options
20
+ * @returns Formatted Markdown string for the directive or undefined
21
+ */
3
22
  export declare const printCustomDirective: (type: unknown, constDirectiveOption: CustomDirectiveMapItem, options: PrintTypeOptions) => Maybe<string>;
23
+ /**
24
+ * Prints all custom directives for a type as a Markdown section
25
+ * @param type - The GraphQL type to print directives for
26
+ * @param options - General printing options
27
+ * @returns Markdown string containing all formatted directives
28
+ */
4
29
  export declare const printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
30
+ /**
31
+ * Extracts custom tags from directives for a given type
32
+ * @param type - The GraphQL type to get tags for
33
+ * @param options - General printing options
34
+ * @returns Array of badge configurations from directive tags
35
+ */
5
36
  export declare const getCustomTags: (type: unknown, options: PrintTypeOptions) => Badge[];
37
+ /**
38
+ * Prints custom directive tags as Markdown badges
39
+ * @param type - The GraphQL type to print tags for
40
+ * @param options - General printing options
41
+ * @returns Formatted Markdown string of badges or empty string
42
+ */
6
43
  export declare const printCustomTags: (type: unknown, options: PrintTypeOptions) => MDXString | string;
package/dist/directive.js CHANGED
@@ -1,4 +1,8 @@
1
1
  "use strict";
2
+ /**
3
+ * Provides utilities for handling and printing GraphQL directives in Markdown format
4
+ * @module
5
+ */
2
6
  Object.defineProperty(exports, "__esModule", { value: true });
3
7
  exports.printCustomTags = exports.getCustomTags = exports.printCustomDirectives = exports.printCustomDirective = exports.getCustomDirectiveResolver = void 0;
4
8
  const graphql_1 = require("@graphql-markdown/graphql");
@@ -6,6 +10,14 @@ const strings_1 = require("./const/strings");
6
10
  const options_1 = require("./const/options");
7
11
  const link_1 = require("./link");
8
12
  const badge_1 = require("./badge");
13
+ /**
14
+ * Resolves a custom directive using the provided resolver function
15
+ * @param resolver - The resolver function name to execute
16
+ * @param type - The GraphQL type to resolve the directive for
17
+ * @param constDirectiveOption - The directive configuration options
18
+ * @param fallback - Optional fallback value if resolution fails
19
+ * @returns The resolved directive value or fallback/undefined
20
+ */
9
21
  const getCustomDirectiveResolver = (resolver, type, constDirectiveOption, fallback) => {
10
22
  if (typeof constDirectiveOption === "undefined" ||
11
23
  typeof constDirectiveOption.type !== "object" ||
@@ -15,6 +27,13 @@ const getCustomDirectiveResolver = (resolver, type, constDirectiveOption, fallba
15
27
  return constDirectiveOption[resolver](constDirectiveOption.type, type);
16
28
  };
17
29
  exports.getCustomDirectiveResolver = getCustomDirectiveResolver;
30
+ /**
31
+ * Prints a custom directive as a Markdown string
32
+ * @param type - The GraphQL type to print the directive for
33
+ * @param constDirectiveOption - The directive configuration options
34
+ * @param options - General printing options
35
+ * @returns Formatted Markdown string for the directive or undefined
36
+ */
18
37
  const printCustomDirective = (type, constDirectiveOption, options) => {
19
38
  const typeNameLink = (0, link_1.printLink)(constDirectiveOption.type, {
20
39
  ...options,
@@ -27,6 +46,12 @@ const printCustomDirective = (type, constDirectiveOption, options) => {
27
46
  return `${options_1.SectionLevels.LEVEL.repeat(4)} ${typeNameLink}${strings_1.MARKDOWN_EOL} ${description}${strings_1.MARKDOWN_EOL} `;
28
47
  };
29
48
  exports.printCustomDirective = printCustomDirective;
49
+ /**
50
+ * Prints all custom directives for a type as a Markdown section
51
+ * @param type - The GraphQL type to print directives for
52
+ * @param options - General printing options
53
+ * @returns Markdown string containing all formatted directives
54
+ */
30
55
  const printCustomDirectives = (type, options) => {
31
56
  const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
32
57
  if (!constDirectiveMap || Object.keys(constDirectiveMap).length < 1) {
@@ -46,6 +71,12 @@ const printCustomDirectives = (type, options) => {
46
71
  return `${options_1.SectionLevels.LEVEL.repeat(3)} Directives${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
47
72
  };
48
73
  exports.printCustomDirectives = printCustomDirectives;
74
+ /**
75
+ * Extracts custom tags from directives for a given type
76
+ * @param type - The GraphQL type to get tags for
77
+ * @param options - General printing options
78
+ * @returns Array of badge configurations from directive tags
79
+ */
49
80
  const getCustomTags = (type, options) => {
50
81
  const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
51
82
  if (typeof constDirectiveMap !== "object" ||
@@ -62,6 +93,12 @@ const getCustomTags = (type, options) => {
62
93
  });
63
94
  };
64
95
  exports.getCustomTags = getCustomTags;
96
+ /**
97
+ * Prints custom directive tags as Markdown badges
98
+ * @param type - The GraphQL type to print tags for
99
+ * @param options - General printing options
100
+ * @returns Formatted Markdown string of badges or empty string
101
+ */
65
102
  const printCustomTags = (type, options) => {
66
103
  const badges = (0, exports.getCustomTags)(type, options);
67
104
  if (badges.length === 0) {
package/dist/example.d.ts CHANGED
@@ -1,3 +1,29 @@
1
+ /**
2
+ * Module providing utilities for handling GraphQL example directives and printing example values.
3
+ *
4
+ * @packageDocumentation
5
+ */
1
6
  import type { Maybe, PrintTypeOptions, TypeDirectiveExample } from "@graphql-markdown/types";
7
+ /**
8
+ * Retrieves directive example options from the provided print type options.
9
+ *
10
+ * @param options - Configuration options
11
+ * @returns The directive example configuration if valid, otherwise `undefined`
12
+ */
2
13
  export declare const getDirectiveExampleOption: ({ exampleSection, schema, }: PrintTypeOptions) => Maybe<TypeDirectiveExample>;
14
+ /**
15
+ * Prints an example value for a given GraphQL type or operation.
16
+ *
17
+ * @param type - The GraphQL type or operation to generate an example for
18
+ * @param options - Configuration options for printing the example
19
+ * @returns Stringified example if available, otherwise `undefined`
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * const example = printExample(type, { schema, exampleSection });
24
+ * if (example) {
25
+ * console.log(example);
26
+ * }
27
+ * ```
28
+ */
3
29
  export declare const printExample: (type: unknown, options: PrintTypeOptions) => Maybe<string>;
package/dist/example.js CHANGED
@@ -1,9 +1,20 @@
1
1
  "use strict";
2
+ /**
3
+ * Module providing utilities for handling GraphQL example directives and printing example values.
4
+ *
5
+ * @packageDocumentation
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.printExample = exports.getDirectiveExampleOption = void 0;
4
9
  const graphql_1 = require("@graphql-markdown/graphql");
5
10
  const utils_1 = require("@graphql-markdown/utils");
6
11
  const link_1 = require("./link");
12
+ /**
13
+ * Retrieves directive example options from the provided print type options.
14
+ *
15
+ * @param options - Configuration options
16
+ * @returns The directive example configuration if valid, otherwise `undefined`
17
+ */
7
18
  const getDirectiveExampleOption = ({ exampleSection, schema, }) => {
8
19
  let directiveName = "example", argName = "value", parserFunc = undefined;
9
20
  if (exampleSection && typeof exampleSection === "object") {
@@ -30,6 +41,15 @@ const getDirectiveExampleOption = ({ exampleSection, schema, }) => {
30
41
  };
31
42
  };
32
43
  exports.getDirectiveExampleOption = getDirectiveExampleOption;
44
+ /**
45
+ * Parses fields of a GraphQL type to generate example values.
46
+ *
47
+ * @internal
48
+ * @param type - The GraphQL type to parse
49
+ * @param options - Print type options for configuration
50
+ * @param mappedTypes - Array of already processed type names to prevent recursion
51
+ * @returns Record of field names and their example values, or `undefined`
52
+ */
33
53
  const parseTypeFields = (type, options, mappedTypes = []) => {
34
54
  const directiveExample = (0, exports.getDirectiveExampleOption)(options);
35
55
  if (!directiveExample) {
@@ -66,6 +86,14 @@ const parseTypeFields = (type, options, mappedTypes = []) => {
66
86
  });
67
87
  return example;
68
88
  };
89
+ /**
90
+ * Parses example value from a string into appropriate type.
91
+ *
92
+ * @internal
93
+ * @param value - The raw example value
94
+ * @param type - The GraphQL type or operation
95
+ * @returns Parsed value, or `undefined` if parsing fails
96
+ */
69
97
  const parseExampleValue = (value, type) => {
70
98
  if (!value || typeof value !== "string") {
71
99
  return undefined;
@@ -85,6 +113,15 @@ const parseExampleValue = (value, type) => {
85
113
  }
86
114
  return value;
87
115
  };
116
+ /**
117
+ * Parses example directive from a GraphQL type or operation.
118
+ *
119
+ * @internal
120
+ * @param type - The GraphQL type or operation to parse
121
+ * @param options - Print type options for configuration
122
+ * @param mappedTypes - Array of already processed type names to prevent recursion
123
+ * @returns Parsed example value, or `undefined`
124
+ */
88
125
  const parseExampleDirective = (type, options, mappedTypes = []) => {
89
126
  const directiveExample = (0, exports.getDirectiveExampleOption)(options);
90
127
  if (!directiveExample || !(0, link_1.hasPrintableDirective)(type, options)) {
@@ -121,6 +158,21 @@ const parseExampleDirective = (type, options, mappedTypes = []) => {
121
158
  throw err;
122
159
  }
123
160
  };
161
+ /**
162
+ * Prints an example value for a given GraphQL type or operation.
163
+ *
164
+ * @param type - The GraphQL type or operation to generate an example for
165
+ * @param options - Configuration options for printing the example
166
+ * @returns Stringified example if available, otherwise `undefined`
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * const example = printExample(type, { schema, exampleSection });
171
+ * if (example) {
172
+ * console.log(example);
173
+ * }
174
+ * ```
175
+ */
124
176
  const printExample = (type, options) => {
125
177
  if (!(0, graphql_1.isType)(type) && !(0, graphql_1.isOperation)(type)) {
126
178
  return undefined;
@@ -1,2 +1,15 @@
1
+ /**
2
+ * Module for handling frontmatter generation in Markdown documents.
3
+ * Provides utilities for formatting and printing frontmatter content.
4
+ * @module
5
+ */
1
6
  import type { FrontMatterOptions, Maybe, PrintTypeOptions } from "@graphql-markdown/types";
7
+ /**
8
+ * Generates a formatted frontmatter string for Markdown/MDX documents.
9
+ *
10
+ * @param title - The title to be included in the frontmatter
11
+ * @param props - Additional frontmatter properties to be included
12
+ * @param options - Configuration options for printing
13
+ * @returns Formatted frontmatter string, or empty string if formatting is disabled
14
+ */
2
15
  export declare const printFrontMatter: (title: string, props: Maybe<FrontMatterOptions>, options: PrintTypeOptions) => string;
@@ -2,6 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.printFrontMatter = void 0;
4
4
  const utils_1 = require("@graphql-markdown/utils");
5
+ /**
6
+ * Generates a formatted frontmatter string for Markdown/MDX documents.
7
+ *
8
+ * @param title - The title to be included in the frontmatter
9
+ * @param props - Additional frontmatter properties to be included
10
+ * @param options - Configuration options for printing
11
+ * @returns Formatted frontmatter string, or empty string if formatting is disabled
12
+ */
5
13
  const printFrontMatter = (title, props, options) => {
6
14
  const frontMatter = (0, utils_1.formatFrontMatterObject)({ ...props, title }, -1);
7
15
  if (!options.formatMDXFrontmatter) {
@@ -1,3 +1,24 @@
1
+ /**
2
+ * Module for handling GraphQL directive printing and formatting.
3
+ * Provides utilities to generate string representations of GraphQL directives
4
+ * including their metadata, arguments, and locations.
5
+ *
6
+ * @module
7
+ */
1
8
  import type { PrintDirectiveOptions, GraphQLDirective, MDXString } from "@graphql-markdown/types";
9
+ /**
10
+ * Prints metadata information for a GraphQL directive, focusing on its arguments.
11
+ *
12
+ * @param type - The GraphQL directive to process
13
+ * @param options - Configuration options for printing directive metadata
14
+ * @returns Formatted metadata string in MDX format or empty string if no arguments
15
+ */
2
16
  export declare const printDirectiveMetadata: (type: GraphQLDirective, options: PrintDirectiveOptions) => MDXString | string;
17
+ /**
18
+ * Generates a string representation of a complete GraphQL directive definition.
19
+ *
20
+ * @param type - The GraphQL directive to process
21
+ * @param options - Configuration options for printing the directive (optional)
22
+ * @returns A formatted string containing the complete directive definition
23
+ */
3
24
  export declare const printCodeDirective: (type: GraphQLDirective, options?: PrintDirectiveOptions) => string;
@@ -1,9 +1,22 @@
1
1
  "use strict";
2
+ /**
3
+ * Module for handling GraphQL directive printing and formatting.
4
+ * Provides utilities to generate string representations of GraphQL directives
5
+ * including their metadata, arguments, and locations.
6
+ *
7
+ * @module
8
+ */
2
9
  Object.defineProperty(exports, "__esModule", { value: true });
3
10
  exports.printCodeDirective = exports.printDirectiveMetadata = void 0;
4
11
  const graphql_1 = require("@graphql-markdown/graphql");
5
12
  const section_1 = require("../section");
6
13
  const code_1 = require("../code");
14
+ /**
15
+ * Generates a string representation of directive locations.
16
+ *
17
+ * @param type - The GraphQL directive to process
18
+ * @returns A formatted string of directive locations or empty string if no locations defined
19
+ */
7
20
  const printCodeDirectiveLocation = (type) => {
8
21
  if (typeof type.locations === "undefined" || type.locations.length === 0) {
9
22
  return "";
@@ -16,6 +29,13 @@ const printCodeDirectiveLocation = (type) => {
16
29
  code += type.locations.join(separator).trim();
17
30
  return code;
18
31
  };
32
+ /**
33
+ * Prints metadata information for a GraphQL directive, focusing on its arguments.
34
+ *
35
+ * @param type - The GraphQL directive to process
36
+ * @param options - Configuration options for printing directive metadata
37
+ * @returns Formatted metadata string in MDX format or empty string if no arguments
38
+ */
19
39
  const printDirectiveMetadata = (type, options) => {
20
40
  if (!("args" in type)) {
21
41
  return "";
@@ -23,6 +43,13 @@ const printDirectiveMetadata = (type, options) => {
23
43
  return (0, section_1.printMetadataSection)(type, type.args, "Arguments", options);
24
44
  };
25
45
  exports.printDirectiveMetadata = printDirectiveMetadata;
46
+ /**
47
+ * Generates a string representation of a complete GraphQL directive definition.
48
+ *
49
+ * @param type - The GraphQL directive to process
50
+ * @param options - Configuration options for printing the directive (optional)
51
+ * @returns A formatted string containing the complete directive definition
52
+ */
26
53
  const printCodeDirective = (type,
27
54
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
55
  options) => {