@graphql-markdown/printer-legacy 1.5.0-next.0 → 1.5.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 +10 -8
- package/dist/code.d.ts +1 -1
- package/dist/code.js +17 -23
- package/dist/common.d.ts +1 -0
- package/dist/common.js +26 -3
- package/dist/const/options.d.ts +6 -5
- package/dist/const/options.js +4 -1
- package/dist/directive.d.ts +2 -2
- package/dist/directive.js +36 -26
- package/dist/graphql/enum.d.ts +1 -1
- package/dist/graphql/enum.js +5 -7
- package/dist/link.d.ts +4 -4
- package/dist/link.js +39 -36
- package/dist/printer.d.ts +8 -6
- package/dist/printer.js +25 -11
- package/dist/relation.js +10 -5
- package/dist/section.d.ts +4 -4
- package/dist/section.js +83 -77
- package/package.json +5 -5
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 printBadges: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
5
4
|
export declare const printBadge: ({ text, classname }: Badge) => MDXString;
|
|
5
|
+
export declare const printBadges: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
package/dist/badge.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.printBadges = exports.printBadge = exports.getTypeBadges = exports.DEFAULT_CSS_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");
|
|
@@ -41,6 +41,12 @@ 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 === "string" ? text : text.singular;
|
|
46
|
+
const formattedText = (0, utils_1.escapeMDX)(textString);
|
|
47
|
+
return `<Badge class="badge ${classname}" text="${formattedText}"/>`;
|
|
48
|
+
};
|
|
49
|
+
exports.printBadge = printBadge;
|
|
44
50
|
const printBadges = (type, options) => {
|
|
45
51
|
if (!("typeBadges" in options) ||
|
|
46
52
|
typeof options.typeBadges !== "boolean" ||
|
|
@@ -52,13 +58,9 @@ const printBadges = (type, options) => {
|
|
|
52
58
|
return "";
|
|
53
59
|
}
|
|
54
60
|
return badges
|
|
55
|
-
.map((badge) =>
|
|
61
|
+
.map((badge) => {
|
|
62
|
+
return (0, exports.printBadge)(badge);
|
|
63
|
+
})
|
|
56
64
|
.join(" ");
|
|
57
65
|
};
|
|
58
66
|
exports.printBadges = printBadges;
|
|
59
|
-
const printBadge = ({ text, classname }) => {
|
|
60
|
-
const textString = typeof text === "string" ? text : text.singular;
|
|
61
|
-
const formattedText = (0, utils_1.escapeMDX)(textString);
|
|
62
|
-
return `<Badge class="badge ${classname}" text="${formattedText}"/>`;
|
|
63
|
-
};
|
|
64
|
-
exports.printBadge = printBadge;
|
package/dist/code.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { MDXString, PrintTypeOptions } from "@graphql-markdown/types";
|
|
2
|
-
export declare const printCodeField: (type: unknown, options?: PrintTypeOptions, indentationLevel?: number) => MDXString | string;
|
|
3
2
|
export declare const printCodeArguments: (type: unknown, indentationLevel?: number) => string;
|
|
3
|
+
export declare const printCodeField: (type: unknown, options?: PrintTypeOptions, indentationLevel?: number) => MDXString | string;
|
package/dist/code.js
CHANGED
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.printCodeField = exports.printCodeArguments = void 0;
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const strings_1 = require("./const/strings");
|
|
6
|
-
const
|
|
7
|
-
if (typeof type !== "object" || type === null || !("type" in type)) {
|
|
8
|
-
return "";
|
|
9
|
-
}
|
|
10
|
-
const skipDirective = options &&
|
|
11
|
-
"skipDocDirective" in options &&
|
|
12
|
-
(0, graphql_1.hasDirective)(type, options.skipDocDirective);
|
|
13
|
-
const skipDeprecated = options &&
|
|
14
|
-
"deprecated" in options &&
|
|
15
|
-
options.deprecated === "skip" &&
|
|
16
|
-
(0, graphql_1.isDeprecated)(type);
|
|
17
|
-
if (skipDirective || skipDeprecated) {
|
|
18
|
-
return "";
|
|
19
|
-
}
|
|
20
|
-
let code = `${(0, graphql_1.getTypeName)(type)}`;
|
|
21
|
-
code += (0, exports.printCodeArguments)(type, indentationLevel + 1);
|
|
22
|
-
code += `: ${(0, graphql_1.getTypeName)(type.type)}`;
|
|
23
|
-
code += (0, graphql_1.isDeprecated)(type) ? ` @${strings_1.DEPRECATED}` : "";
|
|
24
|
-
code += strings_1.MARKDOWN_EOL;
|
|
25
|
-
return code;
|
|
26
|
-
};
|
|
27
|
-
exports.printCodeField = printCodeField;
|
|
6
|
+
const common_1 = require("./common");
|
|
28
7
|
const printCodeArguments = (type, indentationLevel = 1) => {
|
|
29
8
|
if (typeof type !== "object" ||
|
|
30
9
|
type === null ||
|
|
@@ -50,3 +29,18 @@ const printCodeArguments = (type, indentationLevel = 1) => {
|
|
|
50
29
|
return code;
|
|
51
30
|
};
|
|
52
31
|
exports.printCodeArguments = printCodeArguments;
|
|
32
|
+
const printCodeField = (type, options, indentationLevel = 0) => {
|
|
33
|
+
if (typeof type !== "object" || type === null || !("type" in type)) {
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
if (!(0, common_1.hasPrintableDirective)(type, options)) {
|
|
37
|
+
return "";
|
|
38
|
+
}
|
|
39
|
+
let code = `${(0, graphql_1.getTypeName)(type)}`;
|
|
40
|
+
code += (0, exports.printCodeArguments)(type, indentationLevel + 1);
|
|
41
|
+
code += `: ${(0, graphql_1.getTypeName)(type.type)}`;
|
|
42
|
+
code += (0, graphql_1.isDeprecated)(type) ? ` @${strings_1.DEPRECATED}` : "";
|
|
43
|
+
code += strings_1.MARKDOWN_EOL;
|
|
44
|
+
return code;
|
|
45
|
+
};
|
|
46
|
+
exports.printCodeField = printCodeField;
|
package/dist/common.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export declare const printCustomDirectives: (type: unknown, options?: PrintTypeO
|
|
|
3
3
|
export declare const formatDescription: (type: unknown, replacement?: Maybe<string>) => MDXString | string;
|
|
4
4
|
export declare const printDeprecation: (type: unknown) => string;
|
|
5
5
|
export declare const printDescription: (type: unknown, options?: PrintTypeOptions, noText?: string) => MDXString | string;
|
|
6
|
+
export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives">) => boolean;
|
package/dist/common.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printDescription = exports.printDeprecation = exports.formatDescription = exports.printCustomDirectives = void 0;
|
|
3
|
+
exports.hasPrintableDirective = exports.printDescription = exports.printDeprecation = 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
6
|
const directive_1 = require("./directive");
|
|
@@ -11,8 +11,12 @@ const printCustomDirectives = (type, options) => {
|
|
|
11
11
|
return "";
|
|
12
12
|
}
|
|
13
13
|
const content = Object.values(constDirectiveMap)
|
|
14
|
-
.map((constDirectiveOption) =>
|
|
15
|
-
.
|
|
14
|
+
.map((constDirectiveOption) => {
|
|
15
|
+
return (0, directive_1.getCustomDirectiveResolver)("descriptor", type, constDirectiveOption, "");
|
|
16
|
+
})
|
|
17
|
+
.filter((text) => {
|
|
18
|
+
return typeof text === "string" && text.length > 0;
|
|
19
|
+
})
|
|
16
20
|
.join(strings_1.MARKDOWN_EOP);
|
|
17
21
|
return `${strings_1.MARKDOWN_EOP}${content}`;
|
|
18
22
|
};
|
|
@@ -44,3 +48,22 @@ const printDescription = (type, options, noText) => {
|
|
|
44
48
|
return `${deprecation}${description}${customDirectives}`;
|
|
45
49
|
};
|
|
46
50
|
exports.printDescription = printDescription;
|
|
51
|
+
const hasPrintableDirective = (type, options) => {
|
|
52
|
+
if (!type) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
if (!options) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
const skipDirective = "skipDocDirectives" in options && options.skipDocDirectives
|
|
59
|
+
? (0, graphql_1.hasDirective)(type, options.skipDocDirectives)
|
|
60
|
+
: false;
|
|
61
|
+
const skipDeprecated = "deprecated" in options &&
|
|
62
|
+
options.deprecated === "skip" &&
|
|
63
|
+
(0, graphql_1.isDeprecated)(type);
|
|
64
|
+
const onlyDirective = "onlyDocDirectives" in options && options.onlyDocDirectives
|
|
65
|
+
? (0, graphql_1.hasDirective)(type, options.onlyDocDirectives, true)
|
|
66
|
+
: true;
|
|
67
|
+
return !(skipDirective || skipDeprecated) && onlyDirective;
|
|
68
|
+
};
|
|
69
|
+
exports.hasPrintableDirective = hasPrintableDirective;
|
package/dist/const/options.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollapsibleOption,
|
|
1
|
+
import type { CollapsibleOption, GraphQLDirective, GraphQLSchema, Maybe, PrintTypeOptions, PrinterConfigPrintTypeOptions, SchemaEntitiesGroupMap, SectionLevelValue } from "@graphql-markdown/types";
|
|
2
2
|
export declare enum SectionLevels {
|
|
3
3
|
NONE = "",
|
|
4
4
|
LEVEL_3 = "###",
|
|
@@ -6,11 +6,12 @@ export declare enum SectionLevels {
|
|
|
6
6
|
LEVEL_5 = "#####"
|
|
7
7
|
}
|
|
8
8
|
export declare const PRINT_TYPE_DEFAULT_OPTIONS: Required<PrinterConfigPrintTypeOptions>;
|
|
9
|
-
export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "groups" | "level" | "parentType" | "schema" | "
|
|
10
|
-
schema: Maybe<GraphQLSchema>;
|
|
11
|
-
skipDocDirective: Maybe<DirectiveName[]>;
|
|
9
|
+
export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "groups" | "level" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
|
|
12
10
|
collapsible: Maybe<CollapsibleOption>;
|
|
13
|
-
parentType: Maybe<string>;
|
|
14
11
|
groups: Maybe<SchemaEntitiesGroupMap>;
|
|
15
12
|
level: Maybe<SectionLevelValue>;
|
|
13
|
+
onlyDocDirectives: GraphQLDirective[];
|
|
14
|
+
parentType: Maybe<string>;
|
|
15
|
+
schema: Maybe<GraphQLSchema>;
|
|
16
|
+
skipDocDirectives: GraphQLDirective[];
|
|
16
17
|
};
|
package/dist/const/options.js
CHANGED
|
@@ -11,6 +11,7 @@ var SectionLevels;
|
|
|
11
11
|
exports.PRINT_TYPE_DEFAULT_OPTIONS = {
|
|
12
12
|
codeSection: true,
|
|
13
13
|
deprecated: "default",
|
|
14
|
+
metatags: [],
|
|
14
15
|
parentTypePrefix: true,
|
|
15
16
|
relatedTypeSection: true,
|
|
16
17
|
typeBadges: true,
|
|
@@ -23,8 +24,10 @@ exports.DEFAULT_OPTIONS = {
|
|
|
23
24
|
groups: undefined,
|
|
24
25
|
header: { toc: true, pagination: true },
|
|
25
26
|
level: undefined,
|
|
27
|
+
metatags: [],
|
|
28
|
+
onlyDocDirectives: [],
|
|
26
29
|
parentType: undefined,
|
|
27
30
|
schema: undefined,
|
|
28
|
-
|
|
31
|
+
skipDocDirectives: [],
|
|
29
32
|
withAttributes: false,
|
|
30
33
|
};
|
package/dist/directive.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Badge, PrintTypeOptions, MDXString, CustomDirectiveMapItem, CustomDirectiveResolver, Maybe } from "@graphql-markdown/types";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const getCustomDirectiveResolver: (resolver: CustomDirectiveResolver, type: unknown, constDirectiveOption: CustomDirectiveMapItem, fallback?: Maybe<string>) => Maybe<string>;
|
|
3
3
|
export declare const printCustomDirective: (type: unknown, constDirectiveOption: CustomDirectiveMapItem, options: PrintTypeOptions) => Maybe<string>;
|
|
4
|
+
export declare const printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
|
|
4
5
|
export declare const getCustomTags: (type: unknown, options: PrintTypeOptions) => Badge[];
|
|
5
6
|
export declare const printCustomTags: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
6
|
-
export declare const getCustomDirectiveResolver: (resolver: CustomDirectiveResolver, type: unknown, constDirectiveOption: CustomDirectiveMapItem, fallback?: Maybe<string>) => Maybe<string>;
|
package/dist/directive.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.printCustomTags = exports.getCustomTags = exports.printCustomDirectives = exports.printCustomDirective = exports.getCustomDirectiveResolver = void 0;
|
|
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
7
|
const link_1 = require("./link");
|
|
8
8
|
const badge_1 = require("./badge");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const directives = Object.values(constDirectiveMap)
|
|
15
|
-
.map((constDirectiveOption) => (0, exports.printCustomDirective)(type, constDirectiveOption, options))
|
|
16
|
-
.filter((value) => typeof value !== "undefined");
|
|
17
|
-
if (directives.length === 0) {
|
|
18
|
-
return "";
|
|
9
|
+
const getCustomDirectiveResolver = (resolver, type, constDirectiveOption, fallback) => {
|
|
10
|
+
if (typeof constDirectiveOption === "undefined" ||
|
|
11
|
+
typeof constDirectiveOption.type !== "object" ||
|
|
12
|
+
typeof constDirectiveOption[resolver] !== "function") {
|
|
13
|
+
return fallback;
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
return `${options_1.SectionLevels.LEVEL_3} Directives${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
|
|
15
|
+
return constDirectiveOption[resolver](constDirectiveOption.type, type);
|
|
22
16
|
};
|
|
23
|
-
exports.
|
|
17
|
+
exports.getCustomDirectiveResolver = getCustomDirectiveResolver;
|
|
24
18
|
const printCustomDirective = (type, constDirectiveOption, options) => {
|
|
25
19
|
const typeNameLink = (0, link_1.printLink)(constDirectiveOption.type, {
|
|
26
20
|
...options,
|
|
@@ -33,6 +27,25 @@ const printCustomDirective = (type, constDirectiveOption, options) => {
|
|
|
33
27
|
return `${options_1.SectionLevels.LEVEL_4} ${typeNameLink}${strings_1.MARKDOWN_EOL}> ${description}${strings_1.MARKDOWN_EOL}> `;
|
|
34
28
|
};
|
|
35
29
|
exports.printCustomDirective = printCustomDirective;
|
|
30
|
+
const printCustomDirectives = (type, options) => {
|
|
31
|
+
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
|
|
32
|
+
if (!constDirectiveMap || Object.keys(constDirectiveMap).length < 1) {
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
const directives = Object.values(constDirectiveMap)
|
|
36
|
+
.map((constDirectiveOption) => {
|
|
37
|
+
return (0, exports.printCustomDirective)(type, constDirectiveOption, options);
|
|
38
|
+
})
|
|
39
|
+
.filter((value) => {
|
|
40
|
+
return typeof value !== "undefined";
|
|
41
|
+
});
|
|
42
|
+
if (directives.length === 0) {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
const content = directives.join(strings_1.MARKDOWN_EOP);
|
|
46
|
+
return `${options_1.SectionLevels.LEVEL_3} Directives${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
|
|
47
|
+
};
|
|
48
|
+
exports.printCustomDirectives = printCustomDirectives;
|
|
36
49
|
const getCustomTags = (type, options) => {
|
|
37
50
|
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options.customDirectives);
|
|
38
51
|
if (typeof constDirectiveMap !== "object" ||
|
|
@@ -41,8 +54,12 @@ const getCustomTags = (type, options) => {
|
|
|
41
54
|
return [];
|
|
42
55
|
}
|
|
43
56
|
return Object.values(constDirectiveMap)
|
|
44
|
-
.map((constDirectiveOption) =>
|
|
45
|
-
.
|
|
57
|
+
.map((constDirectiveOption) => {
|
|
58
|
+
return (0, exports.getCustomDirectiveResolver)("tag", type, constDirectiveOption);
|
|
59
|
+
})
|
|
60
|
+
.filter((value) => {
|
|
61
|
+
return typeof value !== "undefined";
|
|
62
|
+
});
|
|
46
63
|
};
|
|
47
64
|
exports.getCustomTags = getCustomTags;
|
|
48
65
|
const printCustomTags = (type, options) => {
|
|
@@ -51,16 +68,9 @@ const printCustomTags = (type, options) => {
|
|
|
51
68
|
return "";
|
|
52
69
|
}
|
|
53
70
|
return badges
|
|
54
|
-
.map((badge) =>
|
|
71
|
+
.map((badge) => {
|
|
72
|
+
return (0, badge_1.printBadge)(badge);
|
|
73
|
+
})
|
|
55
74
|
.join(" ");
|
|
56
75
|
};
|
|
57
76
|
exports.printCustomTags = printCustomTags;
|
|
58
|
-
const getCustomDirectiveResolver = (resolver, type, constDirectiveOption, fallback) => {
|
|
59
|
-
if (typeof constDirectiveOption === "undefined" ||
|
|
60
|
-
typeof constDirectiveOption.type !== "object" ||
|
|
61
|
-
typeof constDirectiveOption[resolver] !== "function") {
|
|
62
|
-
return fallback;
|
|
63
|
-
}
|
|
64
|
-
return constDirectiveOption[resolver](constDirectiveOption.type, type);
|
|
65
|
-
};
|
|
66
|
-
exports.getCustomDirectiveResolver = getCustomDirectiveResolver;
|
package/dist/graphql/enum.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { MDXString, PrintTypeOptions } from "@graphql-markdown/types";
|
|
2
2
|
export declare const printEnumMetadata: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
3
|
-
export declare const printCodeEnum: (type: unknown, options
|
|
3
|
+
export declare const printCodeEnum: (type: unknown, options?: PrintTypeOptions) => string;
|
package/dist/graphql/enum.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.printCodeEnum = exports.printEnumMetadata = void 0;
|
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const strings_1 = require("../const/strings");
|
|
6
6
|
const section_1 = require("../section");
|
|
7
|
+
const common_1 = require("../common");
|
|
7
8
|
const printEnumMetadata = (type, options) => {
|
|
8
9
|
if (!(0, graphql_1.isEnumType)(type)) {
|
|
9
10
|
return "";
|
|
@@ -19,19 +20,16 @@ const printCodeEnum = (type, options) => {
|
|
|
19
20
|
code += type
|
|
20
21
|
.getValues()
|
|
21
22
|
.map((value) => {
|
|
22
|
-
|
|
23
|
-
(0, graphql_1.hasDirective)(value, options.skipDocDirective);
|
|
24
|
-
const skipDeprecated = "deprecated" in options &&
|
|
25
|
-
options.deprecated === "skip" &&
|
|
26
|
-
(0, graphql_1.isDeprecated)(value);
|
|
27
|
-
if (skipDirective || skipDeprecated) {
|
|
23
|
+
if (!(0, common_1.hasPrintableDirective)(value, options)) {
|
|
28
24
|
return "";
|
|
29
25
|
}
|
|
30
26
|
const v = (0, graphql_1.getTypeName)(value);
|
|
31
27
|
const d = (0, graphql_1.isDeprecated)(value) ? ` @${strings_1.DEPRECATED}` : "";
|
|
32
28
|
return ` ${v}${d}`;
|
|
33
29
|
})
|
|
34
|
-
.filter((value) =>
|
|
30
|
+
.filter((value) => {
|
|
31
|
+
return value.length > 0;
|
|
32
|
+
})
|
|
35
33
|
.join(strings_1.MARKDOWN_EOL);
|
|
36
34
|
code += `${strings_1.MARKDOWN_EOL}}`;
|
|
37
35
|
return code;
|
package/dist/link.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { MDXString, Maybe, PrintLinkOptions, TypeLink, TypeLocale } from "@graphql-markdown/types";
|
|
2
2
|
export declare const getLinkCategory: (type: unknown) => Maybe<TypeLocale>;
|
|
3
|
-
export declare const toLink: (type: unknown, name: string, operation: Maybe<TypeLocale>, options: PrintLinkOptions) => TypeLink;
|
|
4
|
-
export declare const getRelationLink: (category: Maybe<TypeLocale>, type: unknown, options: PrintLinkOptions) => Maybe<TypeLink>;
|
|
5
|
-
export declare const printParentLink: (type: unknown, options: PrintLinkOptions) => MDXString | string;
|
|
6
3
|
export declare const hasOptionWithAttributes: (options: PrintLinkOptions) => boolean;
|
|
7
4
|
export declare const hasOptionParentType: (options: PrintLinkOptions) => boolean;
|
|
8
|
-
export declare const
|
|
5
|
+
export declare const toLink: (type: unknown, name: string, operation: Maybe<TypeLocale>, options: PrintLinkOptions) => TypeLink;
|
|
6
|
+
export declare const getRelationLink: (category: Maybe<TypeLocale>, type: unknown, options: PrintLinkOptions) => Maybe<TypeLink>;
|
|
9
7
|
export declare const printLinkAttributes: (type: unknown, text?: Maybe<string>) => string;
|
|
8
|
+
export declare const printLink: (type: unknown, options: PrintLinkOptions) => string;
|
|
9
|
+
export declare const printParentLink: (type: unknown, options: PrintLinkOptions) => MDXString | string;
|
package/dist/link.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.printParentLink = exports.printLink = exports.printLinkAttributes = exports.getRelationLink = exports.toLink = exports.hasOptionParentType = exports.hasOptionWithAttributes = exports.getLinkCategory = void 0;
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const utils_1 = require("@graphql-markdown/utils");
|
|
6
6
|
const group_1 = require("./group");
|
|
7
7
|
const strings_1 = require("./const/strings");
|
|
8
|
+
const common_1 = require("./common");
|
|
8
9
|
const getLinkCategory = (type) => {
|
|
9
10
|
switch (true) {
|
|
10
11
|
case (0, graphql_1.isDirectiveType)(type):
|
|
@@ -27,6 +28,17 @@ const getLinkCategory = (type) => {
|
|
|
27
28
|
return undefined;
|
|
28
29
|
};
|
|
29
30
|
exports.getLinkCategory = getLinkCategory;
|
|
31
|
+
const hasOptionWithAttributes = (options) => {
|
|
32
|
+
return "withAttributes" in options && options.withAttributes === true;
|
|
33
|
+
};
|
|
34
|
+
exports.hasOptionWithAttributes = hasOptionWithAttributes;
|
|
35
|
+
const hasOptionParentType = (options) => {
|
|
36
|
+
return ("parentTypePrefix" in options &&
|
|
37
|
+
options.parentTypePrefix === true &&
|
|
38
|
+
"parentType" in options &&
|
|
39
|
+
typeof options.parentType !== "undefined");
|
|
40
|
+
};
|
|
41
|
+
exports.hasOptionParentType = hasOptionParentType;
|
|
30
42
|
const toLink = (type, name, operation, options) => {
|
|
31
43
|
const fallback = {
|
|
32
44
|
text: name,
|
|
@@ -35,10 +47,8 @@ const toLink = (type, name, operation, options) => {
|
|
|
35
47
|
if (typeof type !== "object") {
|
|
36
48
|
return fallback;
|
|
37
49
|
}
|
|
38
|
-
if (typeof options !== "undefined" &&
|
|
39
|
-
|
|
40
|
-
return fallback;
|
|
41
|
-
}
|
|
50
|
+
if (typeof options !== "undefined" && !(0, common_1.hasPrintableDirective)(type, options)) {
|
|
51
|
+
return fallback;
|
|
42
52
|
}
|
|
43
53
|
const graphQLNamedType = (0, graphql_1.getNamedType)(type);
|
|
44
54
|
let category = (0, exports.getLinkCategory)(graphQLNamedType);
|
|
@@ -82,23 +92,24 @@ const getRelationLink = (category, type, options) => {
|
|
|
82
92
|
return (0, exports.toLink)(type, type.name, category, options);
|
|
83
93
|
};
|
|
84
94
|
exports.getRelationLink = getRelationLink;
|
|
85
|
-
const
|
|
86
|
-
if (typeof type !== "object" || type === null
|
|
87
|
-
return "";
|
|
95
|
+
const printLinkAttributes = (type, text = "") => {
|
|
96
|
+
if (typeof type !== "object" || type === null) {
|
|
97
|
+
return text ?? "";
|
|
88
98
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
if (!(0, graphql_1.isLeafType)(type) &&
|
|
100
|
+
"ofType" in type &&
|
|
101
|
+
typeof type.ofType !== "undefined") {
|
|
102
|
+
text = (0, exports.printLinkAttributes)(type.ofType, text);
|
|
103
|
+
}
|
|
104
|
+
if ((0, graphql_1.isListType)(type)) {
|
|
105
|
+
return `[${text}]`;
|
|
106
|
+
}
|
|
107
|
+
if ((0, graphql_1.isNonNullType)(type)) {
|
|
108
|
+
return `${text}!`;
|
|
109
|
+
}
|
|
110
|
+
return text ?? "";
|
|
93
111
|
};
|
|
94
|
-
exports.
|
|
95
|
-
const hasOptionWithAttributes = (options) => "withAttributes" in options && options.withAttributes === true;
|
|
96
|
-
exports.hasOptionWithAttributes = hasOptionWithAttributes;
|
|
97
|
-
const hasOptionParentType = (options) => "parentTypePrefix" in options &&
|
|
98
|
-
options.parentTypePrefix === true &&
|
|
99
|
-
"parentType" in options &&
|
|
100
|
-
typeof options.parentType !== "undefined";
|
|
101
|
-
exports.hasOptionParentType = hasOptionParentType;
|
|
112
|
+
exports.printLinkAttributes = printLinkAttributes;
|
|
102
113
|
const printLink = (type, options) => {
|
|
103
114
|
if (typeof type !== "object" || type === null) {
|
|
104
115
|
return "";
|
|
@@ -114,21 +125,13 @@ const printLink = (type, options) => {
|
|
|
114
125
|
return `[\`${text}\`](${link.url})`;
|
|
115
126
|
};
|
|
116
127
|
exports.printLink = printLink;
|
|
117
|
-
const
|
|
118
|
-
if (typeof type !== "object" || type === null) {
|
|
119
|
-
return
|
|
120
|
-
}
|
|
121
|
-
if (!(0, graphql_1.isLeafType)(type) &&
|
|
122
|
-
"ofType" in type &&
|
|
123
|
-
typeof type.ofType != "undefined") {
|
|
124
|
-
text = (0, exports.printLinkAttributes)(type.ofType, text);
|
|
125
|
-
}
|
|
126
|
-
if ((0, graphql_1.isListType)(type)) {
|
|
127
|
-
return `[${text}]`;
|
|
128
|
-
}
|
|
129
|
-
if ((0, graphql_1.isNonNullType)(type)) {
|
|
130
|
-
return `${text}!`;
|
|
128
|
+
const printParentLink = (type, options) => {
|
|
129
|
+
if (typeof type !== "object" || type === null || !("type" in type)) {
|
|
130
|
+
return "";
|
|
131
131
|
}
|
|
132
|
-
return
|
|
132
|
+
return `<Bullet />${(0, exports.printLink)(type.type, {
|
|
133
|
+
...options,
|
|
134
|
+
withAttributes: true,
|
|
135
|
+
})}`;
|
|
133
136
|
};
|
|
134
|
-
exports.
|
|
137
|
+
exports.printParentLink = printParentLink;
|
package/dist/printer.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import type { CustomDirectiveMap,
|
|
1
|
+
import type { CustomDirectiveMap, GraphQLDirective, GraphQLSchema, IPrinter, MDXString, Maybe, PrintTypeOptions, PrinterConfigPrintTypeOptions, SchemaEntitiesGroupMap, TypeDeprecatedOption } from "@graphql-markdown/types";
|
|
2
2
|
export declare class Printer implements IPrinter {
|
|
3
3
|
static options: Maybe<PrintTypeOptions>;
|
|
4
|
-
static
|
|
4
|
+
static printDescription: (type: unknown, options?: PrintTypeOptions | undefined, noText?: string | undefined) => string | MDXString;
|
|
5
|
+
static printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
|
|
6
|
+
static printCustomTags: (type: unknown, options: PrintTypeOptions) => string | MDXString;
|
|
7
|
+
static init(schema: Maybe<GraphQLSchema>, baseURL?: Maybe<string>, linkRoot?: Maybe<string>, { customDirectives, groups, onlyDocDirectives, printTypeOptions, skipDocDirectives, }?: {
|
|
5
8
|
customDirectives?: CustomDirectiveMap;
|
|
6
9
|
deprecated?: TypeDeprecatedOption;
|
|
7
10
|
groups?: SchemaEntitiesGroupMap;
|
|
11
|
+
onlyDocDirectives?: GraphQLDirective[];
|
|
8
12
|
printTypeOptions?: PrinterConfigPrintTypeOptions;
|
|
9
|
-
|
|
13
|
+
skipDocDirectives?: GraphQLDirective[];
|
|
10
14
|
}): void;
|
|
11
15
|
static printHeader: (id: string, title: string, options: PrintTypeOptions) => string;
|
|
12
|
-
static printDescription: (type: unknown, options?: PrintTypeOptions | undefined, noText?: string | undefined) => string | MDXString;
|
|
13
16
|
static printCode: (type: unknown, options: PrintTypeOptions) => string;
|
|
14
|
-
static printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
|
|
15
|
-
static printCustomTags: (type: unknown, options: PrintTypeOptions) => string | MDXString;
|
|
16
17
|
static printTypeMetadata: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
17
18
|
static printRelations: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
19
|
+
static printMetaTags: (_type: unknown, { metatags }: PrintTypeOptions) => MDXString | string;
|
|
18
20
|
static printType: (name: Maybe<string>, type: unknown, options?: Maybe<Partial<PrintTypeOptions>>) => Maybe<MDXString>;
|
|
19
21
|
}
|
package/dist/printer.js
CHANGED
|
@@ -12,11 +12,15 @@ const mdx_1 = require("./const/mdx");
|
|
|
12
12
|
const options_1 = require("./const/options");
|
|
13
13
|
class Printer {
|
|
14
14
|
static options;
|
|
15
|
-
static
|
|
15
|
+
static printDescription = common_1.printDescription;
|
|
16
|
+
static printCustomDirectives = directive_1.printCustomDirectives;
|
|
17
|
+
static printCustomTags = directive_1.printCustomTags;
|
|
18
|
+
static init(schema, baseURL = "schema", linkRoot = "/", { customDirectives, groups, onlyDocDirectives, printTypeOptions, skipDocDirectives, } = {
|
|
16
19
|
customDirectives: undefined,
|
|
17
20
|
groups: undefined,
|
|
21
|
+
onlyDocDirectives: [],
|
|
18
22
|
printTypeOptions: options_1.PRINT_TYPE_DEFAULT_OPTIONS,
|
|
19
|
-
|
|
23
|
+
skipDocDirectives: [],
|
|
20
24
|
}) {
|
|
21
25
|
if (typeof Printer.options !== "undefined") {
|
|
22
26
|
return;
|
|
@@ -33,13 +37,14 @@ class Printer {
|
|
|
33
37
|
relatedTypeSection: printTypeOptions?.relatedTypeSection ??
|
|
34
38
|
options_1.PRINT_TYPE_DEFAULT_OPTIONS.relatedTypeSection,
|
|
35
39
|
schema,
|
|
36
|
-
|
|
40
|
+
onlyDocDirectives: onlyDocDirectives ?? [],
|
|
41
|
+
skipDocDirectives: skipDocDirectives ?? [],
|
|
37
42
|
typeBadges: printTypeOptions?.typeBadges ?? options_1.PRINT_TYPE_DEFAULT_OPTIONS.typeBadges,
|
|
38
43
|
};
|
|
39
44
|
}
|
|
40
45
|
static printHeader = (id, title, options) => {
|
|
41
46
|
const { toc, pagination } = options.header ?? options_1.DEFAULT_OPTIONS.header;
|
|
42
|
-
const
|
|
47
|
+
const paginationButtons = pagination
|
|
43
48
|
? []
|
|
44
49
|
: ["pagination_next: null", "pagination_prev: null"];
|
|
45
50
|
const header = [
|
|
@@ -47,12 +52,11 @@ class Printer {
|
|
|
47
52
|
`id: ${id}`,
|
|
48
53
|
`title: ${title}`,
|
|
49
54
|
`hide_table_of_contents: ${!toc}`,
|
|
50
|
-
...
|
|
55
|
+
...paginationButtons,
|
|
51
56
|
strings_1.FRONT_MATTER,
|
|
52
57
|
];
|
|
53
58
|
return header.join(strings_1.MARKDOWN_EOL);
|
|
54
59
|
};
|
|
55
|
-
static printDescription = common_1.printDescription;
|
|
56
60
|
static printCode = (type, options) => {
|
|
57
61
|
let code = "";
|
|
58
62
|
if (typeof options.codeSection === "undefined" ||
|
|
@@ -89,8 +93,6 @@ class Printer {
|
|
|
89
93
|
}
|
|
90
94
|
return strings_1.MARKDOWN_SOC + code.trim() + strings_1.MARKDOWN_EOC;
|
|
91
95
|
};
|
|
92
|
-
static printCustomDirectives = directive_1.printCustomDirectives;
|
|
93
|
-
static printCustomTags = directive_1.printCustomTags;
|
|
94
96
|
static printTypeMetadata = (type, options) => {
|
|
95
97
|
switch (true) {
|
|
96
98
|
case (0, graphql_1.isScalarType)(type):
|
|
@@ -119,18 +121,29 @@ class Printer {
|
|
|
119
121
|
}
|
|
120
122
|
return (0, relation_1.printRelations)(type, options);
|
|
121
123
|
};
|
|
124
|
+
static printMetaTags = (_type, { metatags }) => {
|
|
125
|
+
if (!metatags || metatags.length < 1) {
|
|
126
|
+
return "";
|
|
127
|
+
}
|
|
128
|
+
const meta = metatags.map((tag) => {
|
|
129
|
+
const props = Object.entries(tag).map(([name, value]) => {
|
|
130
|
+
return `${name}="${value}"`;
|
|
131
|
+
});
|
|
132
|
+
return `<meta ${props.join(" ")} />`;
|
|
133
|
+
});
|
|
134
|
+
return ["<head>", ...meta, "</head>"].join(strings_1.MARKDOWN_EOL);
|
|
135
|
+
};
|
|
122
136
|
static printType = (name, type, options) => {
|
|
123
137
|
const printTypeOptions = {
|
|
124
138
|
...options_1.DEFAULT_OPTIONS,
|
|
125
139
|
...Printer.options,
|
|
126
140
|
...options,
|
|
127
141
|
};
|
|
128
|
-
if (!type
|
|
129
|
-
!name ||
|
|
130
|
-
(0, graphql_1.hasDirective)(type, printTypeOptions.skipDocDirective)) {
|
|
142
|
+
if (!name || !(0, common_1.hasPrintableDirective)(type, printTypeOptions)) {
|
|
131
143
|
return undefined;
|
|
132
144
|
}
|
|
133
145
|
const header = Printer.printHeader(name, (0, graphql_1.getTypeName)(type), printTypeOptions);
|
|
146
|
+
const metatags = Printer.printMetaTags(type, printTypeOptions);
|
|
134
147
|
const description = Printer.printDescription(type, printTypeOptions);
|
|
135
148
|
const code = Printer.printCode(type, printTypeOptions);
|
|
136
149
|
const customDirectives = Printer.printCustomDirectives(type, printTypeOptions);
|
|
@@ -140,6 +153,7 @@ class Printer {
|
|
|
140
153
|
return [
|
|
141
154
|
header,
|
|
142
155
|
mdx_1.mdx,
|
|
156
|
+
metatags,
|
|
143
157
|
tags,
|
|
144
158
|
description,
|
|
145
159
|
code,
|
package/dist/relation.js
CHANGED
|
@@ -46,19 +46,24 @@ const printRelationOf = (type, section, getRelation, options) => {
|
|
|
46
46
|
return "";
|
|
47
47
|
}
|
|
48
48
|
const content = [...data]
|
|
49
|
-
.sort((a, b) =>
|
|
49
|
+
.sort((a, b) => {
|
|
50
|
+
return a.localeCompare(b);
|
|
51
|
+
})
|
|
50
52
|
.join("<Bullet />");
|
|
51
53
|
return `${options_1.SectionLevels.LEVEL_3} ${section}${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
|
|
52
54
|
};
|
|
53
55
|
exports.printRelationOf = printRelationOf;
|
|
54
56
|
const printRelations = (type, options) => {
|
|
55
57
|
const relations = {
|
|
56
|
-
"Returned by": graphql_1.getRelationOfReturn,
|
|
57
|
-
"Member
|
|
58
|
-
|
|
58
|
+
returnedBy: { section: "Returned by", getRelation: graphql_1.getRelationOfReturn },
|
|
59
|
+
memberOf: { section: "Member Of", getRelation: graphql_1.getRelationOfField },
|
|
60
|
+
implementedBy: {
|
|
61
|
+
section: "Implemented By",
|
|
62
|
+
getRelation: graphql_1.getRelationOfImplementation,
|
|
63
|
+
},
|
|
59
64
|
};
|
|
60
65
|
let data = "";
|
|
61
|
-
for (const
|
|
66
|
+
for (const { section, getRelation } of Object.values(relations)) {
|
|
62
67
|
data += (0, exports.printRelationOf)(type, section, getRelation, options);
|
|
63
68
|
}
|
|
64
69
|
return data;
|
package/dist/section.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MDXString, PrintTypeOptions, SectionLevel } from "@graphql-markdown/types";
|
|
2
2
|
export declare const sectionLevels: SectionLevel[];
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
3
|
+
export declare const printSectionItem: <T>(type: T, options: PrintTypeOptions) => MDXString | string;
|
|
4
|
+
export declare const printSectionItems: <V>(values: V | V[], options: PrintTypeOptions) => MDXString | string;
|
|
5
|
+
export declare const printSection: <V>(values: V[] | readonly V[], section: string, options: PrintTypeOptions) => MDXString | string;
|
|
6
|
+
export declare const printMetadataSection: <T, V>(type: T, values: V | 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.
|
|
3
|
+
exports.printMetadataSection = exports.printSection = exports.printSectionItems = exports.printSectionItem = exports.sectionLevels = 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");
|
|
@@ -13,44 +13,53 @@ exports.sectionLevels = [
|
|
|
13
13
|
options_1.SectionLevels.LEVEL_4,
|
|
14
14
|
options_1.SectionLevels.LEVEL_5,
|
|
15
15
|
];
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
values.length === 0) {
|
|
16
|
+
const printSectionItem = (type, options) => {
|
|
17
|
+
const level = "level" in options && typeof options.level === "string"
|
|
18
|
+
? options.level
|
|
19
|
+
: options_1.SectionLevels.LEVEL_4;
|
|
20
|
+
if (!(0, common_1.hasPrintableDirective)(type, options)) {
|
|
22
21
|
return "";
|
|
23
22
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
return `${meta}${deprecatedMeta}`;
|
|
44
|
-
}
|
|
45
|
-
case "default":
|
|
46
|
-
default:
|
|
47
|
-
return (0, exports.printSection)(values, section, {
|
|
48
|
-
...options,
|
|
49
|
-
parentType: type.name,
|
|
50
|
-
});
|
|
23
|
+
const typeNameLink = (0, link_1.printLink)(type, {
|
|
24
|
+
...options,
|
|
25
|
+
withAttributes: false,
|
|
26
|
+
});
|
|
27
|
+
const description = (0, common_1.printDescription)(type, options, "").replaceAll("\n", `${strings_1.MARKDOWN_EOL}> `);
|
|
28
|
+
const badges = (0, badge_1.printBadges)(type, options);
|
|
29
|
+
const tags = (0, directive_1.printCustomTags)(type, options);
|
|
30
|
+
const parentTypeLink = (0, link_1.printParentLink)(type, options);
|
|
31
|
+
let section = `${level} ${typeNameLink}${parentTypeLink} ${badges} ${tags}${strings_1.MARKDOWN_EOL}> ${description}${strings_1.MARKDOWN_EOL}> `;
|
|
32
|
+
if ((0, graphql_1.isGraphQLFieldType)(type)) {
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
34
|
+
section += (0, exports.printSectionItems)(type.args, {
|
|
35
|
+
...options,
|
|
36
|
+
level: options_1.SectionLevels.LEVEL_5,
|
|
37
|
+
parentType: typeof options.parentType === "undefined"
|
|
38
|
+
? type.name
|
|
39
|
+
: `${options.parentType}.${type.name}`,
|
|
40
|
+
});
|
|
51
41
|
}
|
|
42
|
+
return section;
|
|
52
43
|
};
|
|
53
|
-
exports.
|
|
44
|
+
exports.printSectionItem = printSectionItem;
|
|
45
|
+
const printSectionItems = (values, options) => {
|
|
46
|
+
if (!Array.isArray(values) || values.length === 0) {
|
|
47
|
+
return "";
|
|
48
|
+
}
|
|
49
|
+
const level = ("level" in options && typeof options.level === "string"
|
|
50
|
+
? options.level
|
|
51
|
+
: options_1.SectionLevels.LEVEL_4);
|
|
52
|
+
return values
|
|
53
|
+
.map((v) => {
|
|
54
|
+
return (v &&
|
|
55
|
+
(0, exports.printSectionItem)(v, {
|
|
56
|
+
...options,
|
|
57
|
+
level,
|
|
58
|
+
}));
|
|
59
|
+
})
|
|
60
|
+
.join(strings_1.MARKDOWN_EOP);
|
|
61
|
+
};
|
|
62
|
+
exports.printSectionItems = printSectionItems;
|
|
54
63
|
const printSection = (values, section, options) => {
|
|
55
64
|
if (!Array.isArray(values) || values.length === 0) {
|
|
56
65
|
return "";
|
|
@@ -82,49 +91,46 @@ const printSection = (values, section, options) => {
|
|
|
82
91
|
return `${level} ${section}${openSection}${items}${closeSection}`;
|
|
83
92
|
};
|
|
84
93
|
exports.printSection = printSection;
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
: options_1.SectionLevels.LEVEL_4);
|
|
92
|
-
return values
|
|
93
|
-
.map((v) => v &&
|
|
94
|
-
(0, exports.printSectionItem)(v, {
|
|
95
|
-
...options,
|
|
96
|
-
level,
|
|
97
|
-
}))
|
|
98
|
-
.join(strings_1.MARKDOWN_EOP);
|
|
99
|
-
};
|
|
100
|
-
exports.printSectionItems = printSectionItems;
|
|
101
|
-
const printSectionItem = (type, options) => {
|
|
102
|
-
const level = "level" in options && typeof options.level === "string"
|
|
103
|
-
? options.level
|
|
104
|
-
: options_1.SectionLevels.LEVEL_4;
|
|
105
|
-
const skipDirective = (0, graphql_1.hasDirective)(type, options.skipDocDirective);
|
|
106
|
-
const skipDeprecated = options.deprecated === "skip" && (0, graphql_1.isDeprecated)(type);
|
|
107
|
-
if (!type || skipDirective || skipDeprecated) {
|
|
94
|
+
const printMetadataSection = (type, values, section, options) => {
|
|
95
|
+
if (typeof type !== "object" ||
|
|
96
|
+
type === null ||
|
|
97
|
+
!("name" in type) ||
|
|
98
|
+
!Array.isArray(values) ||
|
|
99
|
+
values.length === 0) {
|
|
108
100
|
return "";
|
|
109
101
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
102
|
+
switch (options.deprecated) {
|
|
103
|
+
case "group": {
|
|
104
|
+
const { fields, deprecated } = values.reduce((res, arg) => {
|
|
105
|
+
if ((0, graphql_1.isDeprecated)(arg)) {
|
|
106
|
+
res.deprecated.push(arg);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
res.fields.push(arg);
|
|
110
|
+
}
|
|
111
|
+
return res;
|
|
112
|
+
}, { fields: [], deprecated: [] });
|
|
113
|
+
const meta = (0, exports.printSection)(fields, section, {
|
|
114
|
+
...options,
|
|
115
|
+
parentType: type.name,
|
|
116
|
+
});
|
|
117
|
+
const deprecatedMeta = (0, exports.printSection)(deprecated, "", {
|
|
118
|
+
...options,
|
|
119
|
+
parentType: type.name,
|
|
120
|
+
level: options_1.SectionLevels.NONE,
|
|
121
|
+
collapsible: {
|
|
122
|
+
dataOpen: strings_1.HIDE_DEPRECATED,
|
|
123
|
+
dataClose: strings_1.SHOW_DEPRECATED,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
return `${meta}${deprecatedMeta}`;
|
|
127
|
+
}
|
|
128
|
+
case "default":
|
|
129
|
+
default:
|
|
130
|
+
return (0, exports.printSection)(values, section, {
|
|
131
|
+
...options,
|
|
132
|
+
parentType: type.name,
|
|
133
|
+
});
|
|
127
134
|
}
|
|
128
|
-
return section;
|
|
129
135
|
};
|
|
130
|
-
exports.
|
|
136
|
+
exports.printMetadataSection = printMetadataSection;
|
package/package.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/graphql-markdown/graphql-markdown/issues"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.5.0
|
|
8
|
+
"version": "1.5.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "graphql-markdown/graphql-markdown",
|
|
12
|
+
"url": "git+https://github.com/graphql-markdown/graphql-markdown.git",
|
|
13
13
|
"directory": "packages/utils"
|
|
14
14
|
},
|
|
15
15
|
"author": {
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"clean": "rm -rf ./dist"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@graphql-markdown/graphql": "^1.0.0
|
|
59
|
-
"@graphql-markdown/utils": "^1.6.0
|
|
58
|
+
"@graphql-markdown/graphql": "^1.0.0",
|
|
59
|
+
"@graphql-markdown/utils": "^1.6.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@graphql-markdown/types": "^1.0.0
|
|
62
|
+
"@graphql-markdown/types": "^1.0.0"
|
|
63
63
|
},
|
|
64
64
|
"directories": {
|
|
65
65
|
"test": "tests"
|