@graphql-markdown/printer-legacy 1.11.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.
Files changed (43) hide show
  1. package/dist/badge.d.ts +29 -1
  2. package/dist/badge.js +42 -10
  3. package/dist/code.d.ts +38 -0
  4. package/dist/code.js +38 -0
  5. package/dist/common.d.ts +39 -0
  6. package/dist/common.js +39 -0
  7. package/dist/const/options.d.ts +1 -4
  8. package/dist/const/options.js +1 -3
  9. package/dist/const/strings.d.ts +1 -0
  10. package/dist/const/strings.js +2 -1
  11. package/dist/directive.d.ts +37 -0
  12. package/dist/directive.js +39 -2
  13. package/dist/example.d.ts +26 -0
  14. package/dist/example.js +52 -0
  15. package/dist/frontmatter.d.ts +15 -3
  16. package/dist/frontmatter.js +14 -59
  17. package/dist/graphql/directive.d.ts +21 -0
  18. package/dist/graphql/directive.js +27 -0
  19. package/dist/graphql/enum.d.ts +18 -0
  20. package/dist/graphql/enum.js +18 -0
  21. package/dist/graphql/interface.d.ts +15 -0
  22. package/dist/graphql/interface.js +15 -0
  23. package/dist/graphql/object.d.ts +23 -0
  24. package/dist/graphql/object.js +29 -0
  25. package/dist/graphql/operation.d.ts +21 -0
  26. package/dist/graphql/operation.js +21 -0
  27. package/dist/graphql/scalar.d.ts +23 -0
  28. package/dist/graphql/scalar.js +20 -1
  29. package/dist/graphql/union.d.ts +16 -0
  30. package/dist/graphql/union.js +16 -0
  31. package/dist/group.d.ts +12 -0
  32. package/dist/group.js +8 -0
  33. package/dist/link.d.ts +92 -0
  34. package/dist/link.js +92 -0
  35. package/dist/mdx/index.d.ts +15 -2
  36. package/dist/mdx/index.js +151 -60
  37. package/dist/printer.d.ts +129 -2
  38. package/dist/printer.js +134 -5
  39. package/dist/relation.d.ts +39 -0
  40. package/dist/relation.js +41 -2
  41. package/dist/section.d.ts +46 -2
  42. package/dist/section.js +54 -23
  43. package/package.json +4 -5
package/dist/link.d.ts CHANGED
@@ -1,14 +1,106 @@
1
+ /**
2
+ * Module for handling links and link-related operations in GraphQL Markdown printer.
3
+ * Provides utilities for creating, formatting, and managing links to GraphQL types and operations.
4
+ * @packageDocumentation
5
+ */
1
6
  import type { ApiGroupOverrideType, MDXString, Maybe, PrintLinkOptions, PrintTypeOptions, TypeDeprecatedOption, TypeLink, TypeLocale } from "@graphql-markdown/types";
2
7
  export declare const API_GROUPS: Required<ApiGroupOverrideType>;
8
+ /**
9
+ * Checks if a type has printable directives based on the provided options.
10
+ *
11
+ * @param type - The GraphQL type to check
12
+ * @param options - Configuration options for directive printing
13
+ * @param options.deprecated - How to handle deprecated types
14
+ * @param options.onlyDocDirectives - Only print types with specific directives
15
+ * @param options.skipDocDirectives - Skip types with specific directives
16
+ * @returns `true` if the type should be printed, `false` otherwise
17
+ */
3
18
  export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives">) => boolean;
19
+ /**
20
+ * Gets the locale category for a given GraphQL type.
21
+ *
22
+ * @param type - The GraphQL type to get the category for
23
+ * @returns The locale category for the type, or `undefined` if not found
24
+ */
4
25
  export declare const getCategoryLocale: (type: unknown) => Maybe<TypeLocale>;
26
+ /**
27
+ * Gets the folder name for a link category based on the GraphQL type and operation locale.
28
+ *
29
+ * @param type - The GraphQL type to get the folder name for
30
+ * @param operationLocale - The locale of the operation
31
+ * @returns The folder name for the link category, or `undefined` if not found
32
+ */
5
33
  export declare const getLinkCategoryFolder: (type: unknown, operationLocale?: Maybe<TypeLocale>) => Maybe<string>;
