@graphql-markdown/printer-legacy 1.16.1 → 1.16.2

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "bugs": {
6
6
  "url": "https://github.com/graphql-markdown/graphql-markdown/issues"
7
7
  },
8
- "version": "1.16.1",
8
+ "version": "1.16.2",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
@@ -58,11 +58,11 @@
58
58
  "prettier": "prettier \"{src,tests,assets}/**/*.{ts,js,json,md,gql}\" --check",
59
59
  "prettier:fix": "prettier \"{src,tests,assets}/**/*.{ts,js,json,md,gql}\" --write",
60
60
  "ts:check": "tsgo --noEmit",
61
- "test": "jest",
62
- "test:unit": "jest --passWithNoTests --testPathPatterns=tests/unit",
63
- "test:integration": "jest --passWithNoTests --testPathPatterns=tests/integration",
64
- "test:ci": "jest --passWithNoTests --ci --silent --randomize --runInBand",
65
- "test:watch": "jest --watch"
61
+ "test": "vitest run --passWithNoTests",
62
+ "test:unit": "vitest run --passWithNoTests tests/unit",
63
+ "test:integration": "vitest run --passWithNoTests tests/integration",
64
+ "test:ci": "vitest run --passWithNoTests --silent --sequence.shuffle",
65
+ "test:watch": "vitest --watch"
66
66
  },
