@graphql-markdown/formatters 1.0.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 (50) hide show
  1. package/README.md +106 -0
  2. package/dist/defaults.d.ts +63 -0
  3. package/dist/defaults.d.ts.map +1 -0
  4. package/dist/defaults.js +93 -0
  5. package/dist/docfx/index.d.ts +56 -0
  6. package/dist/docfx/index.d.ts.map +1 -0
  7. package/dist/docfx/index.js +184 -0
  8. package/dist/docfx.d.ts +20 -0
  9. package/dist/docfx.d.ts.map +1 -0
  10. package/dist/docfx.js +71 -0
  11. package/dist/docusaurus/index.d.ts +76 -0
  12. package/dist/docusaurus/index.d.ts.map +1 -0
  13. package/dist/docusaurus/index.js +139 -0
  14. package/dist/docusaurus.d.ts +20 -0
  15. package/dist/docusaurus.d.ts.map +1 -0
  16. package/dist/docusaurus.js +72 -0
  17. package/dist/fumadocs/index.d.ts +42 -0
  18. package/dist/fumadocs/index.d.ts.map +1 -0
  19. package/dist/fumadocs/index.js +80 -0
  20. package/dist/honkit/index.d.ts +75 -0
  21. package/dist/honkit/index.d.ts.map +1 -0
  22. package/dist/honkit/index.js +135 -0
  23. package/dist/hugo/index.d.ts +70 -0
  24. package/dist/hugo/index.d.ts.map +1 -0
  25. package/dist/hugo/index.js +143 -0
  26. package/dist/hugo.d.ts +20 -0
  27. package/dist/hugo.d.ts.map +1 -0
  28. package/dist/hugo.js +68 -0
  29. package/dist/index.d.ts +26 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +61 -0
  32. package/dist/mdbook/index.d.ts +69 -0
  33. package/dist/mdbook/index.d.ts.map +1 -0
  34. package/dist/mdbook/index.js +176 -0
  35. package/dist/mdbook.d.ts +20 -0
  36. package/dist/mdbook.d.ts.map +1 -0
  37. package/dist/mdbook.js +51 -0
  38. package/dist/mkdocs/index.d.ts +69 -0
  39. package/dist/mkdocs/index.d.ts.map +1 -0
  40. package/dist/mkdocs/index.js +138 -0
  41. package/dist/mkdocs.d.ts +19 -0
  42. package/dist/mkdocs.d.ts.map +1 -0
  43. package/dist/mkdocs.js +65 -0
  44. package/dist/starlight/index.d.ts +65 -0
  45. package/dist/starlight/index.d.ts.map +1 -0
  46. package/dist/starlight/index.js +113 -0
  47. package/dist/vocs/index.d.ts +55 -0
  48. package/dist/vocs/index.d.ts.map +1 -0
  49. package/dist/vocs/index.js +101 -0
  50. package/package.json +231 -0
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Docusaurus MDX formatter for GraphQL documentation output.
3
+ *
4
+ * Produces MDX markup compatible with Docusaurus v2 and v3,
5
+ * using Badge, Bullet, SpecifiedBy components and native admonition syntax.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { AdmonitionType, Badge, CollapsibleOption, Formatter, FrontMatterOptions, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
10
+ /** MDX component definitions prepended to every generated file. */
11
+ export declare const mdxDeclaration: MDXString;
12
+ /**
13
+ * Formats a badge using the inline `<Badge>` component defined in `mdxDeclaration`.
14
+ * Appends a CSS class derived from `classname` (e.g. `badge--deprecated`).
15
+ * @param badge - Badge data containing text and optional classname
16
+ * @returns Formatted Badge component string
17
+ */
18
+ export declare const formatMDXBadge: ({ text, classname }: Badge) => MDXString;
19
+ /**
20
+ * Formats an admonition using Docusaurus native `:::type` callout syntax.
21
+ * Detects Docusaurus v2 (via `meta`) and uses `:::caution` instead of `:::warning`.
22
+ * @param admonition - Admonition data with text, title, and type
23
+ * @param meta - Optional metadata used to detect Docusaurus version
24
+ * @returns Formatted admonition string
25
+ */
26
+ export declare const formatMDXAdmonition: ({ text, title, type }: AdmonitionType, meta: Maybe<MetaInfo>) => MDXString;
27
+ /**
28
+ * Formats a bullet point using the inline `<Bullet/>` component defined in `mdxDeclaration`.
29
+ * @param text - Optional text to append after the bullet
30
+ * @returns Formatted Bullet component string
31
+ */
32
+ export declare const formatMDXBullet: (text?: string) => MDXString;
33
+ /**
34
+ * Formats a collapsible block as an HTML `<details>` element with
35
+ * toggle labels that swap via the `hidden` attribute.
36
+ * Text is escaped so curly braces and angle brackets don't break MDX.
37
+ * @param option - Configuration for open/close label text
38
+ * @returns Formatted details element string
39
+ */
40
+ export declare const formatMDXDetails: ({ dataOpen, dataClose, }: CollapsibleOption) => MDXString;
41
+ /**
42
+ * Formats a "specified by" link using the inline `<SpecifiedBy>` component.
43
+ * @param url - URL to the specification
44
+ * @returns Formatted SpecifiedBy component string
45
+ */
46
+ export declare const formatMDXSpecifiedByLink: (url: string) => MDXString;
47
+ /**
48
+ * Formats a named entity as an inline `<code>` element with the parent type
49
+ * in normal weight and the entity name in bold.
50
+ * Text is escaped so curly braces don't break MDX.
51
+ * @param name - Entity name
52
+ * @param parentType - Optional parent type name for qualified references
53
+ * @returns Formatted JSX code element string
54
+ */
55
+ export declare const formatMDXNameEntity: (name: string, parentType?: Maybe<string>) => MDXString;
56
+ /**
57
+ * Appends `.mdx` to internal link URLs.
58
+ * @param link - Link data with URL and text
59
+ * @returns Link with `.mdx` extension appended to the URL
60
+ */
61
+ export declare const formatMDXLink: ({ text, url }: TypeLink) => TypeLink;
62
+ /**
63
+ * Formats YAML front matter wrapped in `---` delimiters.
64
+ * @param _props - Front matter options (unused)
65
+ * @param formatted - Pre-formatted front matter lines
66
+ * @returns Formatted front matter block, or empty string if no lines provided
67
+ */
68
+ export declare const formatMDXFrontmatter: (_props: Maybe<FrontMatterOptions>, formatted: Maybe<string[]>) => MDXString;
69
+ /**
70
+ * Creates a Docusaurus formatter.
71
+ * Captures `meta` in closure so `formatMDXAdmonition` can detect the Docusaurus version.
72
+ * @param meta - Optional metadata used to detect Docusaurus version
73
+ * @returns A complete {@link Formatter} implementation for Docusaurus MDX output
74
+ */
75
+ export declare const createMDXFormatter: (meta?: Maybe<MetaInfo>) => Formatter;
76
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/docusaurus/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAejC,mEAAmE;AACnE,eAAO,MAAM,cAAc,EAAE,SAQf,CAAC;AAEf;;;;;GAKG;AACH,eAAO,MAAM,cAAc,wBAAyB,KAAK,KAAG,SAI3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc,QAC/B,KAAK,CAAC,QAAQ,CAAC,KACpB,SAOF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,UAAU,MAAM,KAAQ,SAEnD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,6BAG1B,iBAAiB,KAAG,SAItB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAAS,MAAM,KAAG,SAEtD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,SACxB,MAAM,eACC,KAAK,CAAC,MAAM,CAAC,KACzB,SAGF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,kBAAmB,QAAQ,KAAG,QAKvD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,WACvB,KAAK,CAAC,kBAAkB,CAAC,aACtB,KAAK,CAAC,MAAM,EAAE,CAAC,KACzB,SAMF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,UAAW,KAAK,CAAC,QAAQ,CAAC,KAAG,SAgB3D,CAAC"}
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ /**
3
+ * Docusaurus MDX formatter for GraphQL documentation output.
4
+ *
5
+ * Produces MDX markup compatible with Docusaurus v2 and v3,
6
+ * using Badge, Bullet, SpecifiedBy components and native admonition syntax.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.createMDXFormatter = exports.formatMDXFrontmatter = exports.formatMDXLink = exports.formatMDXNameEntity = exports.formatMDXSpecifiedByLink = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxDeclaration = void 0;
12
+ const helpers_1 = require("@graphql-markdown/helpers");
13
+ const utils_1 = require("@graphql-markdown/utils");
14
+ const LINK_MDX_EXTENSION = ".mdx";
15
+ const DEFAULT_CSS_CLASSNAME = "badge--secondary";
16
+ /** MDX component definitions prepended to every generated file. */
17
+ exports.mdxDeclaration = `
18
+ export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em', color: 'var(--ifm-color-secondary-darkest)' }}>&nbsp;●&nbsp;</span></>
19
+
20
+ export const SpecifiedBy = (props) => <>Specification<a className="link" style={{ fontSize:'1.5em', paddingLeft:'4px' }} target="_blank" href={props.url} title={'Specified by ' + props.url}>⎘</a></>
21
+
22
+ export const Badge = (props) => <><span className={props.class}>{props.text}</span></>
23
+
24
+
25
+ `;
26
+ /**
27
+ * Formats a badge using the inline `<Badge>` component defined in `mdxDeclaration`.
28
+ * Appends a CSS class derived from `classname` (e.g. `badge--deprecated`).
29
+ * @param badge - Badge data containing text and optional classname
30
+ * @returns Formatted Badge component string
31
+ */
32
+ const formatMDXBadge = ({ text, classname }) => {
33
+ const style = typeof classname === "string" ? `badge--${classname.toLowerCase()}` : "";
34
+ return `<Badge class="badge ${DEFAULT_CSS_CLASSNAME} ${style}" text="${text}"/>`;
35
+ };
36
+ exports.formatMDXBadge = formatMDXBadge;
37
+ /**
38
+ * Formats an admonition using Docusaurus native `:::type` callout syntax.
39
+ * Detects Docusaurus v2 (via `meta`) and uses `:::caution` instead of `:::warning`.
40
+ * @param admonition - Admonition data with text, title, and type
41
+ * @param meta - Optional metadata used to detect Docusaurus version
42
+ * @returns Formatted admonition string
43
+ */
44
+ const formatMDXAdmonition = ({ text, title, type }, meta) => {
45
+ const isDocusaurus = meta?.generatorFrameworkName === "docusaurus";
46
+ if (isDocusaurus && meta.generatorFrameworkVersion?.startsWith("2")) {
47
+ const oldType = type === "warning" ? "caution" : type;
48
+ return `${utils_1.MARKDOWN_EOP}:::${oldType} ${title}${text}:::`;
49
+ }
50
+ return `${utils_1.MARKDOWN_EOP}:::${type}[${title}]${text}:::`;
51
+ };
52
+ exports.formatMDXAdmonition = formatMDXAdmonition;
53
+ /**
54
+ * Formats a bullet point using the inline `<Bullet/>` component defined in `mdxDeclaration`.
55
+ * @param text - Optional text to append after the bullet
56
+ * @returns Formatted Bullet component string
57
+ */
58
+ const formatMDXBullet = (text = "") => {
59
+ return `<Bullet />${text}`;
60
+ };
61
+ exports.formatMDXBullet = formatMDXBullet;
62
+ /**
63
+ * Formats a collapsible block as an HTML `<details>` element with
64
+ * toggle labels that swap via the `hidden` attribute.
65
+ * Text is escaped so curly braces and angle brackets don't break MDX.
66
+ * @param option - Configuration for open/close label text
67
+ * @returns Formatted details element string
68
+ */
69
+ const formatMDXDetails = ({ dataOpen, dataClose, }) => {
70
+ const openLabel = (0, utils_1.escapeMDX)(`Hide ${dataOpen}`);
71
+ const closeLabel = (0, utils_1.escapeMDX)(`Show ${dataClose}`);
72
+ return `${utils_1.MARKDOWN_EOP}<details class="graphql-markdown-details">${utils_1.MARKDOWN_EOL}<summary>${utils_1.MARKDOWN_EOL}<span class="graphql-markdown-details-label-closed">${closeLabel}</span>${utils_1.MARKDOWN_EOL}<span class="graphql-markdown-details-label-open" hidden>${openLabel}</span>${utils_1.MARKDOWN_EOL}</summary>${utils_1.MARKDOWN_EOP}\r${utils_1.MARKDOWN_EOP}</details>${utils_1.MARKDOWN_EOP}`;
73
+ };
74
+ exports.formatMDXDetails = formatMDXDetails;
75
+ /**
76
+ * Formats a "specified by" link using the inline `<SpecifiedBy>` component.
77
+ * @param url - URL to the specification
78
+ * @returns Formatted SpecifiedBy component string
79
+ */
80
+ const formatMDXSpecifiedByLink = (url) => {
81
+ return `<SpecifiedBy url="${url}"/>`;
82
+ };
83
+ exports.formatMDXSpecifiedByLink = formatMDXSpecifiedByLink;
84
+ /**
85
+ * Formats a named entity as an inline `<code>` element with the parent type
86
+ * in normal weight and the entity name in bold.
87
+ * Text is escaped so curly braces don't break MDX.
88
+ * @param name - Entity name
89
+ * @param parentType - Optional parent type name for qualified references
90
+ * @returns Formatted JSX code element string
91
+ */
92
+ const formatMDXNameEntity = (name, parentType) => {
93
+ const parentName = parentType ? `${parentType}.` : "";
94
+ return `<code style={{ fontWeight: 'normal' }}>${(0, utils_1.escapeMDX)(parentName)}<b>${(0, utils_1.escapeMDX)(name)}</b></code>`;
95
+ };
96
+ exports.formatMDXNameEntity = formatMDXNameEntity;
97
+ /**
98
+ * Appends `.mdx` to internal link URLs.
99
+ * @param link - Link data with URL and text
100
+ * @returns Link with `.mdx` extension appended to the URL
101
+ */
102
+ const formatMDXLink = ({ text, url }) => {
103
+ return {
104
+ text,
105
+ url: (0, helpers_1.appendLinkExtension)(url, LINK_MDX_EXTENSION),
106
+ };
107
+ };
108
+ exports.formatMDXLink = formatMDXLink;
109
+ /**
110
+ * Formats YAML front matter wrapped in `---` delimiters.
111
+ * @param _props - Front matter options (unused)
112
+ * @param formatted - Pre-formatted front matter lines
113
+ * @returns Formatted front matter block, or empty string if no lines provided
114
+ */
115
+ const formatMDXFrontmatter = (_props, formatted) => {
116
+ return (0, helpers_1.formatMarkdownFrontmatter)(formatted, utils_1.FRONT_MATTER_DELIMITER, utils_1.MARKDOWN_EOL);
117
+ };
118
+ exports.formatMDXFrontmatter = formatMDXFrontmatter;
119
+ /**
120
+ * Creates a Docusaurus formatter.
121
+ * Captures `meta` in closure so `formatMDXAdmonition` can detect the Docusaurus version.
122
+ * @param meta - Optional metadata used to detect Docusaurus version
123
+ * @returns A complete {@link Formatter} implementation for Docusaurus MDX output
124
+ */
125
+ const createMDXFormatter = (meta) => {
126
+ return {
127
+ formatMDXBadge: exports.formatMDXBadge,
128
+ formatMDXAdmonition: (admonition, _meta) => {
129
+ return (0, exports.formatMDXAdmonition)(admonition, meta ?? _meta);
130
+ },
131
+ formatMDXBullet: exports.formatMDXBullet,
132
+ formatMDXDetails: exports.formatMDXDetails,
133
+ formatMDXFrontmatter: exports.formatMDXFrontmatter,
134
+ formatMDXLink: exports.formatMDXLink,
135
+ formatMDXNameEntity: exports.formatMDXNameEntity,
136
+ formatMDXSpecifiedByLink: exports.formatMDXSpecifiedByLink,
137
+ };
138
+ };
139
+ exports.createMDXFormatter = createMDXFormatter;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Docusaurus MDX formatter for GraphQL documentation output.
3
+ *
4
+ * Produces MDX markup compatible with Docusaurus v2 and v3,
5
+ * using Badge, Bullet, SpecifiedBy components and native admonition syntax.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { AdmonitionType, Badge, CollapsibleOption, Formatter, FrontMatterOptions, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
10
+ export declare const mdxDeclaration: MDXString;
11
+ export declare const formatMDXBadge: ({ text, classname }: Badge) => MDXString;
12
+ export declare const formatMDXAdmonition: ({ text, title, type }: AdmonitionType, meta: Maybe<MetaInfo>) => MDXString;
13
+ export declare const formatMDXBullet: (text?: string) => MDXString;
14
+ export declare const formatMDXDetails: ({ dataOpen, dataClose, }: CollapsibleOption) => MDXString;
15
+ export declare const formatMDXSpecifiedByLink: (url: string) => MDXString;
16
+ export declare const formatMDXNameEntity: (name: string, parentType?: Maybe<string>) => MDXString;
17
+ export declare const formatMDXLink: ({ text, url }: TypeLink) => TypeLink;
18
+ export declare const formatMDXFrontmatter: (_props: Maybe<FrontMatterOptions>, formatted: Maybe<string[]>) => MDXString;
19
+ export declare const createMDXFormatter: (meta?: Maybe<MetaInfo>) => Formatter;
20
+ //# sourceMappingURL=docusaurus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docusaurus.d.ts","sourceRoot":"","sources":["../src/docusaurus.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAWjC,eAAO,MAAM,cAAc,EAAE,SAQf,CAAC;AAEf,eAAO,MAAM,cAAc,wBAAyB,KAAK,KAAG,SAI3D,CAAC;AAEF,eAAO,MAAM,mBAAmB,0BACP,cAAc,QAC/B,KAAK,CAAC,QAAQ,CAAC,KACpB,SAOF,CAAC;AAEF,eAAO,MAAM,eAAe,UAAU,MAAM,KAAQ,SAClB,CAAC;AAEnC,eAAO,MAAM,gBAAgB,6BAG1B,iBAAiB,KAAG,SAItB,CAAC;AAEF,eAAO,MAAM,wBAAwB,QAAS,MAAM,KAAG,SACX,CAAC;AAE7C,eAAO,MAAM,mBAAmB,SACxB,MAAM,eACC,KAAK,CAAC,MAAM,CAAC,KACzB,SAGF,CAAC;AAEF,eAAO,MAAM,aAAa,kBAAmB,QAAQ,KAAG,QAGtD,CAAC;AAEH,eAAO,MAAM,oBAAoB,WACvB,KAAK,CAAC,kBAAkB,CAAC,aACtB,KAAK,CAAC,MAAM,EAAE,CAAC,KACzB,SAKoB,CAAC;AAExB,eAAO,MAAM,kBAAkB,UAAW,KAAK,CAAC,QAAQ,CAAC,KAAG,SAY1D,CAAC"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ /**
3
+ * Docusaurus MDX formatter for GraphQL documentation output.
4
+ *
5
+ * Produces MDX markup compatible with Docusaurus v2 and v3,
6
+ * using Badge, Bullet, SpecifiedBy components and native admonition syntax.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.createMDXFormatter = exports.formatMDXFrontmatter = exports.formatMDXLink = exports.formatMDXNameEntity = exports.formatMDXSpecifiedByLink = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxDeclaration = void 0;
12
+ const utils_1 = require("@graphql-markdown/utils");
13
+ const LINK_MDX_EXTENSION = ".mdx";
14
+ const DEFAULT_CSS_CLASSNAME = "badge--secondary";
15
+ exports.mdxDeclaration = `
16
+ export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em', color: 'var(--ifm-color-secondary-darkest)' }}>&nbsp;●&nbsp;</span></>
17
+
18
+ export const SpecifiedBy = (props) => <>Specification<a className="link" style={{ fontSize:'1.5em', paddingLeft:'4px' }} target="_blank" href={props.url} title={'Specified by ' + props.url}>⎘</a></>
19
+
20
+ export const Badge = (props) => <><span className={props.class}>{props.text}</span></>
21
+
22
+
23
+ `;
24
+ const formatMDXBadge = ({ text, classname }) => {
25
+ const style = typeof classname === "string" ? `badge--${classname.toLowerCase()}` : "";
26
+ return `<Badge class="badge ${DEFAULT_CSS_CLASSNAME} ${style}" text="${text}"/>`;
27
+ };
28
+ exports.formatMDXBadge = formatMDXBadge;
29
+ const formatMDXAdmonition = ({ text, title, type }, meta) => {
30
+ const isDocusaurus = meta?.generatorFrameworkName === "docusaurus";
31
+ if (isDocusaurus && meta.generatorFrameworkVersion?.startsWith("2")) {
32
+ const oldType = type === "warning" ? "caution" : type;
33
+ return `${utils_1.MARKDOWN_EOP}:::${oldType} ${title}${text}:::`;
34
+ }
35
+ return `${utils_1.MARKDOWN_EOP}:::${type}[${title}]${text}:::`;
36
+ };
37
+ exports.formatMDXAdmonition = formatMDXAdmonition;
38
+ const formatMDXBullet = (text = "") => `<Bullet />${text}`;
39
+ exports.formatMDXBullet = formatMDXBullet;
40
+ const formatMDXDetails = ({ dataOpen, dataClose, }) => {
41
+ const openLabel = (0, utils_1.escapeMDX)(`Hide ${dataOpen}`);
42
+ const closeLabel = (0, utils_1.escapeMDX)(`Show ${dataClose}`);
43
+ return `${utils_1.MARKDOWN_EOP}<details class="graphql-markdown-details">${utils_1.MARKDOWN_EOL}<summary>${utils_1.MARKDOWN_EOL}<span class="graphql-markdown-details-label-closed">${closeLabel}</span>${utils_1.MARKDOWN_EOL}<span class="graphql-markdown-details-label-open" hidden>${openLabel}</span>${utils_1.MARKDOWN_EOL}</summary>${utils_1.MARKDOWN_EOP}\r${utils_1.MARKDOWN_EOP}</details>${utils_1.MARKDOWN_EOP}`;
44
+ };
45
+ exports.formatMDXDetails = formatMDXDetails;
46
+ const formatMDXSpecifiedByLink = (url) => `<SpecifiedBy url="${url}"/>`;
47
+ exports.formatMDXSpecifiedByLink = formatMDXSpecifiedByLink;
48
+ const formatMDXNameEntity = (name, parentType) => {
49
+ const parentName = parentType ? `${parentType}.` : "";
50
+ return `<code style={{ fontWeight: 'normal' }}>${(0, utils_1.escapeMDX)(parentName)}<b>${(0, utils_1.escapeMDX)(name)}</b></code>`;
51
+ };
52
+ exports.formatMDXNameEntity = formatMDXNameEntity;
53
+ const formatMDXLink = ({ text, url }) => ({
54
+ text,
55
+ url: `${url}${LINK_MDX_EXTENSION}`,
56
+ });
57
+ exports.formatMDXLink = formatMDXLink;
58
+ const formatMDXFrontmatter = (_props, formatted) => formatted
59
+ ? [utils_1.FRONT_MATTER_DELIMITER, ...formatted, utils_1.FRONT_MATTER_DELIMITER].join(utils_1.MARKDOWN_EOL)
60
+ : "";
61
+ exports.formatMDXFrontmatter = formatMDXFrontmatter;
62
+ const createMDXFormatter = (meta) => ({
63
+ formatMDXBadge: exports.formatMDXBadge,
64
+ formatMDXAdmonition: (admonition, _meta) => (0, exports.formatMDXAdmonition)(admonition, meta ?? _meta),
65
+ formatMDXBullet: exports.formatMDXBullet,
66
+ formatMDXDetails: exports.formatMDXDetails,
67
+ formatMDXFrontmatter: exports.formatMDXFrontmatter,
68
+ formatMDXLink: exports.formatMDXLink,
69
+ formatMDXNameEntity: exports.formatMDXNameEntity,
70
+ formatMDXSpecifiedByLink: exports.formatMDXSpecifiedByLink,
71
+ });
72
+ exports.createMDXFormatter = createMDXFormatter;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Fumadocs formatter for GraphQL documentation output.
3
+ *
4
+ * Produces MDX compatible with Next.js Fumadocs using its native
5
+ * Callout component for admonitions and Material UI Chip for badges.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { AdmonitionType, Badge, Formatter, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
10
+ /** File extension used for generated pages. */
11
+ export declare const mdxExtension: ".mdx";
12
+ /** MDX import statement prepended to every generated file to register Fumadocs and MUI components. */
13
+ export declare const mdxDeclaration: MDXString;
14
+ /**
15
+ * Formats a badge using the Material UI `<Chip>` component.
16
+ * Maps `DEPRECATED` classname to `warning` color; all others use `info`.
17
+ * @param badge - Badge data containing text and optional classname
18
+ * @returns Formatted MUI Chip component string
19
+ */
20
+ export declare const formatMDXBadge: ({ text, classname }: Badge) => MDXString;
21
+ /**
22
+ * Formats an admonition using the Fumadocs `<Callout>` component.
23
+ * Maps `warning` type to `warn`; all other types use `info`.
24
+ * @param admonition - Admonition data with text, title, and type
25
+ * @param _meta - Unused metadata parameter
26
+ * @returns Formatted Fumadocs Callout component string
27
+ */
28
+ export declare const formatMDXAdmonition: ({ text, title, type }: AdmonitionType, _meta: Maybe<MetaInfo>) => MDXString;
29
+ /**
30
+ * Appends `.mdx` to internal link URLs.
31
+ * @param link - Link data with URL and text
32
+ * @returns Link with `.mdx` extension appended to the URL
33
+ */
34
+ export declare const formatMDXLink: ({ text, url }: TypeLink) => TypeLink;
35
+ export { formatMDXBullet, formatMDXDetails, formatMDXFrontmatter, formatMDXNameEntity, formatMDXSpecifiedByLink, } from "../defaults";
36
+ /**
37
+ * Creates a Fumadocs formatter.
38
+ * @param _meta - Unused metadata parameter
39
+ * @returns A complete {@link Formatter} implementation for Fumadocs MDX output
40
+ */
41
+ export declare const createMDXFormatter: (_meta?: Maybe<MetaInfo>) => Formatter;
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fumadocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAWjC,+CAA+C;AAC/C,eAAO,MAAM,YAAY,EAAG,MAAe,CAAC;AAE5C,sGAAsG;AACtG,eAAO,MAAM,cAAc,EAAE,SAGf,CAAC;AAEf;;;;;GAKG;AACH,eAAO,MAAM,cAAc,wBAAyB,KAAK,KAAG,SAG3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc,SAC9B,KAAK,CAAC,QAAQ,CAAC,KACrB,SAGF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,kBAAmB,QAAQ,KAAG,QAKvD,CAAC;AAEF,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAW5D,CAAC"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /**
3
+ * Fumadocs formatter for GraphQL documentation output.
4
+ *
5
+ * Produces MDX compatible with Next.js Fumadocs using its native
6
+ * Callout component for admonitions and Material UI Chip for badges.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXLink = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxDeclaration = exports.mdxExtension = void 0;
12
+ const helpers_1 = require("@graphql-markdown/helpers");
13
+ const utils_1 = require("@graphql-markdown/utils");
14
+ const defaults_1 = require("../defaults");
15
+ /** File extension used for generated pages. */
16
+ exports.mdxExtension = ".mdx";
17
+ /** MDX import statement prepended to every generated file to register Fumadocs and MUI components. */
18
+ exports.mdxDeclaration = `
19
+ import { Callout } from 'fumadocs-ui/components/callout';
20
+ import Chip from '@mui/material/Chip';
21
+ `;
22
+ /**
23
+ * Formats a badge using the Material UI `<Chip>` component.
24
+ * Maps `DEPRECATED` classname to `warning` color; all others use `info`.
25
+ * @param badge - Badge data containing text and optional classname
26
+ * @returns Formatted MUI Chip component string
27
+ */
28
+ const formatMDXBadge = ({ text, classname }) => {
29
+ const color = classname === "DEPRECATED" ? "warning" : "info";
30
+ return `<Chip color="${color}" label="${text}" size="small" variant="outlined"/>`;
31
+ };
32
+ exports.formatMDXBadge = formatMDXBadge;
33
+ /**
34
+ * Formats an admonition using the Fumadocs `<Callout>` component.
35
+ * Maps `warning` type to `warn`; all other types use `info`.
36
+ * @param admonition - Admonition data with text, title, and type
37
+ * @param _meta - Unused metadata parameter
38
+ * @returns Formatted Fumadocs Callout component string
39
+ */
40
+ const formatMDXAdmonition = ({ text, title, type }, _meta) => {
41
+ const calloutType = type === "warning" ? "warn" : "info";
42
+ return `${utils_1.MARKDOWN_EOP}<Callout type="${calloutType}" title="${title}">${text}</Callout>`;
43
+ };
44
+ exports.formatMDXAdmonition = formatMDXAdmonition;
45
+ /**
46
+ * Appends `.mdx` to internal link URLs.
47
+ * @param link - Link data with URL and text
48
+ * @returns Link with `.mdx` extension appended to the URL
49
+ */
50
+ const formatMDXLink = ({ text, url }) => {
51
+ return {
52
+ text,
53
+ url: (0, helpers_1.appendLinkExtension)(url, exports.mdxExtension),
54
+ };
55
+ };
56
+ exports.formatMDXLink = formatMDXLink;
57
+ var defaults_2 = require("../defaults");
58
+ Object.defineProperty(exports, "formatMDXBullet", { enumerable: true, get: function () { return defaults_2.formatMDXBullet; } });
59
+ Object.defineProperty(exports, "formatMDXDetails", { enumerable: true, get: function () { return defaults_2.formatMDXDetails; } });
60
+ Object.defineProperty(exports, "formatMDXFrontmatter", { enumerable: true, get: function () { return defaults_2.formatMDXFrontmatter; } });
61
+ Object.defineProperty(exports, "formatMDXNameEntity", { enumerable: true, get: function () { return defaults_2.formatMDXNameEntity; } });
62
+ Object.defineProperty(exports, "formatMDXSpecifiedByLink", { enumerable: true, get: function () { return defaults_2.formatMDXSpecifiedByLink; } });
63
+ /**
64
+ * Creates a Fumadocs formatter.
65
+ * @param _meta - Unused metadata parameter
66
+ * @returns A complete {@link Formatter} implementation for Fumadocs MDX output
67
+ */
68
+ const createMDXFormatter = (_meta) => {
69
+ return {
70
+ formatMDXBadge: exports.formatMDXBadge,
71
+ formatMDXAdmonition: exports.formatMDXAdmonition,
72
+ formatMDXBullet: defaults_1.formatMDXBullet,
73
+ formatMDXDetails: defaults_1.formatMDXDetails,
74
+ formatMDXFrontmatter: defaults_1.formatMDXFrontmatter,
75
+ formatMDXLink: exports.formatMDXLink,
76
+ formatMDXNameEntity: defaults_1.formatMDXNameEntity,
77
+ formatMDXSpecifiedByLink: defaults_1.formatMDXSpecifiedByLink,
78
+ };
79
+ };
80
+ exports.createMDXFormatter = createMDXFormatter;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * HonKit formatter for GraphQL documentation output.
3
+ *
4
+ * Produces plain Markdown compatible with HonKit static site generator.
5
+ * Internal links are converted to .html paths.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import type { AdmonitionType, Badge, CollapsibleOption, Formatter, FrontMatterOptions, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
10
+ export declare const __default: {
11
+ formatMDXBullet: (text?: string) => MDXString;
12
+ };
13
+ /** File extension used for generated pages — HonKit renders plain Markdown to HTML. */
14
+ export declare const mdxExtension: ".md";
15
+ /**
16
+ * Formats a badge as an inline HTML `<span>` with a shared default style.
17
+ * Users can customize badge colors by providing their own `formatMDXBadge` implementation.
18
+ * @param badge - Badge data containing text
19
+ * @returns Formatted inline HTML span string
20
+ */
21
+ export declare const formatMDXBadge: ({ text }: Badge) => MDXString;
22
+ /**
23
+ * Formats an admonition as a Markdown blockquote with a bold prefix label.
24
+ * Maps `warning` type to `WARNING`; all other types use `INFO`.
25
+ * @param admonition - Admonition data with text, title, and type
26
+ * @param _meta - Unused metadata parameter
27
+ * @returns Formatted blockquote string
28
+ */
29
+ export declare const formatMDXAdmonition: ({ text, title, type }: AdmonitionType, _meta: Maybe<MetaInfo>) => MDXString;
30
+ /**
31
+ * Formats a collapsible block as an HTML `<details>` element.
32
+ * @param option - Configuration for open/close label text
33
+ * @returns Formatted details element string
34
+ */
35
+ export declare const formatMDXDetails: ({ dataOpen, dataClose, }: CollapsibleOption) => MDXString;
36
+ /**
37
+ * Formats YAML front matter and appends an H1 heading derived from the `title` prop.
38
+ * Merges `props` entries with `formatted` lines (formatted lines take precedence).
39
+ * Returns empty string if `props` is empty or absent — HonKit renders front matter
40
+ * without a title as literal YAML content.
41
+ * @param props - Front matter options; `title` is used to generate the H1 heading
42
+ * @param formatted - Pre-formatted front matter lines that override props values
43
+ * @returns Formatted front matter block with optional H1, or empty string
44
+ */
45
+ export declare const formatMDXFrontmatter: (props: Maybe<FrontMatterOptions>, formatted: Maybe<string[]>) => MDXString;
46
+ /**
47
+ * Converts internal link URLs to `.html` paths for HonKit static output.
48
+ * Absolute paths without an `.html` extension are suffixed with `.html`.
49
+ * External URLs and fragment-only links are returned unchanged.
50
+ * @param link - Link data with URL and text
51
+ * @returns Link with `.html` extension applied to absolute internal paths
52
+ */
53
+ export declare const formatMDXLink: ({ text, url }: TypeLink) => TypeLink;
54
+ /**
55
+ * Formats a named entity as plain text (no markup).
56
+ * HonKit renders plain Markdown — no JSX or code spans needed.
57
+ * @param name - Entity name
58
+ * @param parentType - Optional parent type name for qualified references
59
+ * @returns Formatted entity reference string
60
+ */
61
+ export declare const formatMDXNameEntity: (name: string, parentType?: Maybe<string>) => MDXString;
62
+ /**
63
+ * Formats a "specified by" link as plain text with the raw URL.
64
+ * HonKit does not render custom JSX components.
65
+ * @param url - URL to the specification
66
+ * @returns Formatted specification text string
67
+ */
68
+ export declare const formatMDXSpecifiedByLink: (url: string) => MDXString;
69
+ /**
70
+ * Creates a HonKit formatter.
71
+ * @param _meta - Unused metadata parameter
72
+ * @returns A complete {@link Formatter} implementation for HonKit output
73
+ */
74
+ export declare const createMDXFormatter: (_meta?: Maybe<MetaInfo>) => Formatter;
75
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/honkit/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAUjC,eAAO,MAAM,SAAS;;CAAsB,CAAC;AAE7C,uFAAuF;AACvF,eAAO,MAAM,YAAY,EAAG,KAAc,CAAC;AAS3C;;;;;GAKG;AACH,eAAO,MAAM,cAAc,aAAc,KAAK,KAAG,SAKhD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc,SAC9B,KAAK,CAAC,QAAQ,CAAC,KACrB,SAGF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,6BAG1B,iBAAiB,KAAG,SAEtB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,UACxB,KAAK,CAAC,kBAAkB,CAAC,aACrB,KAAK,CAAC,MAAM,EAAE,CAAC,KACzB,SAiBF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,kBAAmB,QAAQ,KAAG,QAoBvD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,SACxB,MAAM,eACC,KAAK,CAAC,MAAM,CAAC,KACzB,SAEF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAAS,MAAM,KAAG,SAEtD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAW5D,CAAC"}