34
+ /**
35
+ * Checks if the options include the `withAttributes` attribute.
36
+ *
37
+ * @param options - The options to check
38
+ * @returns `true` if the options include `withAttributes`, `false` otherwise
39
+ */
6
40
  export declare const hasOptionWithAttributes: (options: PrintLinkOptions) => boolean;
41
+ /**
42
+ * Checks if the options include the `parentTypePrefix` attribute.
43
+ *
44
+ * @param options - The options to check
45
+ * @returns `true` if the options include `parentTypePrefix`, `false` otherwise
46
+ */
7
47
  export declare const hasOptionParentType: (options: PrintLinkOptions) => boolean;
48
+ /**
49
+ * Gets the folder name for an API group based on the GraphQL type and group options.
50
+ *
51
+ * @param type - The GraphQL type to get the folder name for
52
+ * @param groups - The group options
53
+ * @returns The folder name for the API group
54
+ */
8
55
  export declare const getLinkApiGroupFolder: (type: unknown, groups?: Maybe<ApiGroupOverrideType | boolean>) => string;
56
+ /**
57
+ * Gets the folder name for deprecated types based on the GraphQL type and deprecation option.
58
+ *
59
+ * @param type - The GraphQL type to get the folder name for
60
+ * @param option - The deprecation option
61
+ * @returns The folder name for deprecated types
62
+ */
9
63
  export declare const getLinkDeprecatedFolder: (type: unknown, option: Maybe<TypeDeprecatedOption>) => string;
64
+ /**
65
+ * Converts a GraphQL type to a link object.
66
+ *
67
+ * @param type - The GraphQL type to convert
68
+ * @param name - The name of the type
69
+ * @param operation - The locale of the operation
70
+ * @param options - Configuration options for link generation
71
+ * @returns The link object for the type
72
+ */
10
73
  export declare const toLink: (type: unknown, name: string, operation: Maybe<TypeLocale>, options: PrintLinkOptions) => TypeLink;
74
+ /**
75
+ * Gets the link for a relation based on the category, type, and options.
76
+ *
77
+ * @param category - The locale category of the relation
78
+ * @param type - The GraphQL type of the relation
79
+ * @param options - Configuration options for link generation
80
+ * @returns The link object for the relation, or `undefined` if not found
81
+ */
11
82
  export declare const getRelationLink: (category: Maybe<TypeLocale>, type: unknown, options: PrintLinkOptions) => Maybe<TypeLink>;
83
+ /**
84
+ * Prints the attributes of a link based on the GraphQL type.
85
+ *
86
+ * @param type - The GraphQL type to print attributes for
87
+ * @param text - The text to append attributes to
88
+ * @returns The text with appended attributes
89
+ */
12
90
  export declare const printLinkAttributes: (type: unknown, text?: Maybe<string>) => string;
91
+ /**
92
+ * Prints a link for a GraphQL type based on the provided options.
93
+ *
94
+ * @param type - The GraphQL type to print a link for
95
+ * @param options - Configuration options for link generation
96
+ * @returns The formatted link as a string
97
+ */
13
98
  export declare const printLink: (type: unknown, options: PrintLinkOptions) => string;
99
+ /**
100
+ * Prints a parent link for a GraphQL type based on the provided options.
101
+ *
102
+ * @param type - The GraphQL type to print a parent link for
103
+ * @param options - Configuration options for link generation
104
+ * @returns The formatted parent link as a string or MDX string
105
+ */
14
106
  export declare const printParentLink: (type: unknown, options: PrintLinkOptions) => MDXString | string;
package/dist/link.js CHANGED
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Module for handling links and link-related operations in GraphQL Markdown printer.
4
+ * Provides utilities for creating, formatting, and managing links to GraphQL types and operations.
5
+ * @packageDocumentation
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
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;
4
9
  const graphql_1 = require("@graphql-markdown/graphql");
@@ -10,6 +15,16 @@ exports.API_GROUPS = {
10
15
  operations: "operations",
11
16
  types: "types",
12
17
  };