67
67
  "dependencies": {
68
68
  "@graphql-markdown/formatters": "",
@@ -1,51 +0,0 @@
1
- /**
2
- * Format event helpers for printer-legacy.
3
- *
4
- * This module provides helper functions to emit MDX format events and handle
5
- * fallback to default formatters when no custom handlers are registered.
6
- *
7
- * @packageDocumentation
8
- */
9
- import type { AdmonitionType, Badge, CollapsibleOption, FrontMatterOptions, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
10
- /**
11
- * Default badge formatter.
12
- */
13
- export declare const formatMDXBadge: (badge: Badge) => MDXString;
14
- /**
15
- * Default admonition formatter.
16
- */
17
- export declare const formatMDXAdmonition: ({ text, title, type, icon }: AdmonitionType, _meta: Maybe<MetaInfo>) => MDXString;
18
- /**
19
- * Default bullet formatter.
20
- */
21
- export declare const formatMDXBullet: (text?: string) => MDXString;
22
- /**
23
- * Default details formatter.
24
- *
25
- * The returned string **must** contain a `\r` (carriage return) character as a
26
- * delimiter between the opening part (ending after `</summary>`) and the
27
- * closing part (starting before `</details>`). `printSection` calls
28
- * `result.split('\r')` to obtain `[openSection, closeSection]`; without this
29
- * delimiter the closing tag is lost and items are rendered outside the
30
- * collapsible element.
31
- *
32
- * Custom implementations of `formatMDXDetails` must follow the same contract.
33
- */
34
- export declare const formatMDXDetails: ({ dataOpen, }: CollapsibleOption) => MDXString;
35
- /**
36
- * Default frontmatter formatter.
37
- */
38
- export declare const formatMDXFrontmatter: (_props: Maybe<FrontMatterOptions>, formatted: Maybe<string[]>) => MDXString;
39
- /**
40
- * Default link formatter.
41
- */
42
- export declare const formatMDXLink: (link: TypeLink) => TypeLink;
43
- /**
44
- * Default name entity formatter.
45
- */
46
- export declare const formatMDXNameEntity: (name: string, parentType?: Maybe<string>) => MDXString;
47
- /**
48
- * Default specified-by link formatter.
49
- */
50
- export declare const formatMDXSpecifiedByLink: (url: string) => MDXString;
51
- //# sourceMappingURL=format-helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-helpers.d.ts","sourceRoot":"","sources":["../src/format-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AASjC;;GAEG;AACH,eAAO,MAAM,cAAc,UAAW,KAAK,KAAG,SAE7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,gCACD,cAAc,SACpC,KAAK,CAAC,QAAQ,CAAC,KACrB,SAEF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,qBAAgB,SAE3C,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,kBAE1B,iBAAiB,KAAG,SAEtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,WACvB,KAAK,CAAC,kBAAkB,CAAC,aACtB,KAAK,CAAC,MAAM,EAAE,CAAC,KACzB,SAMF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,SAAU,QAAQ,KAAG,QAE9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,SACxB,MAAM,eACC,KAAK,CAAC,MAAM,CAAC,KACzB,SAKF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,QAAS,MAAM,KAAG,SAEtD,CAAC"}
@@ -1,83 +0,0 @@
1
- "use strict";
2
- /**
3
- * Format event helpers for printer-legacy.
4
- *
5
- * This module provides helper functions to emit MDX format events and handle
6
- * fallback to default formatters when no custom handlers are registered.
7
- *
8
- * @packageDocumentation
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
12
- // Import default formatters
13
- const strings_1 = require("./const/strings");
14
- /**
15
- * Default badge formatter.
16
- */
17
- const formatMDXBadge = (badge) => {
18
- return `<mark class="gqlmd-mdx-badge">${badge.text}</mark>`;
19
- };
20
- exports.formatMDXBadge = formatMDXBadge;
21
- /**
22
- * Default admonition formatter.
23
- */
24
- const formatMDXAdmonition = ({ text, title, type, icon }, _meta) => {
25
- 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>`;
26
- };
27
- exports.formatMDXAdmonition = formatMDXAdmonition;
28
- /**
29
- * Default bullet formatter.
30
- */
31
- const formatMDXBullet = (text = "") => {
32
- return `<span class="gqlmd-mdx-bullet">&nbsp;●&nbsp;</span>${text}`;
33
- };
34
- exports.formatMDXBullet = formatMDXBullet;
35
- /**
36
- * Default details formatter.
37
- *
38
- * The returned string **must** contain a `\r` (carriage return) character as a
39
- * delimiter between the opening part (ending after `</summary>`) and the
40
- * closing part (starting before `</details>`). `printSection` calls
41
- * `result.split('\r')` to obtain `[openSection, closeSection]`; without this
42
- * delimiter the closing tag is lost and items are rendered outside the
43
- * collapsible element.
44
- *
45
- * Custom implementations of `formatMDXDetails` must follow the same contract.
46
- */
47
- const formatMDXDetails = ({ dataOpen, }) => {
48
- 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}`;
49
- };
50
- exports.formatMDXDetails = formatMDXDetails;
51
- /**
52
- * Default frontmatter formatter.
53
- */
54
- const formatMDXFrontmatter = (_props, formatted) => {
55
- return formatted
56
- ? [strings_1.FRONT_MATTER_DELIMITER, ...formatted, strings_1.FRONT_MATTER_DELIMITER].join(strings_1.MARKDOWN_EOL)
57
- : "";
58
- };
59
- exports.formatMDXFrontmatter = formatMDXFrontmatter;
60
- /**
61
- * Default link formatter.
62
- */
63
- const formatMDXLink = (link) => {
64
- return link;
65
- };
66
- exports.formatMDXLink = formatMDXLink;
67
- /**
68
- * Default name entity formatter.
69
- */
70
- const formatMDXNameEntity = (name, parentType) => {
71
- const parentName = parentType
72
- ? `<code class="gqlmd-mdx-entity-parent">${parentType}</code>.`
73
- : "";
74
- return `<span class="gqlmd-mdx-entity">${parentName}<code class="gqlmd-mdx-entity-name">${name}</code></span>`;
75
- };
76
- exports.formatMDXNameEntity = formatMDXNameEntity;
77
- /**
78
- * Default specified-by link formatter.
79
- */
80
- const formatMDXSpecifiedByLink = (url) => {
81
- return `<span class="gqlmd-mdx-specifiedby">Specification<a class="gqlmd-mdx-specifiedby-link" target="_blank" href="${url}" title="Specified by ${url}">⎘</a></span>`;
82
- };
83
- exports.formatMDXSpecifiedByLink = formatMDXSpecifiedByLink;
@@ -1,19 +0,0 @@
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";
15
- export declare const mdxDeclaration = "";
16
- declare const defaultModule: MDXSupportType;
17
- export declare const mdxModule: (mdxPackage?: Record<string, unknown>) => Promise<Readonly<MDXSupportType>>;
18
- export default defaultModule;
19
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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 DELETED
@@ -1,190 +0,0 @@
1
- "use strict";
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
- */
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.mdxModule = exports.mdxDeclaration = void 0;
17
- const strings_1 = require("../const/strings");
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>`;
35
- };
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>`;
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
- */
69
- const formatMDXBullet = (text = "") => {
70
- return `<span class="gqlmd-mdx-bullet">&nbsp;●&nbsp;</span>${text}`;
71
- };
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\r\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}\r${strings_1.MARKDOWN_EOL}</details>${strings_1.MARKDOWN_EOP}`;
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
- */
104
- const formatMDXSpecifiedByLink = (url) => {
105
- return `<span class="gqlmd-mdx-specifiedby">Specification<a class="gqlmd-mdx-specifiedby-link" target="_blank" href="${url}" title="Specified by ${url}">⎘</a></span>`;
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
- */
122
- const formatMDXNameEntity = (name, parentType) => {
123
- const parentName = parentType
124
- ? `<code class="gqlmd-mdx-entity-parent">${parentType}</code>.`
125
- : "";
126
- return `<span class="gqlmd-mdx-entity">${parentName}<code class="gqlmd-mdx-entity-name">${name}</code></span>`;
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
- */
137
- const formatMDXLink = (link) => {
138
- return link;
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
- };
161
- exports.mdxDeclaration = "";
162
- const defaultModule = {
163
- formatMDXAdmonition,
164
- formatMDXBadge,
165
- formatMDXBullet,
166
- formatMDXDetails,
167
- formatMDXFrontmatter,
168
- formatMDXNameEntity,
169
- formatMDXSpecifiedByLink,
170
- mdxDeclaration: exports.mdxDeclaration,
171
- };
172
- const mdxModule = async (mdxPackage) => {
173
- if (!mdxPackage) {
174
- return defaultModule;
175
- }
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
- };
188
- };
189
- exports.mdxModule = mdxModule;
190
- exports.default = defaultModule;