@graphql-markdown/printer-legacy 1.10.0 → 1.11.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 +1 -1
- package/dist/badge.js +4 -4
- package/dist/common.d.ts +6 -3
- package/dist/common.js +4 -9
- package/dist/const/options.d.ts +1 -0
- package/dist/const/options.js +5 -0
- package/dist/const/strings.d.ts +0 -3
- package/dist/const/strings.js +1 -4
- package/dist/directive.js +1 -1
- 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 +99 -0
- package/dist/printer.d.ts +4 -3
- package/dist/printer.js +10 -4
- package/dist/relation.js +2 -2
- package/dist/section.js +3 -6
- package/package.json +2 -1
- package/dist/const/mdx.d.ts +0 -2
- package/dist/const/mdx.js +0 -32
package/dist/badge.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Badge, MDXString, Maybe, PrintTypeOptions, SchemaEntitiesGroupMap } from "@graphql-markdown/types";
|
|
2
2
|
export declare const DEFAULT_CSS_CLASSNAME: "badge--secondary";
|
|
3
3
|
export declare const getTypeBadges: (type: unknown, groups?: Maybe<SchemaEntitiesGroupMap>) => Badge[];
|
|
4
|
-
export declare const printBadge: ({ text, classname }: Badge) => MDXString;
|
|
4
|
+
export declare const printBadge: ({ text, classname }: Badge, options: PrintTypeOptions) => MDXString;
|
|
5
5
|
export declare const printBadges: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
package/dist/badge.js
CHANGED
|
@@ -41,10 +41,10 @@ const getTypeBadges = (type, groups) => {
|
|
|
41
41
|
return badges;
|
|
42
42
|
};
|
|
43
43
|
exports.getTypeBadges = getTypeBadges;
|
|
44
|
-
const printBadge = ({ text, classname }) => {
|
|
45
|
-
const textString = typeof text === "object" ? text.singular : text
|
|
44
|
+
const printBadge = ({ text, classname }, options) => {
|
|
45
|
+
const textString = typeof text === "object" ? text.singular : text;
|
|
46
46
|
const formattedText = (0, utils_1.escapeMDX)(textString);
|
|
47
|
-
return
|
|
47
|
+
return options.formatMDXBadge({ text: formattedText, classname });
|
|
48
48
|
};
|
|
49
49
|
exports.printBadge = printBadge;
|
|
50
50
|
const printBadges = (type, options) => {
|
|
@@ -59,7 +59,7 @@ const printBadges = (type, options) => {
|
|
|
59
59
|
}
|
|
60
60
|
return badges
|
|
61
61
|
.map((badge) => {
|
|
62
|
-
return (0, exports.printBadge)(badge);
|
|
62
|
+
return (0, exports.printBadge)(badge, options);
|
|
63
63
|
})
|
|
64
64
|
.join(" ");
|
|
65
65
|
};
|
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
|
@@ -15,6 +15,7 @@ export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsib
|
|
|
15
15
|
collapsible: Maybe<CollapsibleOption>;
|
|
16
16
|
groups: Maybe<SchemaEntitiesGroupMap>;
|
|
17
17
|
level: Maybe<SectionLevelValue>;
|
|
18
|
+
mdxSupport: boolean;
|
|
18
19
|
onlyDocDirectives: GraphQLDirective[];
|
|
19
20
|
parentType: Maybe<string>;
|
|
20
21
|
schema: Maybe<GraphQLSchema>;
|
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";
|
|
@@ -38,4 +42,5 @@ exports.DEFAULT_OPTIONS = {
|
|
|
38
42
|
schema: undefined,
|
|
39
43
|
skipDocDirectives: [],
|
|
40
44
|
withAttributes: false,
|
|
45
|
+
...mdx_1.default,
|
|
41
46
|
};
|
package/dist/const/strings.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
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";
|
|
5
4
|
export declare const GRAPHQL: "graphql";
|
|
6
5
|
export declare const NO_DESCRIPTION_TEXT: "No description";
|
|
@@ -11,5 +10,3 @@ export declare const MARKDOWN_EOL: "\n";
|
|
|
11
10
|
export declare const MARKDOWN_EOP: string;
|
|
12
11
|
export declare const MARKDOWN_EOC: "\n```\n";
|
|
13
12
|
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.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,7 +14,6 @@ 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";
|
|
19
18
|
exports.GRAPHQL = "graphql";
|
|
20
19
|
exports.NO_DESCRIPTION_TEXT = "No description";
|
|
@@ -25,5 +24,3 @@ exports.MARKDOWN_EOL = "\n";
|
|
|
25
24
|
exports.MARKDOWN_EOP = `${exports.MARKDOWN_EOL.repeat(2)}`;
|
|
26
25
|
exports.MARKDOWN_EOC = `${exports.MARKDOWN_EOL}${exports.MARKDOWN_CODE_SNIPPET}${exports.MARKDOWN_EOL}`;
|
|
27
26
|
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
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.LEVEL_3}
|
|
16
|
+
return `${options_1.SectionLevels.LEVEL_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 { Maybe, MDXSupportType, PackageName } from "@graphql-markdown/types";
|
|
2
|
+
export declare const mdxDeclaration = "";
|
|
3
|
+
declare const defaultModule: MDXSupportType;
|
|
4
|
+
export declare const mdxModule: (mdxPackage?: Maybe<PackageName>) => Promise<Readonly<MDXSupportType>>;
|
|
5
|
+
export default defaultModule;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.mdxModule = exports.mdxDeclaration = void 0;
|
|
37
|
+
const strings_1 = require("../const/strings");
|
|
38
|
+
const logger_1 = require("@graphql-markdown/logger");
|
|
39
|
+
const formatMDXBadge = ({ text, classname }) => {
|
|
40
|
+
return `<mark class="gqlmd-mdx-badge">${text}</mark>`;
|
|
41
|
+
};
|
|
42
|
+
const formatMDXAdmonition = ({ text, title, type, icon }, meta) => {
|
|
43
|
+
return `${strings_1.MARKDOWN_EOP}<fieldset class="gqlmd-mdx-admonition-fieldset">${strings_1.MARKDOWN_EOL}<legend class="gqlmd-mdx-admonition-legend"><span class="gqlmd-mdx-admonition-legend-type gqlmd-mdx-admonition-legend-type-${type.toLocaleLowerCase()}">${icon ?? type.toUpperCase()}</span> **${title}**</legend>${strings_1.MARKDOWN_EOL}<span>${text}</span>${strings_1.MARKDOWN_EOL}</fieldset>`;
|
|
44
|
+
};
|
|
45
|
+
const formatMDXBullet = (text = "") => {
|
|
46
|
+
return `<span class="gqlmd-mdx-bullet"> ● </span>${text}`;
|
|
47
|
+
};
|
|
48
|
+
const formatMDXDetails = ({ dataOpen, }) => {
|
|
49
|
+
return `${strings_1.MARKDOWN_EOP}<details class="gqlmd-mdx-details">${strings_1.MARKDOWN_EOL}<summary class="gqlmd-mdx-details-summary"><span className="gqlmd-mdx-details-summary-open">${dataOpen?.toUpperCase()}</span></summary>${strings_1.MARKDOWN_EOP}\r${strings_1.MARKDOWN_EOP}</details>${strings_1.MARKDOWN_EOP}`;
|
|
50
|
+
};
|
|
51
|
+
const formatMDXSpecifiedByLink = (url) => {
|
|
52
|
+
return `<span class="gqlmd-mdx-specifiedby">Specification<a class="gqlmd-mdx-specifiedby-link" target="_blank" href="${url}" title="Specified by ${url}">⎘</a></span>`;
|
|
53
|
+
};
|
|
54
|
+
const formatMDXNameEntity = (name, parentType) => {
|
|
55
|
+
const parentName = parentType
|
|
56
|
+
? `<code class="gqlmd-mdx-entity-parent">${parentType}</code>.`
|
|
57
|
+
: "";
|
|
58
|
+
return `<span class="gqlmd-mdx-entity">${parentName}<code class="gqlmd-mdx-entity-name">${name}</code></span>`;
|
|
59
|
+
};
|
|
60
|
+
const formatMDXLink = (link) => {
|
|
61
|
+
return link;
|
|
62
|
+
};
|
|
63
|
+
exports.mdxDeclaration = "";
|
|
64
|
+
const defaultModule = {
|
|
65
|
+
formatMDXAdmonition,
|
|
66
|
+
formatMDXBadge,
|
|
67
|
+
formatMDXBullet,
|
|
68
|
+
formatMDXDetails,
|
|
69
|
+
formatMDXLink,
|
|
70
|
+
formatMDXNameEntity,
|
|
71
|
+
formatMDXSpecifiedByLink,
|
|
72
|
+
mdxDeclaration: exports.mdxDeclaration,
|
|
73
|
+
mdxSupport: false,
|
|
74
|
+
};
|
|
75
|
+
const mdxModule = async (mdxPackage) => {
|
|
76
|
+
if (!mdxPackage) {
|
|
77
|
+
return defaultModule;
|
|
78
|
+
}
|
|
79
|
+
return Promise.resolve(`${mdxPackage}`).then(s => __importStar(require(s))).then((_module) => {
|
|
80
|
+
const module = (_module.default ?? _module);
|
|
81
|
+
return {
|
|
82
|
+
formatMDXAdmonition: module.formatMDXAdmonition ?? formatMDXAdmonition,
|
|
83
|
+
formatMDXBadge: module.formatMDXBadge ?? formatMDXBadge,
|
|
84
|
+
formatMDXBullet: module.formatMDXBullet ?? formatMDXBullet,
|
|
85
|
+
formatMDXDetails: module.formatMDXDetails ?? formatMDXDetails,
|
|
86
|
+
formatMDXLink: module.formatMDXLink ?? formatMDXLink,
|
|
87
|
+
formatMDXNameEntity: module.formatMDXNameEntity ?? formatMDXNameEntity,
|
|
88
|
+
formatMDXSpecifiedByLink: module.formatMDXSpecifiedByLink ?? formatMDXSpecifiedByLink,
|
|
89
|
+
mdxDeclaration: module.mdxDeclaration ?? exports.mdxDeclaration,
|
|
90
|
+
mdxSupport: true,
|
|
91
|
+
};
|
|
92
|
+
})
|
|
93
|
+
.catch(() => {
|
|
94
|
+
(0, logger_1.log)(`An error occurred while loading MDX formatter "${mdxPackage}"`, logger_1.LogLevel.warn);
|
|
95
|
+
return defaultModule;
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
exports.mdxModule = mdxModule;
|
|
99
|
+
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, PackageName, 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?: PackageName): 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,8 +47,12 @@ 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.mdxSupport) {
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
51
56
|
const fmOptions = options.frontMatter ?? options_1.DEFAULT_OPTIONS.frontMatter;
|
|
52
57
|
return (0, frontmatter_1.printFrontMatter)(id, title, fmOptions);
|
|
53
58
|
};
|
|
@@ -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,
|
package/dist/relation.js
CHANGED
|
@@ -36,7 +36,7 @@ const printRelationOf = (type, section, getRelation, options) => {
|
|
|
36
36
|
const badge = (0, badge_1.printBadge)({
|
|
37
37
|
text: category,
|
|
38
38
|
classname: badge_1.DEFAULT_CSS_CLASSNAME,
|
|
39
|
-
});
|
|
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,7 +49,7 @@ const printRelationOf = (type, section, getRelation, options) => {
|
|
|
49
49
|
.sort((a, b) => {
|
|
50
50
|
return a.localeCompare(b);
|
|
51
51
|
})
|
|
52
|
-
.join(
|
|
52
|
+
.join(options.formatMDXBullet());
|
|
53
53
|
return `${options_1.SectionLevels.LEVEL_3} ${section}${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
|
|
54
54
|
};
|
|
55
55
|
exports.printRelationOf = printRelationOf;
|
package/dist/section.js
CHANGED
|
@@ -74,10 +74,7 @@ const printSection = (values, section, options) => {
|
|
|
74
74
|
const [openSection, closeSection] = (() => {
|
|
75
75
|
if (typeof options.collapsible?.dataOpen === "string" &&
|
|
76
76
|
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
|
-
];
|
|
77
|
+
return options.formatMDXDetails(options.collapsible).split(`\r`);
|
|
81
78
|
}
|
|
82
79
|
return [strings_1.MARKDOWN_EOP, strings_1.MARKDOWN_EOP];
|
|
83
80
|
})();
|
|
@@ -122,8 +119,8 @@ const printMetadataSection = (type, values, section, options) => {
|
|
|
122
119
|
parentType: type.name,
|
|
123
120
|
level: options_1.SectionLevels.NONE,
|
|
124
121
|
collapsible: {
|
|
125
|
-
dataOpen: strings_1.
|
|
126
|
-
dataClose: strings_1.
|
|
122
|
+
dataOpen: strings_1.DEPRECATED,
|
|
123
|
+
dataClose: strings_1.DEPRECATED,
|
|
127
124
|
},
|
|
128
125
|
});
|
|
129
126
|
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.11.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@graphql-markdown/graphql": "^1.1.5",
|
|
60
|
+
"@graphql-markdown/logger": "^1.0.5",
|
|
60
61
|
"@graphql-markdown/utils": "^1.7.1"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
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
|
-
`;
|