18
+ /**
19
+ * Checks if a type has printable directives based on the provided options.
20
+ *
21
+ * @param type - The GraphQL type to check
22
+ * @param options - Configuration options for directive printing
23
+ * @param options.deprecated - How to handle deprecated types
24
+ * @param options.onlyDocDirectives - Only print types with specific directives
25
+ * @param options.skipDocDirectives - Skip types with specific directives
26
+ * @returns `true` if the type should be printed, `false` otherwise
27
+ */
13
28
  const hasPrintableDirective = (type, options) => {
14
29
  if (!type) {
15
30
  return false;
@@ -29,6 +44,12 @@ const hasPrintableDirective = (type, options) => {
29
44
  return !(skipDirective || skipDeprecated) && onlyDirective;
30
45
  };
31
46
  exports.hasPrintableDirective = hasPrintableDirective;
47
+ /**
48
+ * Gets the locale category for a given GraphQL type.
49
+ *
50
+ * @param type - The GraphQL type to get the category for
51
+ * @returns The locale category for the type, or `undefined` if not found
52
+ */
32
53
  const getCategoryLocale = (type) => {
33
54
  switch (true) {
34
55
  case (0, graphql_1.isDirectiveType)(type):
@@ -51,6 +72,13 @@ const getCategoryLocale = (type) => {
51
72
  return undefined;
52
73
  };
53
74
  exports.getCategoryLocale = getCategoryLocale;
75
+ /**
76
+ * Gets the folder name for a link category based on the GraphQL type and operation locale.
77
+ *
78
+ * @param type - The GraphQL type to get the folder name for
79
+ * @param operationLocale - The locale of the operation
80
+ * @returns The folder name for the link category, or `undefined` if not found
81
+ */
54
82
  const getLinkCategoryFolder = (type, operationLocale) => {
55
83
  const categoryLocale = (0, exports.getCategoryLocale)(type);
56
84
  if (!categoryLocale) {
@@ -70,10 +98,22 @@ const getLinkCategoryFolder = (type, operationLocale) => {
70
98
  : categoryLocale;
71
99
  };
72
100
  exports.getLinkCategoryFolder = getLinkCategoryFolder;
101
+ /**
102
+ * Checks if the options include the `withAttributes` attribute.
103
+ *
104
+ * @param options - The options to check
105
+ * @returns `true` if the options include `withAttributes`, `false` otherwise
106
+ */
73
107
  const hasOptionWithAttributes = (options) => {
74
108
  return "withAttributes" in options && options.withAttributes === true;
75
109
  };
76
110
  exports.hasOptionWithAttributes = hasOptionWithAttributes;
111
+ /**
112
+ * Checks if the options include the `parentTypePrefix` attribute.
113
+ *
114
+ * @param options - The options to check
115
+ * @returns `true` if the options include `parentTypePrefix`, `false` otherwise
116
+ */
77
117
  const hasOptionParentType = (options) => {
78
118
  return ("parentTypePrefix" in options &&
79
119
  options.parentTypePrefix === true &&
@@ -81,6 +121,13 @@ const hasOptionParentType = (options) => {
81
121
  typeof options.parentType !== "undefined");
82
122
  };
83
123
  exports.hasOptionParentType = hasOptionParentType;
124
+ /**
125
+ * Gets the folder name for an API group based on the GraphQL type and group options.
126
+ *
127
+ * @param type - The GraphQL type to get the folder name for
128
+ * @param groups - The group options
129
+ * @returns The folder name for the API group
130
+ */
84
131
  const getLinkApiGroupFolder = (type, groups) => {
85
132
  let folderNames = exports.API_GROUPS;
86
133
  if (groups && typeof groups === "object") {
@@ -89,6 +136,13 @@ const getLinkApiGroupFolder = (type, groups) => {
89
136
  return (0, graphql_1.isApiType)(type) ? folderNames.operations : folderNames.types;
90
137
  };
91
138
  exports.getLinkApiGroupFolder = getLinkApiGroupFolder;
139
+ /**
140
+ * Gets the folder name for deprecated types based on the GraphQL type and deprecation option.
141
+ *
142
+ * @param type - The GraphQL type to get the folder name for
143
+ * @param option - The deprecation option
144
+ * @returns The folder name for deprecated types
145
+ */
92
146
  const getLinkDeprecatedFolder = (type, option) => {
93
147
  return option === "group" && (0, graphql_1.isDeprecated)(type) ? strings_1.DEPRECATED : "";
94
148
  };
@@ -96,6 +150,15 @@ exports.getLinkDeprecatedFolder = getLinkDeprecatedFolder;
96
150
  const isHierarchy = (options, hierarchy) => {
97
151
  return (options?.hierarchy?.[hierarchy] && true);
98
152
  };
153
+ /**
154
+ * Converts a GraphQL type to a link object.
155
+ *
156
+ * @param type - The GraphQL type to convert
157
+ * @param name - The name of the type
158
+ * @param operation - The locale of the operation
159
+ * @param options - Configuration options for link generation
160
+ * @returns The link object for the type
161
+ */
99
162
  const toLink = (type, name, operation, options) => {
100
163
  const fallback = {
101
164
  text: name,
@@ -140,6 +203,14 @@ const toLink = (type, name, operation, options) => {
140
203
  return link;
141
204
  };
142
205
  exports.toLink = toLink;
206
+ /**
207
+ * Gets the link for a relation based on the category, type, and options.
208
+ *
209
+ * @param category - The locale category of the relation
210
+ * @param type - The GraphQL type of the relation
211
+ * @param options - Configuration options for link generation
212
+ * @returns The link object for the relation, or `undefined` if not found
213
+ */
143
214
  const getRelationLink = (category, type, options) => {
144
215
  if (!category ||
145
216
  typeof type !== "object" ||
@@ -150,6 +221,13 @@ const getRelationLink = (category, type, options) => {
150
221
  return (0, exports.toLink)(type, type.name, category, options);
151
222
  };
152
223
  exports.getRelationLink = getRelationLink;
224
+ /**
225
+ * Prints the attributes of a link based on the GraphQL type.
226
+ *
227
+ * @param type - The GraphQL type to print attributes for
228
+ * @param text - The text to append attributes to
229
+ * @returns The text with appended attributes
230
+ */
153
231
  const printLinkAttributes = (type, text = "") => {
154
232
  if (typeof type !== "object" || type === null) {
155
233
  return text ?? "";
@@ -168,6 +246,13 @@ const printLinkAttributes = (type, text = "") => {
168
246
  return text ?? "";
169
247
  };
170
248
  exports.printLinkAttributes = printLinkAttributes;
249
+ /**
250
+ * Prints a link for a GraphQL type based on the provided options.
251
+ *
252
+ * @param type - The GraphQL type to print a link for
253
+ * @param options - Configuration options for link generation
254
+ * @returns The formatted link as a string
255
+ */
171
256
  const printLink = (type, options) => {
172
257
  if (typeof type !== "object" || type === null) {
173
258
  return "";
@@ -181,6 +266,13 @@ const printLink = (type, options) => {
181
266
  return `[${options.formatMDXNameEntity(text)}](${link.url})`;
182
267
  };
183
268
  exports.printLink = printLink;
269
+ /**
270
+ * Prints a parent link for a GraphQL type based on the provided options.
271
+ *
272
+ * @param type - The GraphQL type to print a parent link for
273
+ * @param options - Configuration options for link generation
274
+ * @returns The formatted parent link as a string or MDX string
275
+ */
184
276
  const printParentLink = (type, options) => {
185
277
  if (typeof type !== "object" || type === null || !("type" in type)) {
186
278
  return "";
@@ -1,5 +1,18 @@
1
- import type { Maybe, MDXSupportType, PackageName } from "@graphql-markdown/types";
1
+ /**
2
+ * MDX formatting module for GraphQL-Markdown.
3
+ *
4
+ * This module provides a set of utility functions for formatting various MDX components
5
+ * used in the documentation generation process. It handles the formatting of badges,
6
+ * admonitions, bullet points, collapsible sections, and other MDX-specific elements.
7
+ *
8
+ * The module can be used with default formatters or customized with user-provided
9
+ * MDX formatting functions through the mdxModule factory function.
10
+ *
11
+ * @module mdx
12
+ * @packageDocumentation
13
+ */
14
+ import type { MDXSupportType } from "@graphql-markdown/types";
2
15
  export declare const mdxDeclaration = "";
3
16
  declare const defaultModule: MDXSupportType;
4
- export declare const mdxModule: (mdxPackage?: Maybe<PackageName>) => Promise<Readonly<MDXSupportType>>;
17
+ export declare const mdxModule: (mdxPackage?: Record<string, unknown>) => Promise<Readonly<MDXSupportType>>;
5
18
  export default defaultModule;
package/dist/mdx/index.js CHANGED
@@ -1,99 +1,190 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
2
+ /**
3
+ * MDX formatting module for GraphQL-Markdown.
4
+ *
5
+ * This module provides a set of utility functions for formatting various MDX components
6
+ * used in the documentation generation process. It handles the formatting of badges,
7
+ * admonitions, bullet points, collapsible sections, and other MDX-specific elements.
8
+ *
9
+ * The module can be used with default formatters or customized with user-provided
10
+ * MDX formatting functions through the mdxModule factory function.
11
+ *
12
+ * @module mdx
13
+ * @packageDocumentation
14
+ */
35
15
  Object.defineProperty(exports, "__esModule", { value: true });
36
16
  exports.mdxModule = exports.mdxDeclaration = void 0;
37
17
  const strings_1 = require("../const/strings");
38
- const logger_1 = require("@graphql-markdown/logger");
39
- const formatMDXBadge = ({ text, classname }) => {
40
- return `<mark class="gqlmd-mdx-badge">${text}</mark>`;
18
+ /**
19
+ * Formats a badge into an MDX string.
20
+ *
21
+ * @param badge - The badge object containing text to display.
22
+ * @returns An MDX string representing the badge.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const badge = { text: "Beta" };
27
+ * formatMDXBadge(badge);
28
+ * // '<mark class="gqlmd-mdx-badge">Beta</mark>'
29
+ * ```
30
+ * @see {@link mdxModule.formatMDXBadge} for the equivalent function in the MDX module.
31
+ * @see {@link printer.formatBadge} for usage in the printer module.
32
+ */
33
+ const formatMDXBadge = (badge) => {
34
+ return `<mark class="gqlmd-mdx-badge">${badge.text}</mark>`;
41
35
  };
42
- const formatMDXAdmonition = ({ text, title, type, icon }, meta) => {
43
- return `${strings_1.MARKDOWN_EOP}<fieldset class="gqlmd-mdx-admonition-fieldset">${strings_1.MARKDOWN_EOL}<legend class="gqlmd-mdx-admonition-legend"><span class="gqlmd-mdx-admonition-legend-type gqlmd-mdx-admonition-legend-type-${type.toLocaleLowerCase()}">${icon ?? type.toUpperCase()}</span> **${title}**</legend>${strings_1.MARKDOWN_EOL}<span>${text}</span>${strings_1.MARKDOWN_EOL}</fieldset>`;
36
+ /**
37
+ * Formats an admonition into an MDX string.
38
+ *
39
+ * @param admonition - The admonition object containing text, title, type, and optional icon.
40
+ * @param _meta - Optional metadata for the admonition.
41
+ * @returns An MDX string representing the admonition.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const admonition = { text: "Be careful!", title: "Warning", type: "warning", icon: "⚠️" };
46
+ * formatMDXAdmonition(admonition, null);
47
+ * // '<fieldset class="gqlmd-mdx-admonition-fieldset">...</fieldset>'
48
+ * ```
49
+ * @see {@link mdxModule.formatMDXAdmonition} for the equivalent function in the MDX module.
50
+ * @see {@link printer.formatAdmonition} for usage in the printer module.
51
+ */
52
+ const formatMDXAdmonition = ({ text, title, type, icon }, _meta) => {
53
+ return `${strings_1.MARKDOWN_EOP}<fieldset class="gqlmd-mdx-admonition-fieldset">${strings_1.MARKDOWN_EOL}<legend class="gqlmd-mdx-admonition-legend"><span class="gqlmd-mdx-admonition-legend-type gqlmd-mdx-admonition-legend-type-${type.toLocaleLowerCase()}">${icon ?? type.toUpperCase()} ${title}</span></legend>${strings_1.MARKDOWN_EOL}<span>${text}</span>${strings_1.MARKDOWN_EOL}</fieldset>`;
44
54
  };
55
+ /**
56
+ * Formats a bullet point into an MDX string.
57
+ *
58
+ * @param text - The text to display next to the bullet. Defaults to an empty string.
59
+ * @returns An MDX string representing the bullet point.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * formatMDXBullet("Item 1");
64
+ * // '<span class="gqlmd-mdx-bullet">&nbsp;●&nbsp;</span>Item 1'
65
+ * ```
66
+ * @see {@link mdxModule.formatMDXBullet} for the equivalent function in the MDX module.
67
+ * @see {@link printer.formatBullet} for usage in the printer module.
68
+ */
45
69
  const formatMDXBullet = (text = "") => {
46
70
  return `<span class="gqlmd-mdx-bullet">&nbsp;●&nbsp;</span>${text}`;
47
71
  };
48
- const formatMDXDetails = ({ dataOpen, }) => {
49
- 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_EOP}\r${strings_1.MARKDOWN_EOP}</details>${strings_1.MARKDOWN_EOP}`;
72
+ /**
73
+ * Formats a collapsible details section into an MDX string.
74
+ *
75
+ * @param options - The collapsible options containing the `dataOpen` text.
76
+ * @returns An MDX string representing the collapsible details section.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const options = { dataOpen: "More Info" };
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'
83
+ * ```
84
+ * @see {@link mdxModule.formatMDXDetails} for the equivalent function in the MDX module.
85
+ * @see {@link printer.formatDetails} for usage in the printer module.
86
+ */
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}`;
50
89
  };
90
+ /**
91
+ * Formats a "Specified By" link into an MDX string.
92
+ *
93
+ * @param url - The URL of the specification.
94
+ * @returns An MDX string representing the "Specified By" link.
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * formatMDXSpecifiedByLink("https://example.com");
99
+ * // '<span class="gqlmd-mdx-specifiedby">Specification<a class="gqlmd-mdx-specifiedby-link" target="_blank" href="https://example.com" title="Specified by https://example.com">⎘</a></span>'
100
+ * ```
101
+ * @see {@link mdxModule.formatMDXSpecifiedByLink} for the equivalent function in the MDX module.
102
+ * @see {@link printer.formatSpecifiedByLink} for usage in the printer module.
103
+ */
51
104
  const formatMDXSpecifiedByLink = (url) => {
52
105
  return `<span class="gqlmd-mdx-specifiedby">Specification<a class="gqlmd-mdx-specifiedby-link" target="_blank" href="${url}" title="Specified by ${url}">⎘</a></span>`;
53
106
  };
107
+ /**
108
+ * Formats an entity name into an MDX string.
109
+ *
110
+ * @param name - The name of the entity.
111
+ * @param parentType - Optional parent type of the entity.
112
+ * @returns An MDX string representing the entity name.
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * formatMDXNameEntity("User", "Query");
117
+ * // '<span class="gqlmd-mdx-entity"><code class="gqlmd-mdx-entity-parent">Query</code>.<code class="gqlmd-mdx-entity-name">User</code></span>'
118
+ * ```
119
+ * @see {@link mdxModule.formatMDXNameEntity} for the equivalent function in the MDX module.
120
+ * @see {@link printer.formatNameEntity} for usage in the printer module.
121
+ */
54
122
  const formatMDXNameEntity = (name, parentType) => {
55
123
  const parentName = parentType
56
124
  ? `<code class="gqlmd-mdx-entity-parent">${parentType}</code>.`
57
125
  : "";
58
126
  return `<span class="gqlmd-mdx-entity">${parentName}<code class="gqlmd-mdx-entity-name">${name}</code></span>`;
59
127
  };
128
+ /**
129
+ * Formats a TypeLink object for MDX format.
130
+ *
131
+ * Currently, this function returns the link as is without modification.
132
+ * This may serve as a placeholder for future formatting logic.
133
+ *
134
+ * @param link - The TypeLink object to format
135
+ * @returns The formatted TypeLink object
136
+ */
60
137
  const formatMDXLink = (link) => {
61
138
  return link;
62
139
  };
140
+ /**
141
+ * Formats a front matter section into an MDX string.
142
+ *
143
+ * @param _props - The front matter options.
144
+ * @param formatted - The formatted front matter as an array of strings.
145
+ * @returns An MDX string representing the front matter.
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const formatted = ["title: My Title", "tags: [tag1, tag2]"];
150
+ * formatMDXFrontmatter(null, formatted);
151
+ * // '---\ntitle: My Title\ntags: [tag1, tag2]\n---'
152
+ * ```
153
+ * @see {@link mdxModule.formatMDXFrontmatter} for the equivalent function in the MDX module.
154
+ * @see {@link printer.formatFrontmatter} for usage in the printer module.
155
+ */
156
+ const formatMDXFrontmatter = (_props, formatted) => {
157
+ return formatted
158
+ ? [strings_1.FRONT_MATTER_DELIMITER, ...formatted, strings_1.FRONT_MATTER_DELIMITER].join(strings_1.MARKDOWN_EOL)
159
+ : "";
160
+ };
63
161
  exports.mdxDeclaration = "";
64
162
  const defaultModule = {
65
163
  formatMDXAdmonition,
66
164
  formatMDXBadge,
67
165
  formatMDXBullet,
68
166
  formatMDXDetails,
69
- formatMDXLink,
167
+ formatMDXFrontmatter,
70
168
  formatMDXNameEntity,
71
169
  formatMDXSpecifiedByLink,
72
170
  mdxDeclaration: exports.mdxDeclaration,
73
- mdxSupport: false,
74
171
  };
75
172
  const mdxModule = async (mdxPackage) => {
76
173
  if (!mdxPackage) {
77
174
  return defaultModule;
78
175
  }
79
- return Promise.resolve(`${mdxPackage}`).then(s => __importStar(require(s))).then((_module) => {
80
- const module = (_module.default ?? _module);
81
- return {
82
- formatMDXAdmonition: module.formatMDXAdmonition ?? formatMDXAdmonition,
83
- formatMDXBadge: module.formatMDXBadge ?? formatMDXBadge,
84
- formatMDXBullet: module.formatMDXBullet ?? formatMDXBullet,
85
- formatMDXDetails: module.formatMDXDetails ?? formatMDXDetails,
86
- formatMDXLink: module.formatMDXLink ?? formatMDXLink,
87
- formatMDXNameEntity: module.formatMDXNameEntity ?? formatMDXNameEntity,
88
- formatMDXSpecifiedByLink: module.formatMDXSpecifiedByLink ?? formatMDXSpecifiedByLink,
89
- mdxDeclaration: module.mdxDeclaration ?? exports.mdxDeclaration,
90
- mdxSupport: true,
91
- };
92
- })
93
- .catch(() => {
94
- (0, logger_1.log)(`An error occurred while loading MDX formatter "${mdxPackage}"`, logger_1.LogLevel.warn);
95
- return defaultModule;
96
- });
176
+ const module = (mdxPackage.default ?? mdxPackage);
177
+ return {
178
+ formatMDXAdmonition: module.formatMDXAdmonition ?? formatMDXAdmonition,
179
+ formatMDXBadge: module.formatMDXBadge ?? formatMDXBadge,
180
+ formatMDXBullet: module.formatMDXBullet ?? formatMDXBullet,
181
+ formatMDXDetails: module.formatMDXDetails ?? formatMDXDetails,
182
+ formatMDXFrontmatter: module.formatMDXFrontmatter ?? formatMDXFrontmatter,
183
+ formatMDXLink: module.formatMDXLink ?? formatMDXLink,
184
+ formatMDXNameEntity: module.formatMDXNameEntity ?? formatMDXNameEntity,
185
+ formatMDXSpecifiedByLink: module.formatMDXSpecifiedByLink ?? formatMDXSpecifiedByLink,
186
+ mdxDeclaration: module.mdxDeclaration ?? exports.mdxDeclaration,
187
+ };
97
188
  };
98
189
  exports.mdxModule = mdxModule;
99
190
  exports.default = defaultModule;