@graphql-markdown/printer-legacy 1.10.0 → 1.12.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.
- package/dist/badge.d.ts +6 -2
- package/dist/badge.js +21 -13
- package/dist/common.d.ts +6 -3
- package/dist/common.js +4 -9
- package/dist/const/options.d.ts +1 -3
- package/dist/const/options.js +6 -3
- package/dist/const/strings.d.ts +1 -3
- package/dist/const/strings.js +2 -4
- package/dist/directive.js +3 -3
- package/dist/frontmatter.d.ts +2 -3
- package/dist/frontmatter.js +6 -59
- package/dist/graphql/scalar.d.ts +2 -2
- package/dist/graphql/scalar.js +3 -3
- package/dist/link.js +10 -8
- package/dist/mdx/index.d.ts +5 -0
- package/dist/mdx/index.js +64 -0
- package/dist/printer.d.ts +4 -3
- package/dist/printer.js +15 -7
- package/dist/relation.js +4 -4
- package/dist/section.d.ts +1 -2
- package/dist/section.js +12 -29
- package/package.json +4 -4
- package/dist/const/mdx.d.ts +0 -2
- package/dist/const/mdx.js +0 -32
package/dist/badge.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { Badge, MDXString, Maybe, PrintTypeOptions, SchemaEntitiesGroupMap } from "@graphql-markdown/types";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const CSS_BADGE_CLASSNAME: {
|
|
3
|
+
DEPRECATED: string;
|
|
4
|
+
RELATION: string;
|
|
5
|
+
NON_NULL: string;
|
|
6
|
+
};
|
|
3
7
|
export declare const getTypeBadges: (type: unknown, groups?: Maybe<SchemaEntitiesGroupMap>) => Badge[];
|
|
4
|
-
export declare const printBadge: ({ text, classname }: Badge) => MDXString;
|
|
8
|
+
export declare const printBadge: ({ text, classname }: Badge, options: PrintTypeOptions) => MDXString;
|
|
5
9
|
export declare const printBadges: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
package/dist/badge.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printBadges = exports.printBadge = exports.getTypeBadges = exports.
|
|
3
|
+
exports.printBadges = exports.printBadge = exports.getTypeBadges = exports.CSS_BADGE_CLASSNAME = void 0;
|
|
4
4
|
const utils_1 = require("@graphql-markdown/utils");
|
|
5
5
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
6
6
|
const link_1 = require("./link");
|
|
7
7
|
const group_1 = require("./group");
|
|
8
|
-
|
|
8
|
+
const strings_1 = require("./const/strings");
|
|
9
|
+
exports.CSS_BADGE_CLASSNAME = {
|
|
10
|
+
DEPRECATED: "DEPRECATED",
|
|
11
|
+
RELATION: "RELATION",
|
|
12
|
+
NON_NULL: "NON_NULL",
|
|
13
|
+
};
|
|
9
14
|
const getTypeBadges = (type, groups) => {
|
|
10
15
|
const badges = [];
|
|
11
16
|
if (typeof type !== "object" || type === null) {
|
|
@@ -14,37 +19,40 @@ const getTypeBadges = (type, groups) => {
|
|
|
14
19
|
const rootType = ("type" in type ? type.type : type);
|
|
15
20
|
if ((0, graphql_1.isDeprecated)(type)) {
|
|
16
21
|
badges.push({
|
|
17
|
-
text:
|
|
18
|
-
classname:
|
|
22
|
+
text: strings_1.DEPRECATED,
|
|
23
|
+
classname: exports.CSS_BADGE_CLASSNAME.DEPRECATED,
|
|
19
24
|
});
|
|
20
25
|
}
|
|
21
26
|
if ((0, graphql_1.isNonNullType)(rootType)) {
|
|
22
27
|
badges.push({
|
|
23
|
-
text:
|
|
24
|
-
classname: exports.
|
|
28
|
+
text: strings_1.NON_NULL,
|
|
29
|
+
classname: exports.CSS_BADGE_CLASSNAME.NON_NULL,
|
|
25
30
|
});
|
|
26
31
|
}
|
|
27
32
|
if ((0, graphql_1.isListType)(rootType)) {
|
|
28
|
-
badges.push({ text: "list"
|
|
33
|
+
badges.push({ text: "list" });
|
|
29
34
|
}
|
|
30
35
|
const category = (0, link_1.getCategoryLocale)((0, graphql_1.getNamedType)(rootType));
|
|
31
36
|
if (category) {
|
|
32
|
-
badges.push({ text: category
|
|
37
|
+
badges.push({ text: category });
|
|
33
38
|
}
|
|
34
39
|
if (groups) {
|
|
35
40
|
const typeCategory = (typeof category === "string" ? category : category?.plural);
|
|
36
41
|
const group = (0, group_1.getGroup)(rootType, groups, typeCategory);
|
|
37
42
|
if (group && group !== "") {
|
|
38
|
-
badges.push({ text: group
|
|
43
|
+
badges.push({ text: group });
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
return badges;
|
|
42
47
|
};
|
|
43
48
|
exports.getTypeBadges = getTypeBadges;
|
|
44
|
-
const printBadge = ({ text, classname }) => {
|
|
45
|
-
const textString = typeof text === "object" ? text.singular : text
|
|
49
|
+
const printBadge = ({ text, classname }, options) => {
|
|
50
|
+
const textString = typeof text === "object" ? text.singular : text;
|
|
46
51
|
const formattedText = (0, utils_1.escapeMDX)(textString);
|
|
47
|
-
return
|
|
52
|
+
return options.formatMDXBadge({
|
|
53
|
+
text: formattedText,
|
|
54
|
+
classname,
|
|
55
|
+
});
|
|
48
56
|
};
|
|
49
57
|
exports.printBadge = printBadge;
|
|
50
58
|
const printBadges = (type, options) => {
|
|
@@ -59,7 +67,7 @@ const printBadges = (type, options) => {
|
|
|
59
67
|
}
|
|
60
68
|
return badges
|
|
61
69
|
.map((badge) => {
|
|
62
|
-
return (0, exports.printBadge)(badge);
|
|
70
|
+
return (0, exports.printBadge)(badge, options);
|
|
63
71
|
})
|
|
64
72
|
.join(" ");
|
|
65
73
|
};
|
package/dist/common.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Maybe, MDXString, PrintTypeOptions } from "@graphql-markdown/types";
|
|
2
2
|
export declare const printCustomDirectives: (type: unknown, options?: PrintTypeOptions) => string;
|
|
3
3
|
export declare const formatDescription: (type: unknown, replacement?: Maybe<string>) => MDXString | string;
|
|
4
|
-
export declare const printWarning: (text
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare const printWarning: ({ text, title }: {
|
|
5
|
+
text?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
}, options: PrintTypeOptions) => string;
|
|
8
|
+
export declare const printDeprecation: (type: unknown, options: PrintTypeOptions) => string;
|
|
9
|
+
export declare const printDescription: (type: unknown, options: PrintTypeOptions, noText?: string) => MDXString | string;
|
package/dist/common.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.printDescription = exports.printDeprecation = exports.printWarning = exports.formatDescription = exports.printCustomDirectives = void 0;
|
|
4
4
|
const utils_1 = require("@graphql-markdown/utils");
|
|
5
5
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
6
|
-
const directive_1 = require("./directive");
|
|
7
6
|
const strings_1 = require("./const/strings");
|
|
7
|
+
const directive_1 = require("./directive");
|
|
8
8
|
const printCustomDirectives = (type, options) => {
|
|
9
9
|
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options?.customDirectives);
|
|
10
10
|
if ((0, utils_1.isEmpty)(constDirectiveMap)) {
|
|
@@ -34,16 +34,11 @@ const formatDescription = (type, replacement = strings_1.NO_DESCRIPTION_TEXT) =>
|
|
|
34
34
|
return `${strings_1.MARKDOWN_EOP}${(0, utils_1.escapeMDX)(description)}`;
|
|
35
35
|
};
|
|
36
36
|
exports.formatDescription = formatDescription;
|
|
37
|
-
const printWarning = (text, title, options) => {
|
|
37
|
+
const printWarning = ({ text, title }, options) => {
|
|
38
38
|
const formattedText = typeof text !== "string" || text.trim() === ""
|
|
39
39
|
? strings_1.MARKDOWN_EOP
|
|
40
40
|
: `${strings_1.MARKDOWN_EOP}${text}${strings_1.MARKDOWN_EOP}`;
|
|
41
|
-
|
|
42
|
-
if (isDocusaurus &&
|
|
43
|
-
options.meta?.generatorFrameworkVersion?.startsWith("2")) {
|
|
44
|
-
return `${strings_1.MARKDOWN_EOP}:::caution ${title}${formattedText}:::`;
|
|
45
|
-
}
|
|
46
|
-
return `${strings_1.MARKDOWN_EOP}:::warning[${title}]${formattedText}:::`;
|
|
41
|
+
return options.formatMDXAdmonition({ text: formattedText, type: "warning", icon: "⚠️", title }, options.meta);
|
|
47
42
|
};
|
|
48
43
|
exports.printWarning = printWarning;
|
|
49
44
|
const printDeprecation = (type, options) => {
|
|
@@ -53,7 +48,7 @@ const printDeprecation = (type, options) => {
|
|
|
53
48
|
const reason = "deprecationReason" in type && typeof type.deprecationReason === "string"
|
|
54
49
|
? (0, utils_1.escapeMDX)(type.deprecationReason)
|
|
55
50
|
: "";
|
|
56
|
-
return (0, exports.printWarning)(reason, strings_1.DEPRECATED.toUpperCase(), options);
|
|
51
|
+
return (0, exports.printWarning)({ text: reason, title: strings_1.DEPRECATED.toUpperCase() }, options);
|
|
57
52
|
};
|
|
58
53
|
exports.printDeprecation = printDeprecation;
|
|
59
54
|
const printDescription = (type, options, noText) => {
|
package/dist/const/options.d.ts
CHANGED
|
@@ -6,9 +6,7 @@ export declare enum TypeHierarchy {
|
|
|
6
6
|
}
|
|
7
7
|
export declare enum SectionLevels {
|
|
8
8
|
NONE = "",
|
|
9
|
-
|
|
10
|
-
LEVEL_4 = "####",
|
|
11
|
-
LEVEL_5 = "#####"
|
|
9
|
+
LEVEL = "#"
|
|
12
10
|
}
|
|
13
11
|
export declare const PRINT_TYPE_DEFAULT_OPTIONS: Required<PrinterConfigPrintTypeOptions>;
|
|
14
12
|
export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "groups" | "level" | "meta" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
|
package/dist/const/options.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.DEFAULT_OPTIONS = exports.PRINT_TYPE_DEFAULT_OPTIONS = exports.SectionLevels = exports.TypeHierarchy = void 0;
|
|
7
|
+
const mdx_1 = __importDefault(require("../mdx"));
|
|
4
8
|
var TypeHierarchy;
|
|
5
9
|
(function (TypeHierarchy) {
|
|
6
10
|
TypeHierarchy["API"] = "api";
|
|
@@ -10,9 +14,7 @@ var TypeHierarchy;
|
|
|
10
14
|
var SectionLevels;
|
|
11
15
|
(function (SectionLevels) {
|
|
12
16
|
SectionLevels["NONE"] = "";
|
|
13
|
-
SectionLevels["
|
|
14
|
-
SectionLevels["LEVEL_4"] = "####";
|
|
15
|
-
SectionLevels["LEVEL_5"] = "#####";
|
|
17
|
+
SectionLevels["LEVEL"] = "#";
|
|
16
18
|
})(SectionLevels || (exports.SectionLevels = SectionLevels = {}));
|
|
17
19
|
exports.PRINT_TYPE_DEFAULT_OPTIONS = {
|
|
18
20
|
codeSection: true,
|
|
@@ -38,4 +40,5 @@ exports.DEFAULT_OPTIONS = {
|
|
|
38
40
|
schema: undefined,
|
|
39
41
|
skipDocDirectives: [],
|
|
40
42
|
withAttributes: false,
|
|
43
|
+
...mdx_1.default,
|
|
41
44
|
};
|
package/dist/const/strings.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RootTypeLocale } from "@graphql-markdown/types";
|
|
2
2
|
export declare const ROOT_TYPE_LOCALE: RootTypeLocale;
|
|
3
|
-
export declare const LINK_MDX_EXTENSION: ".mdx";
|
|
4
3
|
export declare const DEPRECATED: "deprecated";
|
|
4
|
+
export declare const NON_NULL: "non-null";
|
|
5
5
|
export declare const GRAPHQL: "graphql";
|
|
6
6
|
export declare const NO_DESCRIPTION_TEXT: "No description";
|
|
7
7
|
export declare const MARKDOWN_CODE_SNIPPET: "```";
|
|
@@ -11,5 +11,3 @@ export declare const MARKDOWN_EOL: "\n";
|
|
|
11
11
|
export declare const MARKDOWN_EOP: string;
|
|
12
12
|
export declare const MARKDOWN_EOC: "\n```\n";
|
|
13
13
|
export declare const MARKDOWN_SOC: "\n```graphql\n";
|
|
14
|
-
export declare const HIDE_DEPRECATED: "<><span className=\"deprecated\">Hide deprecated</span></>";
|
|
15
|
-
export declare const SHOW_DEPRECATED: "<><span className=\"deprecated\">Show deprecated</span></>";
|
package/dist/const/strings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MARKDOWN_SOC = exports.MARKDOWN_EOC = exports.MARKDOWN_EOP = exports.MARKDOWN_EOL = exports.MARKDOWN_CODE_INDENTATION = exports.FRONT_MATTER_DELIMITER = exports.MARKDOWN_CODE_SNIPPET = exports.NO_DESCRIPTION_TEXT = exports.GRAPHQL = exports.NON_NULL = exports.DEPRECATED = exports.ROOT_TYPE_LOCALE = void 0;
|
|
4
4
|
exports.ROOT_TYPE_LOCALE = {
|
|
5
5
|
DIRECTIVE: { singular: "directive", plural: "directives" },
|
|
6
6
|
ENUM: { singular: "enum", plural: "enums" },
|
|
@@ -14,8 +14,8 @@ exports.ROOT_TYPE_LOCALE = {
|
|
|
14
14
|
TYPE: { singular: "object", plural: "objects" },
|
|
15
15
|
UNION: { singular: "union", plural: "unions" },
|
|
16
16
|
};
|
|
17
|
-
exports.LINK_MDX_EXTENSION = ".mdx";
|
|
18
17
|
exports.DEPRECATED = "deprecated";
|
|
18
|
+
exports.NON_NULL = "non-null";
|
|
19
19
|
exports.GRAPHQL = "graphql";
|
|
20
20
|
exports.NO_DESCRIPTION_TEXT = "No description";
|
|
21
21
|
exports.MARKDOWN_CODE_SNIPPET = "```";
|
|
@@ -25,5 +25,3 @@ exports.MARKDOWN_EOL = "\n";
|
|
|
25
25
|
exports.MARKDOWN_EOP = `${exports.MARKDOWN_EOL.repeat(2)}`;
|
|
26
26
|
exports.MARKDOWN_EOC = `${exports.MARKDOWN_EOL}${exports.MARKDOWN_CODE_SNIPPET}${exports.MARKDOWN_EOL}`;
|
|
27
27
|
exports.MARKDOWN_SOC = `${exports.MARKDOWN_EOL}${exports.MARKDOWN_CODE_SNIPPET}${exports.GRAPHQL}${exports.MARKDOWN_EOL}`;
|
|
28
|
-
exports.HIDE_DEPRECATED = `<><span className="${exports.DEPRECATED}">Hide ${exports.DEPRECATED}</span></>`;
|
|
29
|
-
exports.SHOW_DEPRECATED = `<><span className="${exports.DEPRECATED}">Show ${exports.DEPRECATED}</span></>`;
|
package/dist/directive.js
CHANGED
|
@@ -24,7 +24,7 @@ const printCustomDirective = (type, constDirectiveOption, options) => {
|
|
|
24
24
|
if (typeof description !== "string") {
|
|
25
25
|
return undefined;
|
|
26
26
|
}
|
|
27
|
-
return `${options_1.SectionLevels.
|
|
27
|
+
return `${options_1.SectionLevels.LEVEL.repeat(4)} ${typeNameLink}${strings_1.MARKDOWN_EOL} ${description}${strings_1.MARKDOWN_EOL} `;
|
|
28
28
|
};
|
|
29
29
|
exports.printCustomDirective = printCustomDirective;
|
|
30
30
|
const printCustomDirectives = (type, options) => {
|
|
@@ -43,7 +43,7 @@ const printCustomDirectives = (type, options) => {
|
|
|
43
43
|
return "";
|
|
44
44
|
}
|
|
45
45
|
const content = directives.join(strings_1.MARKDOWN_EOP);
|
|
46
|
-
return `${options_1.SectionLevels.
|
|
46
|
+
return `${options_1.SectionLevels.LEVEL.repeat(3)} Directives${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
|
|
47
47
|
};
|
|
48
48
|
exports.printCustomDirectives = printCustomDirectives;
|
|
49
49
|
const getCustomTags = (type, options) => {
|
|
@@ -69,7 +69,7 @@ const printCustomTags = (type, options) => {
|
|
|
69
69
|
}
|
|
70
70
|
return badges
|
|
71
71
|
.map((badge) => {
|
|
72
|
-
return (0, badge_1.printBadge)(badge);
|
|
72
|
+
return (0, badge_1.printBadge)(badge, options);
|
|
73
73
|
})
|
|
74
74
|
.join(" ");
|
|
75
75
|
};
|
package/dist/frontmatter.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { FrontMatterOptions, Maybe } from "@graphql-markdown/types";
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const printFrontMatter: (id: string, title: string, props?: Maybe<FrontMatterOptions>) => string;
|
|
1
|
+
import type { FrontMatterOptions, Maybe, PrintTypeOptions } from "@graphql-markdown/types";
|
|
2
|
+
export declare const printFrontMatter: (title: string, props: Maybe<FrontMatterOptions>, options: PrintTypeOptions) => string;
|
package/dist/frontmatter.js
CHANGED
|
@@ -1,65 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printFrontMatter =
|
|
3
|
+
exports.printFrontMatter = void 0;
|
|
4
4
|
const utils_1 = require("@graphql-markdown/utils");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const formatFrontMatterObject = (props, indentation = 0, prefix) => {
|
|
10
|
-
const frontMatter = [];
|
|
11
|
-
if (!props || typeof props !== "object") {
|
|
12
|
-
return frontMatter;
|
|
13
|
-
}
|
|
14
|
-
for (const [key, value] of Object.entries(props)) {
|
|
15
|
-
frontMatter.push(
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
17
|
-
...(0, exports.formatFrontMatterProp)({ [key]: value }, indentation + 1, prefix));
|
|
18
|
-
prefix = " ".repeat(prefix?.length ?? 0);
|
|
19
|
-
}
|
|
20
|
-
return frontMatter;
|
|
21
|
-
};
|
|
22
|
-
const formatFrontMatterList = (prop, indentation = 0, prefix = "- ") => {
|
|
23
|
-
const frontMatter = [];
|
|
24
|
-
if (!Array.isArray(prop)) {
|
|
25
|
-
return frontMatter;
|
|
5
|
+
const printFrontMatter = (title, props, options) => {
|
|
6
|
+
const frontMatter = (0, utils_1.formatFrontMatterObject)({ ...props, title }, -1);
|
|
7
|
+
if (!options.formatMDXFrontmatter) {
|
|
8
|
+
return "";
|
|
26
9
|
}
|
|
27
|
-
|
|
28
|
-
if (typeof entry === "object") {
|
|
29
|
-
frontMatter.push(...formatFrontMatterObject(entry, -1, prefix).map((item) => {
|
|
30
|
-
return `${tabs(indentation)}${item}`;
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
frontMatter.push(`${tabs(indentation)}- ${(0, utils_1.toString)(entry)}`);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return frontMatter;
|
|
38
|
-
};
|
|
39
|
-
const formatFrontMatterProp = (prop, indentation = 0, prefix) => {
|
|
40
|
-
if (typeof prop === "undefined" || prop === null) {
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
const tabs = strings_1.MARKDOWN_CODE_INDENTATION.repeat(indentation);
|
|
44
|
-
const [key, value] = Object.entries(prop)[0];
|
|
45
|
-
const index = `${tabs}${prefix ?? ""}${key}:`;
|
|
46
|
-
switch (true) {
|
|
47
|
-
case typeof value !== "string" && Array.isArray(value):
|
|
48
|
-
return [index, ...formatFrontMatterList(value, indentation + 1, prefix)];
|
|
49
|
-
case typeof value === "object" && value !== null:
|
|
50
|
-
return [index, ...formatFrontMatterObject(value, indentation, prefix)];
|
|
51
|
-
default:
|
|
52
|
-
return [`${index} ${value}`];
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
exports.formatFrontMatterProp = formatFrontMatterProp;
|
|
56
|
-
const printFrontMatter = (id, title, props) => {
|
|
57
|
-
const frontMatter = formatFrontMatterObject({ ...props, id, title }, -1);
|
|
58
|
-
const header = [
|
|
59
|
-
strings_1.FRONT_MATTER_DELIMITER,
|
|
60
|
-
...frontMatter,
|
|
61
|
-
strings_1.FRONT_MATTER_DELIMITER,
|
|
62
|
-
];
|
|
63
|
-
return header.join(strings_1.MARKDOWN_EOL);
|
|
10
|
+
return options.formatMDXFrontmatter(props, frontMatter);
|
|
64
11
|
};
|
|
65
12
|
exports.printFrontMatter = printFrontMatter;
|
package/dist/graphql/scalar.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PrintTypeOptions, MDXString } from "@graphql-markdown/types";
|
|
2
|
-
export declare const printSpecification: (type: unknown) => MDXString | string;
|
|
3
|
-
export declare const printScalarMetadata: (type: unknown, options
|
|
2
|
+
export declare const printSpecification: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
3
|
+
export declare const printScalarMetadata: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
4
4
|
export declare const printCodeScalar: (type: unknown, options?: PrintTypeOptions) => string;
|
package/dist/graphql/scalar.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.printCodeScalar = exports.printScalarMetadata = exports.printSpecificati
|
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const strings_1 = require("../const/strings");
|
|
6
6
|
const options_1 = require("../const/options");
|
|
7
|
-
const printSpecification = (type) => {
|
|
7
|
+
const printSpecification = (type, options) => {
|
|
8
8
|
if (typeof type !== "object" ||
|
|
9
9
|
type === null ||
|
|
10
10
|
!("specifiedByURL" in type) ||
|
|
@@ -13,11 +13,11 @@ const printSpecification = (type) => {
|
|
|
13
13
|
}
|
|
14
14
|
const url = type.specifiedByURL;
|
|
15
15
|
// Needs newline between "export const specifiedByLinkCss" and markdown header to prevent compilation error in docusaurus
|
|
16
|
-
return `${options_1.SectionLevels.
|
|
16
|
+
return `${options_1.SectionLevels.LEVEL.repeat(3)} ${options.formatMDXSpecifiedByLink(url)}${strings_1.MARKDOWN_EOP}`;
|
|
17
17
|
};
|
|
18
18
|
exports.printSpecification = printSpecification;
|
|
19
19
|
const printScalarMetadata = (type, options) => {
|
|
20
|
-
return (0, exports.printSpecification)(type);
|
|
20
|
+
return (0, exports.printSpecification)(type, options);
|
|
21
21
|
};
|
|
22
22
|
exports.printScalarMetadata = printScalarMetadata;
|
|
23
23
|
const printCodeScalar = (type, options) => {
|
package/dist/link.js
CHANGED
|
@@ -129,11 +129,15 @@ const toLink = (type, name, operation, options) => {
|
|
|
129
129
|
: "";
|
|
130
130
|
}
|
|
131
131
|
const text = graphQLNamedType.name || graphQLNamedType.toString();
|
|
132
|
-
const url = utils_1.pathUrl.join(options.basePath, deprecatedFolder, apiGroupFolder, groupFolder, category, `${(0, utils_1.slugify)(text)}
|
|
133
|
-
|
|
132
|
+
const url = utils_1.pathUrl.join(options.basePath, deprecatedFolder, apiGroupFolder, groupFolder, category, `${(0, utils_1.slugify)(text)}`);
|
|
133
|
+
const link = {
|
|
134
134
|
text,
|
|
135
135
|
url,
|
|
136
136
|
};
|
|
137
|
+
if (options.formatMDXLink) {
|
|
138
|
+
return options.formatMDXLink(link);
|
|
139
|
+
}
|
|
140
|
+
return link;
|
|
137
141
|
};
|
|
138
142
|
exports.toLink = toLink;
|
|
139
143
|
const getRelationLink = (category, type, options) => {
|
|
@@ -170,22 +174,20 @@ const printLink = (type, options) => {
|
|
|
170
174
|
}
|
|
171
175
|
const link = (0, exports.toLink)(type, (0, graphql_1.getTypeName)(type, (0, utils_1.toString)(type)), undefined, options);
|
|
172
176
|
if (typeof options !== "undefined" && !(0, exports.hasOptionWithAttributes)(options)) {
|
|
173
|
-
const textWithAttribute = (
|
|
174
|
-
? `<code style={{ fontWeight: 'normal' }}>${options.parentType}.<b>${link.text}</b></code>`
|
|
175
|
-
: `\`${link.text}\``;
|
|
177
|
+
const textWithAttribute = options.formatMDXNameEntity(link.text, options.parentType);
|
|
176
178
|
return `[${textWithAttribute}](${link.url})`;
|
|
177
179
|
}
|
|
178
180
|
const text = (0, exports.printLinkAttributes)(type, link.text);
|
|
179
|
-
return `[
|
|
181
|
+
return `[${options.formatMDXNameEntity(text)}](${link.url})`;
|
|
180
182
|
};
|
|
181
183
|
exports.printLink = printLink;
|
|
182
184
|
const printParentLink = (type, options) => {
|
|
183
185
|
if (typeof type !== "object" || type === null || !("type" in type)) {
|
|
184
186
|
return "";
|
|
185
187
|
}
|
|
186
|
-
return
|
|
188
|
+
return options.formatMDXBullet((0, exports.printLink)(type.type, {
|
|
187
189
|
...options,
|
|
188
190
|
withAttributes: true,
|
|
189
|
-
})
|
|
191
|
+
}));
|
|
190
192
|
};
|
|
191
193
|
exports.printParentLink = printParentLink;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MDXSupportType } from "@graphql-markdown/types";
|
|
2
|
+
export declare const mdxDeclaration = "";
|
|
3
|
+
declare const defaultModule: MDXSupportType;
|
|
4
|
+
export declare const mdxModule: (mdxPackage?: Record<string, unknown>) => Promise<Readonly<MDXSupportType>>;
|
|
5
|
+
export default defaultModule;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mdxModule = exports.mdxDeclaration = void 0;
|
|
4
|
+
const strings_1 = require("../const/strings");
|
|
5
|
+
const formatMDXBadge = (badge) => {
|
|
6
|
+
return `<mark class="gqlmd-mdx-badge">${badge.text}</mark>`;
|
|
7
|
+
};
|
|
8
|
+
const formatMDXAdmonition = ({ text, title, type, icon }, _meta) => {
|
|
9
|
+
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>`;
|
|
10
|
+
};
|
|
11
|
+
const formatMDXBullet = (text = "") => {
|
|
12
|
+
return `<span class="gqlmd-mdx-bullet"> ● </span>${text}`;
|
|
13
|
+
};
|
|
14
|
+
const formatMDXDetails = ({ dataOpen }) => {
|
|
15
|
+
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}`;
|
|
16
|
+
};
|
|
17
|
+
const formatMDXSpecifiedByLink = (url) => {
|
|
18
|
+
return `<span class="gqlmd-mdx-specifiedby">Specification<a class="gqlmd-mdx-specifiedby-link" target="_blank" href="${url}" title="Specified by ${url}">⎘</a></span>`;
|
|
19
|
+
};
|
|
20
|
+
const formatMDXNameEntity = (name, parentType) => {
|
|
21
|
+
const parentName = parentType
|
|
22
|
+
? `<code class="gqlmd-mdx-entity-parent">${parentType}</code>.`
|
|
23
|
+
: "";
|
|
24
|
+
return `<span class="gqlmd-mdx-entity">${parentName}<code class="gqlmd-mdx-entity-name">${name}</code></span>`;
|
|
25
|
+
};
|
|
26
|
+
const formatMDXLink = (link) => {
|
|
27
|
+
return link;
|
|
28
|
+
};
|
|
29
|
+
const formatMDXFrontmatter = (_props, formatted) => {
|
|
30
|
+
return formatted
|
|
31
|
+
? [strings_1.FRONT_MATTER_DELIMITER, ...formatted, strings_1.FRONT_MATTER_DELIMITER].join(strings_1.MARKDOWN_EOL)
|
|
32
|
+
: "";
|
|
33
|
+
};
|
|
34
|
+
exports.mdxDeclaration = "";
|
|
35
|
+
const defaultModule = {
|
|
36
|
+
formatMDXAdmonition,
|
|
37
|
+
formatMDXBadge,
|
|
38
|
+
formatMDXBullet,
|
|
39
|
+
formatMDXDetails,
|
|
40
|
+
formatMDXFrontmatter,
|
|
41
|
+
formatMDXLink,
|
|
42
|
+
formatMDXNameEntity,
|
|
43
|
+
formatMDXSpecifiedByLink,
|
|
44
|
+
mdxDeclaration: exports.mdxDeclaration,
|
|
45
|
+
};
|
|
46
|
+
const mdxModule = async (mdxPackage) => {
|
|
47
|
+
if (!mdxPackage) {
|
|
48
|
+
return defaultModule;
|
|
49
|
+
}
|
|
50
|
+
const module = (mdxPackage.default ?? mdxPackage);
|
|
51
|
+
return {
|
|
52
|
+
formatMDXAdmonition: module.formatMDXAdmonition ?? formatMDXAdmonition,
|
|
53
|
+
formatMDXBadge: module.formatMDXBadge ?? formatMDXBadge,
|
|
54
|
+
formatMDXBullet: module.formatMDXBullet ?? formatMDXBullet,
|
|
55
|
+
formatMDXDetails: module.formatMDXDetails ?? formatMDXDetails,
|
|
56
|
+
formatMDXFrontmatter: module.formatMDXFrontmatter ?? formatMDXFrontmatter,
|
|
57
|
+
formatMDXLink: module.formatMDXLink ?? formatMDXLink,
|
|
58
|
+
formatMDXNameEntity: module.formatMDXNameEntity ?? formatMDXNameEntity,
|
|
59
|
+
formatMDXSpecifiedByLink: module.formatMDXSpecifiedByLink ?? formatMDXSpecifiedByLink,
|
|
60
|
+
mdxDeclaration: module.mdxDeclaration ?? exports.mdxDeclaration,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
exports.mdxModule = mdxModule;
|
|
64
|
+
exports.default = defaultModule;
|
package/dist/printer.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { CustomDirectiveMap, GraphQLDirective, GraphQLSchema, IPrinter, MDXString, Maybe, MetaOptions, PrintTypeOptions, PrinterConfigPrintTypeOptions, SchemaEntitiesGroupMap, TypeDeprecatedOption } from "@graphql-markdown/types";
|
|
1
|
+
import type { CustomDirectiveMap, GraphQLDirective, GraphQLSchema, IPrinter, MDXString, MDXSupportType, Maybe, MetaOptions, PrintTypeOptions, PrinterConfigPrintTypeOptions, SchemaEntitiesGroupMap, TypeDeprecatedOption } from "@graphql-markdown/types";
|
|
2
2
|
export declare class Printer implements IPrinter {
|
|
3
3
|
static options: Readonly<Maybe<PrintTypeOptions>>;
|
|
4
|
-
static readonly printDescription: (type: unknown, options
|
|
4
|
+
static readonly printDescription: (type: unknown, options: PrintTypeOptions, noText?: string) => MDXString | string;
|
|
5
5
|
static readonly printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
|
|
6
6
|
static readonly printCustomTags: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
7
|
+
static printMDXModule: Readonly<MDXSupportType>;
|
|
7
8
|
static init(schema: Maybe<GraphQLSchema>, baseURL?: Maybe<string>, linkRoot?: Maybe<string>, { customDirectives, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, }?: {
|
|
8
9
|
customDirectives?: CustomDirectiveMap;
|
|
9
10
|
deprecated?: TypeDeprecatedOption;
|
|
@@ -13,7 +14,7 @@ export declare class Printer implements IPrinter {
|
|
|
13
14
|
onlyDocDirectives?: GraphQLDirective[];
|
|
14
15
|
printTypeOptions?: PrinterConfigPrintTypeOptions;
|
|
15
16
|
skipDocDirectives?: GraphQLDirective[];
|
|
16
|
-
}): void
|
|
17
|
+
}, mdxParser?: Record<string, unknown>): Promise<void>;
|
|
17
18
|
static readonly printHeader: (id: string, title: string, options: PrintTypeOptions) => string;
|
|
18
19
|
static readonly printCode: (type: unknown, options: PrintTypeOptions) => string;
|
|
19
20
|
static readonly printExample: (type: unknown, options: PrintTypeOptions) => string;
|
package/dist/printer.js
CHANGED
|
@@ -10,7 +10,7 @@ const frontmatter_1 = require("./frontmatter");
|
|
|
10
10
|
const graphql_2 = require("./graphql");
|
|
11
11
|
const link_1 = require("./link");
|
|
12
12
|
const strings_1 = require("./const/strings");
|
|
13
|
-
const mdx_1 = require("./
|
|
13
|
+
const mdx_1 = require("./mdx");
|
|
14
14
|
const options_1 = require("./const/options");
|
|
15
15
|
const example_1 = require("./example");
|
|
16
16
|
class Printer {
|
|
@@ -18,10 +18,11 @@ class Printer {
|
|
|
18
18
|
static printDescription = common_1.printDescription;
|
|
19
19
|
static printCustomDirectives = directive_1.printCustomDirectives;
|
|
20
20
|
static printCustomTags = directive_1.printCustomTags;
|
|
21
|
-
static
|
|
21
|
+
static printMDXModule;
|
|
22
|
+
static async init(schema, baseURL = "schema", linkRoot = "/", { customDirectives, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, } = {
|
|
22
23
|
customDirectives: undefined,
|
|
23
24
|
groups: undefined,
|
|
24
|
-
}) {
|
|
25
|
+
}, mdxParser) {
|
|
25
26
|
if (typeof Printer.options !== "undefined") {
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
@@ -46,10 +47,14 @@ class Printer {
|
|
|
46
47
|
hierarchy: printTypeOptions?.hierarchy ?? options_1.PRINT_TYPE_DEFAULT_OPTIONS.hierarchy,
|
|
47
48
|
meta: meta,
|
|
48
49
|
};
|
|
50
|
+
Printer.printMDXModule = await (0, mdx_1.mdxModule)(mdxParser);
|
|
49
51
|
}
|
|
50
52
|
static printHeader = (id, title, options) => {
|
|
53
|
+
if (options.frontMatter === false) {
|
|
54
|
+
return `# ${title}${strings_1.MARKDOWN_EOP}`;
|
|
55
|
+
}
|
|
51
56
|
const fmOptions = options.frontMatter ?? options_1.DEFAULT_OPTIONS.frontMatter;
|
|
52
|
-
return (0, frontmatter_1.printFrontMatter)(
|
|
57
|
+
return (0, frontmatter_1.printFrontMatter)(title, { ...fmOptions, id }, options);
|
|
53
58
|
};
|
|
54
59
|
static printCode = (type, options) => {
|
|
55
60
|
let code = "";
|
|
@@ -97,7 +102,7 @@ class Printer {
|
|
|
97
102
|
if (!example) {
|
|
98
103
|
return "";
|
|
99
104
|
}
|
|
100
|
-
return `${options_1.SectionLevels.
|
|
105
|
+
return `${options_1.SectionLevels.LEVEL.repeat(3)} Example${strings_1.MARKDOWN_EOP}${strings_1.MARKDOWN_SOC}${example}${strings_1.MARKDOWN_EOC}${strings_1.MARKDOWN_EOP}`;
|
|
101
106
|
};
|
|
102
107
|
static printTypeMetadata = (type, options) => {
|
|
103
108
|
switch (true) {
|
|
@@ -144,6 +149,7 @@ class Printer {
|
|
|
144
149
|
...options_1.DEFAULT_OPTIONS,
|
|
145
150
|
...Printer.options,
|
|
146
151
|
...options,
|
|
152
|
+
...Printer.printMDXModule,
|
|
147
153
|
};
|
|
148
154
|
if (!name || !(0, link_1.hasPrintableDirective)(type, printTypeOptions)) {
|
|
149
155
|
return undefined;
|
|
@@ -160,7 +166,7 @@ class Printer {
|
|
|
160
166
|
return [
|
|
161
167
|
header,
|
|
162
168
|
metatags,
|
|
163
|
-
|
|
169
|
+
Printer.printMDXModule.mdxDeclaration,
|
|
164
170
|
tags,
|
|
165
171
|
description,
|
|
166
172
|
code,
|
|
@@ -168,7 +174,9 @@ class Printer {
|
|
|
168
174
|
metadata,
|
|
169
175
|
example,
|
|
170
176
|
relations,
|
|
171
|
-
]
|
|
177
|
+
]
|
|
178
|
+
.join(strings_1.MARKDOWN_EOP)
|
|
179
|
+
.trim();
|
|
172
180
|
};
|
|
173
181
|
}
|
|
174
182
|
exports.Printer = Printer;
|
package/dist/relation.js
CHANGED
|
@@ -35,8 +35,8 @@ const printRelationOf = (type, section, getRelation, options) => {
|
|
|
35
35
|
const category = (0, exports.getRootTypeLocaleFromString)(relation);
|
|
36
36
|
const badge = (0, badge_1.printBadge)({
|
|
37
37
|
text: category,
|
|
38
|
-
classname: badge_1.
|
|
39
|
-
});
|
|
38
|
+
classname: badge_1.CSS_BADGE_CLASSNAME.RELATION,
|
|
39
|
+
}, options);
|
|
40
40
|
data = data.concat(types.map((t) => {
|
|
41
41
|
const link = (0, link_1.getRelationLink)(category, t, options);
|
|
42
42
|
return link ? `[\`${link.text}\`](${link.url}) ${badge}` : "";
|
|
@@ -49,8 +49,8 @@ const printRelationOf = (type, section, getRelation, options) => {
|
|
|
49
49
|
.sort((a, b) => {
|
|
50
50
|
return a.localeCompare(b);
|
|
51
51
|
})
|
|
52
|
-
.join(
|
|
53
|
-
return `${options_1.SectionLevels.
|
|
52
|
+
.join(options.formatMDXBullet());
|
|
53
|
+
return `${options_1.SectionLevels.LEVEL.repeat(3)} ${section}${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
|
|
54
54
|
};
|
|
55
55
|
exports.printRelationOf = printRelationOf;
|
|
56
56
|
const printRelations = (type, options) => {
|
package/dist/section.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { MDXString, PrintTypeOptions
|
|
2
|
-
export declare const sectionLevels: SectionLevel[];
|
|
1
|
+
import type { MDXString, PrintTypeOptions } from "@graphql-markdown/types";
|
|
3
2
|
export declare const printSectionItem: <T>(type: T, options: PrintTypeOptions) => MDXString | string;
|
|
4
3
|
export declare const printSectionItems: <V>(values: V | V[], options: PrintTypeOptions) => MDXString | string;
|
|
5
4
|
export declare const printSection: <V>(values: V[] | readonly V[], section: string, options: PrintTypeOptions) => MDXString | string;
|
package/dist/section.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printMetadataSection = exports.printSection = exports.printSectionItems = exports.printSectionItem =
|
|
3
|
+
exports.printMetadataSection = exports.printSection = exports.printSectionItems = exports.printSectionItem = void 0;
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const common_1 = require("./common");
|
|
6
6
|
const badge_1 = require("./badge");
|
|
@@ -8,15 +8,8 @@ const link_1 = require("./link");
|
|
|
8
8
|
const directive_1 = require("./directive");
|
|
9
9
|
const strings_1 = require("./const/strings");
|
|
10
10
|
const options_1 = require("./const/options");
|
|
11
|
-
exports.sectionLevels = [
|
|
12
|
-
options_1.SectionLevels.LEVEL_3,
|
|
13
|
-
options_1.SectionLevels.LEVEL_4,
|
|
14
|
-
options_1.SectionLevels.LEVEL_5,
|
|
15
|
-
];
|
|
16
11
|
const printSectionItem = (type, options) => {
|
|
17
|
-
const level = "level" in options && typeof options.level === "
|
|
18
|
-
? options.level
|
|
19
|
-
: options_1.SectionLevels.LEVEL_4;
|
|
12
|
+
const level = "level" in options && typeof options.level === "number" ? options.level : 4;
|
|
20
13
|
if (!(0, link_1.hasPrintableDirective)(type, options)) {
|
|
21
14
|
return "";
|
|
22
15
|
}
|
|
@@ -27,7 +20,7 @@ const printSectionItem = (type, options) => {
|
|
|
27
20
|
const badges = (0, badge_1.printBadges)(type, options);
|
|
28
21
|
const tags = (0, directive_1.printCustomTags)(type, options);
|
|
29
22
|
const parentTypeLink = (0, link_1.printParentLink)(type, options);
|
|
30
|
-
const title = `${level} ${typeNameLink}${parentTypeLink} ${badges} ${tags}${strings_1.MARKDOWN_EOL}`;
|
|
23
|
+
const title = `${options_1.SectionLevels.LEVEL.repeat(level)} ${typeNameLink}${parentTypeLink} ${badges} ${tags}${strings_1.MARKDOWN_EOL}`;
|
|
31
24
|
const description = (0, common_1.printDescription)(type, options, "")
|
|
32
25
|
.trim()
|
|
33
26
|
.replaceAll("\n", `${strings_1.MARKDOWN_EOL}`);
|
|
@@ -36,7 +29,7 @@ const printSectionItem = (type, options) => {
|
|
|
36
29
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
37
30
|
section += (0, exports.printSectionItems)(type.args, {
|
|
38
31
|
...options,
|
|
39
|
-
level:
|
|
32
|
+
level: 5,
|
|
40
33
|
parentType: typeof options.parentType === "undefined"
|
|
41
34
|
? type.name
|
|
42
35
|
: `${options.parentType}.${type.name}`,
|
|
@@ -49,9 +42,7 @@ const printSectionItems = (values, options) => {
|
|
|
49
42
|
if (!Array.isArray(values) || values.length === 0) {
|
|
50
43
|
return "";
|
|
51
44
|
}
|
|
52
|
-
const level = ("level" in options && typeof options.level === "
|
|
53
|
-
? options.level
|
|
54
|
-
: options_1.SectionLevels.LEVEL_4);
|
|
45
|
+
const level = ("level" in options && typeof options.level === "number" ? options.level : 4);
|
|
55
46
|
return values
|
|
56
47
|
.map((v) => {
|
|
57
48
|
return (v &&
|
|
@@ -67,31 +58,23 @@ const printSection = (values, section, options) => {
|
|
|
67
58
|
if (!Array.isArray(values) || values.length === 0) {
|
|
68
59
|
return "";
|
|
69
60
|
}
|
|
70
|
-
const level = ("level" in options && typeof options.level === "
|
|
71
|
-
? options.level
|
|
72
|
-
: options_1.SectionLevels.LEVEL_3);
|
|
73
|
-
const levelPosition = exports.sectionLevels.indexOf(level);
|
|
61
|
+
const level = ("level" in options && typeof options.level === "number" ? options.level : 3);
|
|
74
62
|
const [openSection, closeSection] = (() => {
|
|
75
63
|
if (typeof options.collapsible?.dataOpen === "string" &&
|
|
76
64
|
typeof options.collapsible.dataClose === "string") {
|
|
77
|
-
return
|
|
78
|
-
`${strings_1.MARKDOWN_EOP}<Details dataOpen={${options.collapsible.dataOpen}} dataClose={${options.collapsible.dataClose}}>${strings_1.MARKDOWN_EOP}`,
|
|
79
|
-
`${strings_1.MARKDOWN_EOP}</Details>${strings_1.MARKDOWN_EOP}`,
|
|
80
|
-
];
|
|
65
|
+
return options.formatMDXDetails(options.collapsible).split(`\r`);
|
|
81
66
|
}
|
|
82
67
|
return [strings_1.MARKDOWN_EOP, strings_1.MARKDOWN_EOP];
|
|
83
68
|
})();
|
|
84
69
|
const items = (0, exports.printSectionItems)(values, {
|
|
85
70
|
...options,
|
|
86
71
|
collapsible: undefined, // do not propagate collapsible
|
|
87
|
-
level: (
|
|
88
|
-
? exports.sectionLevels[levelPosition + 1]
|
|
89
|
-
: undefined),
|
|
72
|
+
level: level >= 3 && level <= 5 ? (level + 1) : undefined,
|
|
90
73
|
});
|
|
91
74
|
if (items === "") {
|
|
92
75
|
return ""; // do not print section is no items printed
|
|
93
76
|
}
|
|
94
|
-
return `${level} ${section}${openSection}${items}${closeSection}`;
|
|
77
|
+
return `${options_1.SectionLevels.LEVEL.repeat(level)} ${section}${openSection}${items}${closeSection}`;
|
|
95
78
|
};
|
|
96
79
|
exports.printSection = printSection;
|
|
97
80
|
const printMetadataSection = (type, values, section, options) => {
|
|
@@ -120,10 +103,10 @@ const printMetadataSection = (type, values, section, options) => {
|
|
|
120
103
|
const deprecatedMeta = (0, exports.printSection)(deprecated, "", {
|
|
121
104
|
...options,
|
|
122
105
|
parentType: type.name,
|
|
123
|
-
level:
|
|
106
|
+
level: 0,
|
|
124
107
|
collapsible: {
|
|
125
|
-
dataOpen: strings_1.
|
|
126
|
-
dataClose: strings_1.
|
|
108
|
+
dataOpen: strings_1.DEPRECATED,
|
|
109
|
+
dataClose: strings_1.DEPRECATED,
|
|
127
110
|
},
|
|
128
111
|
});
|
|
129
112
|
return `${meta}${deprecatedMeta}`;
|
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.
|
|
8
|
+
"version": "1.12.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
"docs": "typedoc"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@graphql-markdown/graphql": "^1.1.
|
|
60
|
-
"@graphql-markdown/utils": "^1.
|
|
59
|
+
"@graphql-markdown/graphql": "^1.1.6",
|
|
60
|
+
"@graphql-markdown/utils": "^1.8.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@graphql-markdown/types": "^1.
|
|
63
|
+
"@graphql-markdown/types": "^1.7.0"
|
|
64
64
|
},
|
|
65
65
|
"resolutions": {
|
|
66
66
|
"micromatch": "4.0.8"
|
package/dist/const/mdx.d.ts
DELETED
package/dist/const/mdx.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mdx = void 0;
|
|
4
|
-
exports.mdx = `
|
|
5
|
-
export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em', color: 'var(--ifm-color-secondary-darkest)' }}> ● </span></>
|
|
6
|
-
|
|
7
|
-
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></>
|
|
8
|
-
|
|
9
|
-
export const Badge = (props) => <><span className={props.class}>{props.text}</span></>
|
|
10
|
-
|
|
11
|
-
import { useState } from 'react';
|
|
12
|
-
|
|
13
|
-
export const Details = ({ dataOpen, dataClose, children, startOpen = false }) => {
|
|
14
|
-
const [open, setOpen] = useState(startOpen);
|
|
15
|
-
return (
|
|
16
|
-
<details {...(open ? { open: true } : {})} className="details" style={{ border:'none', boxShadow:'none', background:'var(--ifm-background-color)' }}>
|
|
17
|
-
<summary
|
|
18
|
-
onClick={(e) => {
|
|
19
|
-
e.preventDefault();
|
|
20
|
-
setOpen((open) => !open);
|
|
21
|
-
}}
|
|
22
|
-
style={{ listStyle:'none' }}
|
|
23
|
-
>
|
|
24
|
-
{open ? dataOpen : dataClose}
|
|
25
|
-
</summary>
|
|
26
|
-
{open && children}
|
|
27
|
-
</details>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
`;
|