@graphql-markdown/formatters 1.0.0 → 1.0.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/dist/hugo.js DELETED
@@ -1,68 +0,0 @@
1
- "use strict";
2
- /**
3
- * Hugo formatter for GraphQL documentation output.
4
- *
5
- * Produces Markdown compatible with Hugo static site generator.
6
- * Uses GitHub-style alerts (Hugo 0.132+) for admonitions and
7
- * strips file extensions from internal links to match Hugo's URL routing.
8
- *
9
- * @packageDocumentation
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
13
- const utils_1 = require("@graphql-markdown/utils");
14
- // Maps graphql-markdown admonition types to Hugo GitHub-style alert types (Hugo 0.132+)
15
- const ALERT_TYPE_MAP = {
16
- note: "NOTE",
17
- tip: "TIP",
18
- info: "IMPORTANT",
19
- warning: "WARNING",
20
- danger: "CAUTION",
21
- deprecated: "WARNING",
22
- caution: "CAUTION",
23
- success: "NOTE",
24
- };
25
- const quoteLines = (text) => text
26
- .split(utils_1.MARKDOWN_EOL)
27
- .map((line) => `> ${line}`)
28
- .join(utils_1.MARKDOWN_EOL);
29
- const formatMDXBadge = ({ text }) => `<mark class="gqlmd-hugo-badge">${text}</mark>`;
30
- exports.formatMDXBadge = formatMDXBadge;
31
- const formatMDXAdmonition = ({ text, title, type }, _meta) => {
32
- const alertType = ALERT_TYPE_MAP[type.toLowerCase()] ?? "NOTE";
33
- const titleLine = title ? `${utils_1.MARKDOWN_EOL}> **${title}**` : "";
34
- return `${utils_1.MARKDOWN_EOP}> [!${alertType}]${titleLine}${utils_1.MARKDOWN_EOL}${quoteLines(text)}${utils_1.MARKDOWN_EOL}`;
35
- };
36
- exports.formatMDXAdmonition = formatMDXAdmonition;
37
- const formatMDXBullet = (text = "") => `&bull;&nbsp;${text}`;
38
- exports.formatMDXBullet = formatMDXBullet;
39
- const formatMDXDetails = ({ dataOpen, dataClose, }) => `${utils_1.MARKDOWN_EOP}<details>${utils_1.MARKDOWN_EOL}<summary>${dataOpen}</summary>${utils_1.MARKDOWN_EOL}${utils_1.MARKDOWN_EOL}\r${utils_1.MARKDOWN_EOL}${utils_1.MARKDOWN_EOL}<p><em>${dataClose}</em></p>${utils_1.MARKDOWN_EOL}</details>${utils_1.MARKDOWN_EOP}`;
40
- exports.formatMDXDetails = formatMDXDetails;
41
- const formatMDXFrontmatter = (_props, formatted) => formatted
42
- ? [utils_1.FRONT_MATTER_DELIMITER, ...formatted, utils_1.FRONT_MATTER_DELIMITER].join(utils_1.MARKDOWN_EOL)
43
- : "";
44
- exports.formatMDXFrontmatter = formatMDXFrontmatter;
45
- // Hugo resolves pages by directory, not by .md extension — strip it from internal links
46
- const formatMDXLink = ({ text, url }) => ({
47
- text,
48
- url: url.replace(/\.md$/, ""),
49
- });
50
- exports.formatMDXLink = formatMDXLink;
51
- const formatMDXNameEntity = (name, parentType) => {
52
- const parentName = parentType ? `${parentType}.` : "";
53
- return `\`${parentName}${name}\``;
54
- };
55
- exports.formatMDXNameEntity = formatMDXNameEntity;
56
- const formatMDXSpecifiedByLink = (url) => `[Specification ⎘](${url})`;
57
- exports.formatMDXSpecifiedByLink = formatMDXSpecifiedByLink;
58
- const createMDXFormatter = (_meta) => ({
59
- formatMDXBadge: exports.formatMDXBadge,
60
- formatMDXAdmonition: exports.formatMDXAdmonition,
61
- formatMDXBullet: exports.formatMDXBullet,
62
- formatMDXDetails: exports.formatMDXDetails,
63
- formatMDXFrontmatter: exports.formatMDXFrontmatter,
64
- formatMDXLink: exports.formatMDXLink,
65
- formatMDXNameEntity: exports.formatMDXNameEntity,
66
- formatMDXSpecifiedByLink: exports.formatMDXSpecifiedByLink,
67
- });
68
- exports.createMDXFormatter = createMDXFormatter;
package/dist/mdbook.d.ts DELETED
@@ -1,20 +0,0 @@
1
- /**
2
- * mdBook formatter for GraphQL documentation output.
3
- *
4
- * Produces Markdown compatible with Rust's mdBook static site generator.
5
- * Front matter is suppressed because mdBook renders it as literal content.
6
- * Admonitions fall back to blockquote style as mdBook has no native support.
7
- *
8
- * @packageDocumentation
9
- */
10
- import type { AdmonitionType, Badge, CollapsibleOption, Formatter, FrontMatterOptions, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
11
- export declare const formatMDXBadge: ({ text }: 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 formatMDXFrontmatter: (_props: Maybe<FrontMatterOptions>, _formatted: Maybe<string[]>) => MDXString;
16
- export declare const formatMDXLink: (link: TypeLink) => TypeLink;
17
- export declare const formatMDXNameEntity: (name: string, parentType?: Maybe<string>) => MDXString;
18
- export declare const formatMDXSpecifiedByLink: (url: string) => MDXString;
19
- export declare const createMDXFormatter: (_meta?: Maybe<MetaInfo>) => Formatter;
20
- //# sourceMappingURL=mdbook.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mdbook.d.ts","sourceRoot":"","sources":["../src/mdbook.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;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;AASjC,eAAO,MAAM,cAAc,aAAc,KAAK,KAAG,SACX,CAAC;AAEvC,eAAO,MAAM,mBAAmB,0BACP,cAAc,SAC9B,KAAK,CAAC,QAAQ,CAAC,KACrB,SAGF,CAAC;AAEF,eAAO,MAAM,eAAe,qBAAgB,SACR,CAAC;AAErC,eAAO,MAAM,gBAAgB,6BAG1B,iBAAiB,KAAG,SAC0L,CAAC;AAGlN,eAAO,MAAM,oBAAoB,WACvB,KAAK,CAAC,kBAAkB,CAAC,cACrB,KAAK,CAAC,MAAM,EAAE,CAAC,KAC1B,SAA4B,CAAC;AAEhC,eAAO,MAAM,aAAa,SAAU,QAAQ,KAAG,QAAgB,CAAC;AAEhE,eAAO,MAAM,mBAAmB,SACxB,MAAM,eACC,KAAK,CAAC,MAAM,CAAC,KACzB,SAGF,CAAC;AAEF,eAAO,MAAM,wBAAwB,QAAS,MAAM,KAAG,SACb,CAAC;AAE3C,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAS3D,CAAC"}
package/dist/mdbook.js DELETED
@@ -1,51 +0,0 @@
1
- "use strict";
2
- /**
3
- * mdBook formatter for GraphQL documentation output.
4
- *
5
- * Produces Markdown compatible with Rust's mdBook static site generator.
6
- * Front matter is suppressed because mdBook renders it as literal content.
7
- * Admonitions fall back to blockquote style as mdBook has no native support.
8
- *
9
- * @packageDocumentation
10
- */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
13
- const utils_1 = require("@graphql-markdown/utils");
14
- const quoteLines = (text) => text
15
- .split(utils_1.MARKDOWN_EOL)
16
- .map((line) => `> ${line}`)
17
- .join(utils_1.MARKDOWN_EOL);
18
- const formatMDXBadge = ({ text }) => `**${text}**`;
19
- exports.formatMDXBadge = formatMDXBadge;
20
- const formatMDXAdmonition = ({ text, title, type }, _meta) => {
21
- const label = (title ?? type).toUpperCase();
22
- return `${utils_1.MARKDOWN_EOP}> **${label}**${utils_1.MARKDOWN_EOL}${quoteLines(text)}${utils_1.MARKDOWN_EOL}`;
23
- };
24
- exports.formatMDXAdmonition = formatMDXAdmonition;
25
- const formatMDXBullet = (text = "") => `&bull;&nbsp;${text}`;
26
- exports.formatMDXBullet = formatMDXBullet;
27
- const formatMDXDetails = ({ dataOpen, dataClose, }) => `${utils_1.MARKDOWN_EOP}<details>${utils_1.MARKDOWN_EOL}<summary>${dataOpen}</summary>${utils_1.MARKDOWN_EOL}${utils_1.MARKDOWN_EOL}\r${utils_1.MARKDOWN_EOL}${utils_1.MARKDOWN_EOL}<em>${dataClose}</em>${utils_1.MARKDOWN_EOL}</details>${utils_1.MARKDOWN_EOP}`;
28
- exports.formatMDXDetails = formatMDXDetails;
29
- // mdBook does not support front matter — rendering it would produce literal --- and YAML as content
30
- const formatMDXFrontmatter = (_props, _formatted) => "";
31
- exports.formatMDXFrontmatter = formatMDXFrontmatter;
32
- const formatMDXLink = (link) => link;
33
- exports.formatMDXLink = formatMDXLink;
34
- const formatMDXNameEntity = (name, parentType) => {
35
- const parentName = parentType ? `${parentType}.` : "";
36
- return `\`${parentName}${name}\``;
37
- };
38
- exports.formatMDXNameEntity = formatMDXNameEntity;
39
- const formatMDXSpecifiedByLink = (url) => `[Specification ⎘](${url})`;
40
- exports.formatMDXSpecifiedByLink = formatMDXSpecifiedByLink;
41
- const createMDXFormatter = (_meta) => ({
42
- formatMDXBadge: exports.formatMDXBadge,
43
- formatMDXAdmonition: exports.formatMDXAdmonition,
44
- formatMDXBullet: exports.formatMDXBullet,
45
- formatMDXDetails: exports.formatMDXDetails,
46
- formatMDXFrontmatter: exports.formatMDXFrontmatter,
47
- formatMDXLink: exports.formatMDXLink,
48
- formatMDXNameEntity: exports.formatMDXNameEntity,
49
- formatMDXSpecifiedByLink: exports.formatMDXSpecifiedByLink,
50
- });
51
- exports.createMDXFormatter = createMDXFormatter;
package/dist/mkdocs.d.ts DELETED
@@ -1,19 +0,0 @@
1
- /**
2
- * MkDocs Material formatter for GraphQL documentation output.
3
- *
4
- * Produces Markdown compatible with MkDocs Material theme admonitions,
5
- * collapsible blocks, and standard YAML front matter.
6
- *
7
- * @packageDocumentation
8
- */
9
- import type { AdmonitionType, Badge, CollapsibleOption, Formatter, FrontMatterOptions, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
10
- export declare const formatMDXBadge: ({ text }: Badge) => MDXString;
11
- export declare const formatMDXAdmonition: ({ text, title, type }: AdmonitionType, _meta: Maybe<MetaInfo>) => MDXString;
12
- export declare const formatMDXBullet: (text?: string) => MDXString;
13
- export declare const formatMDXDetails: ({ dataOpen, dataClose, }: CollapsibleOption) => MDXString;
14
- export declare const formatMDXFrontmatter: (_props: Maybe<FrontMatterOptions>, formatted: Maybe<string[]>) => MDXString;
15
- export declare const formatMDXLink: (link: TypeLink) => TypeLink;
16
- export declare const formatMDXNameEntity: (name: string, parentType?: Maybe<string>) => MDXString;
17
- export declare const formatMDXSpecifiedByLink: (url: string) => MDXString;
18
- export declare const createMDXFormatter: (_meta?: Maybe<MetaInfo>) => Formatter;
19
- //# sourceMappingURL=mkdocs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mkdocs.d.ts","sourceRoot":"","sources":["../src/mkdocs.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;AA0BjC,eAAO,MAAM,cAAc,aAAc,KAAK,KAAG,SACyB,CAAC;AAE3E,eAAO,MAAM,mBAAmB,0BACP,cAAc,SAC9B,KAAK,CAAC,QAAQ,CAAC,KACrB,SAIF,CAAC;AAEF,eAAO,MAAM,eAAe,qBAAgB,SACR,CAAC;AAErC,eAAO,MAAM,gBAAgB,6BAG1B,iBAAiB,KAAG,SACkI,CAAC;AAE1J,eAAO,MAAM,oBAAoB,WACvB,KAAK,CAAC,kBAAkB,CAAC,aACtB,KAAK,CAAC,MAAM,EAAE,CAAC,KACzB,SAKoB,CAAC;AAExB,eAAO,MAAM,aAAa,SAAU,QAAQ,KAAG,QAAgB,CAAC;AAEhE,eAAO,MAAM,mBAAmB,SACxB,MAAM,eACC,KAAK,CAAC,MAAM,CAAC,KACzB,SAGF,CAAC;AAEF,eAAO,MAAM,wBAAwB,QAAS,MAAM,KAAG,SACb,CAAC;AAE3C,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAS3D,CAAC"}
package/dist/mkdocs.js DELETED
@@ -1,65 +0,0 @@
1
- "use strict";
2
- /**
3
- * MkDocs Material formatter for GraphQL documentation output.
4
- *
5
- * Produces Markdown compatible with MkDocs Material theme admonitions,
6
- * collapsible blocks, and standard YAML front matter.
7
- *
8
- * @packageDocumentation
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
12
- const utils_1 = require("@graphql-markdown/utils");
13
- const ADMONITION_TYPE_MAP = {
14
- note: "note",
15
- tip: "tip",
16
- info: "info",
17
- warning: "warning",
18
- danger: "danger",
19
- deprecated: "warning",
20
- caution: "warning",
21
- success: "success",
22
- };
23
- const indentLines = (text, spaces) => {
24
- const indent = " ".repeat(spaces);
25
- return text
26
- .split(utils_1.MARKDOWN_EOL)
27
- .map((line) => (line.trim() ? `${indent}${line}` : ""))
28
- .join(utils_1.MARKDOWN_EOL);
29
- };
30
- const formatMDXBadge = ({ text }) => `<mark class="gqlmd-mkdocs-badge">${text}</mark>`;
31
- exports.formatMDXBadge = formatMDXBadge;
32
- const formatMDXAdmonition = ({ text, title, type }, _meta) => {
33
- const mkdocsType = ADMONITION_TYPE_MAP[type.toLowerCase()] ?? "note";
34
- const titleAttr = title ? ` "${title}"` : "";
35
- return `${utils_1.MARKDOWN_EOP}!!! ${mkdocsType}${titleAttr}${utils_1.MARKDOWN_EOL}${indentLines(text, 4)}${utils_1.MARKDOWN_EOL}`;
36
- };
37
- exports.formatMDXAdmonition = formatMDXAdmonition;
38
- const formatMDXBullet = (text = "") => `&bull;&nbsp;${text}`;
39
- exports.formatMDXBullet = formatMDXBullet;
40
- const formatMDXDetails = ({ dataOpen, dataClose, }) => `${utils_1.MARKDOWN_EOP}??? note "${dataOpen}"${utils_1.MARKDOWN_EOL}${utils_1.MARKDOWN_EOL} \r${utils_1.MARKDOWN_EOL}${utils_1.MARKDOWN_EOL} *${dataClose}*${utils_1.MARKDOWN_EOL}`;
41
- exports.formatMDXDetails = formatMDXDetails;
42
- const formatMDXFrontmatter = (_props, formatted) => formatted
43
- ? [utils_1.FRONT_MATTER_DELIMITER, ...formatted, utils_1.FRONT_MATTER_DELIMITER].join(utils_1.MARKDOWN_EOL)
44
- : "";
45
- exports.formatMDXFrontmatter = formatMDXFrontmatter;
46
- const formatMDXLink = (link) => link;
47
- exports.formatMDXLink = formatMDXLink;
48
- const formatMDXNameEntity = (name, parentType) => {
49
- const parentName = parentType ? `${parentType}.` : "";
50
- return `\`${parentName}${name}\``;
51
- };
52
- exports.formatMDXNameEntity = formatMDXNameEntity;
53
- const formatMDXSpecifiedByLink = (url) => `[Specification ⎘](${url})`;
54
- exports.formatMDXSpecifiedByLink = formatMDXSpecifiedByLink;
55
- const createMDXFormatter = (_meta) => ({
56
- formatMDXBadge: exports.formatMDXBadge,
57
- formatMDXAdmonition: exports.formatMDXAdmonition,
58
- formatMDXBullet: exports.formatMDXBullet,
59
- formatMDXDetails: exports.formatMDXDetails,
60
- formatMDXFrontmatter: exports.formatMDXFrontmatter,
61
- formatMDXLink: exports.formatMDXLink,
62
- formatMDXNameEntity: exports.formatMDXNameEntity,
63
- formatMDXSpecifiedByLink: exports.formatMDXSpecifiedByLink,
64
- });
65
- exports.createMDXFormatter = createMDXFormatter;