@graphql-markdown/printer-legacy 1.5.1 → 1.5.3
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/common.d.ts +1 -0
- package/dist/common.js +22 -8
- package/package.json +2 -1
package/dist/common.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PrintTypeOptions, MDXString, Maybe } 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?: string, title?: string) => string;
|
|
4
5
|
export declare const printDeprecation: (type: unknown) => string;
|
|
5
6
|
export declare const printDescription: (type: unknown, options?: PrintTypeOptions, noText?: string) => MDXString | string;
|
|
6
7
|
export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives">) => boolean;
|
package/dist/common.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasPrintableDirective = exports.printDescription = exports.printDeprecation = exports.formatDescription = exports.printCustomDirectives = void 0;
|
|
4
|
-
const utils_1 = require("@
|
|
3
|
+
exports.hasPrintableDirective = exports.printDescription = exports.printDeprecation = exports.printWarning = exports.formatDescription = exports.printCustomDirectives = void 0;
|
|
4
|
+
const utils_1 = require("@docusaurus/utils");
|
|
5
|
+
const utils_2 = require("@graphql-markdown/utils");
|
|
5
6
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
6
7
|
const directive_1 = require("./directive");
|
|
7
8
|
const strings_1 = require("./const/strings");
|
|
8
9
|
const printCustomDirectives = (type, options) => {
|
|
9
10
|
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options?.customDirectives);
|
|
10
|
-
if (!constDirectiveMap || (0,
|
|
11
|
+
if (!constDirectiveMap || (0, utils_2.isEmpty)(constDirectiveMap)) {
|
|
11
12
|
return "";
|
|
12
13
|
}
|
|
13
14
|
const content = Object.values(constDirectiveMap)
|
|
@@ -16,6 +17,9 @@ const printCustomDirectives = (type, options) => {
|
|
|
16
17
|
})
|
|
17
18
|
.filter((text) => {
|
|
18
19
|
return typeof text === "string" && text.length > 0;
|
|
20
|
+
})
|
|
21
|
+
.map((text) => {
|
|
22
|
+
return (0, utils_2.escapeMDX)(text);
|
|
19
23
|
})
|
|
20
24
|
.join(strings_1.MARKDOWN_EOP);
|
|
21
25
|
return `${strings_1.MARKDOWN_EOP}${content}`;
|
|
@@ -23,22 +27,32 @@ const printCustomDirectives = (type, options) => {
|
|
|
23
27
|
exports.printCustomDirectives = printCustomDirectives;
|
|
24
28
|
const formatDescription = (type, replacement = strings_1.NO_DESCRIPTION_TEXT) => {
|
|
25
29
|
if (typeof type !== "object" || type === null) {
|
|
26
|
-
return `${strings_1.MARKDOWN_EOP}${replacement}`;
|
|
30
|
+
return `${strings_1.MARKDOWN_EOP}${(0, utils_2.escapeMDX)(replacement)}`;
|
|
27
31
|
}
|
|
28
32
|
const description = "description" in type && typeof type.description === "string"
|
|
29
|
-
?
|
|
33
|
+
? type.description
|
|
30
34
|
: replacement;
|
|
31
|
-
return `${strings_1.MARKDOWN_EOP}${description}`;
|
|
35
|
+
return `${strings_1.MARKDOWN_EOP}${(0, utils_2.escapeMDX)(description)}`;
|
|
32
36
|
};
|
|
33
37
|
exports.formatDescription = formatDescription;
|
|
38
|
+
const printWarning = (text, title) => {
|
|
39
|
+
const formattedText = typeof text !== "string" || text.trim() === ""
|
|
40
|
+
? strings_1.MARKDOWN_EOP
|
|
41
|
+
: `${strings_1.MARKDOWN_EOP}${text}${strings_1.MARKDOWN_EOP}`;
|
|
42
|
+
if (utils_1.DOCUSAURUS_VERSION.startsWith("2")) {
|
|
43
|
+
return `${strings_1.MARKDOWN_EOP}:::caution ${title}${formattedText}:::`;
|
|
44
|
+
}
|
|
45
|
+
return `${strings_1.MARKDOWN_EOP}:::warning[${title}]${formattedText}:::`;
|
|
46
|
+
};
|
|
47
|
+
exports.printWarning = printWarning;
|
|
34
48
|
const printDeprecation = (type) => {
|
|
35
49
|
if (typeof type !== "object" || type === null || !(0, graphql_1.isDeprecated)(type)) {
|
|
36
50
|
return "";
|
|
37
51
|
}
|
|
38
52
|
const reason = "deprecationReason" in type && typeof type.deprecationReason === "string"
|
|
39
|
-
? type.deprecationReason
|
|
53
|
+
? (0, utils_2.escapeMDX)(type.deprecationReason)
|
|
40
54
|
: "";
|
|
41
|
-
return
|
|
55
|
+
return (0, exports.printWarning)(reason, strings_1.DEPRECATED.toUpperCase());
|
|
42
56
|
};
|
|
43
57
|
exports.printDeprecation = printDeprecation;
|
|
44
58
|
const printDescription = (type, options, noText) => {
|
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.5.
|
|
8
|
+
"version": "1.5.3",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"clean": "rm -rf ./dist"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
+
"@docusaurus/utils": ">=2.0.0",
|
|
58
59
|
"@graphql-markdown/graphql": "^1.0.1",
|
|
59
60
|
"@graphql-markdown/utils": "^1.6.1"
|
|
60
61
|
},
|