@graphql-markdown/printer-legacy 1.3.1 → 1.4.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/package.json +2 -2
- package/src/badge.js +23 -28
- package/src/common.js +35 -24
- package/src/const/mdx.js +1 -1
- package/src/const/strings.js +25 -18
- package/src/directive.js +59 -12
- package/src/link.js +20 -15
- package/src/printer.js +5 -1
- package/src/section.js +11 -10
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.4.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"main": "src/index.js",
|
|
11
11
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"stryker": "stryker run"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@graphql-markdown/utils": "^1.
|
|
25
|
+
"@graphql-markdown/utils": "^1.5.0"
|
|
26
26
|
},
|
|
27
27
|
"directories": {
|
|
28
28
|
"test": "tests"
|
package/src/badge.js
CHANGED
|
@@ -1,47 +1,42 @@
|
|
|
1
1
|
const {
|
|
2
|
+
graphql: { getNamedType, isDeprecated, isListType, isNonNullType },
|
|
2
3
|
object: { hasProperty },
|
|
3
|
-
|
|
4
|
-
isNonNullType,
|
|
5
|
-
isListType,
|
|
6
|
-
isDeprecated,
|
|
7
|
-
getNamedType,
|
|
8
|
-
getConstDirectiveMap,
|
|
9
|
-
},
|
|
4
|
+
string: { escapeMDX },
|
|
10
5
|
} = require("@graphql-markdown/utils");
|
|
11
6
|
|
|
12
7
|
const { getLinkCategory } = require("./link");
|
|
13
8
|
const { getGroup } = require("./group");
|
|
14
9
|
|
|
15
|
-
const
|
|
10
|
+
const DEFAULT_CSS_CLASSNAME = "badge--secondary";
|
|
11
|
+
|
|
12
|
+
const getTypeBadges = (type) => {
|
|
16
13
|
const rootType = hasProperty(type, "type") ? type.type : type;
|
|
17
14
|
|
|
18
15
|
const badges = [];
|
|
19
16
|
|
|
20
17
|
if (isDeprecated(type) === true) {
|
|
21
|
-
badges.push(
|
|
18
|
+
badges.push({
|
|
19
|
+
text: "deprecated",
|
|
20
|
+
classname: "badge--deprecated badge--secondary",
|
|
21
|
+
});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
if (isNonNullType(rootType) === true) {
|
|
25
|
-
badges.push("non-null");
|
|
25
|
+
badges.push({ text: "non-null", classname: DEFAULT_CSS_CLASSNAME });
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
if (isListType(rootType) === true) {
|
|
29
|
-
badges.push("list");
|
|
29
|
+
badges.push({ text: "list", classname: DEFAULT_CSS_CLASSNAME });
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
const category = getLinkCategory(getNamedType(rootType));
|
|
33
33
|
if (typeof category !== "undefined") {
|
|
34
|
-
badges.push(category);
|
|
34
|
+
badges.push({ text: category, classname: DEFAULT_CSS_CLASSNAME });
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const group = getGroup(rootType);
|
|
38
38
|
if (typeof group !== "undefined" && group !== "") {
|
|
39
|
-
badges.push(group);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const constDirectiveMap = getConstDirectiveMap(type, options);
|
|
43
|
-
if (typeof constDirectiveMap !== "undefined") {
|
|
44
|
-
badges.push(...Object.keys(constDirectiveMap).map((badge) => `@${badge}`));
|
|
39
|
+
badges.push({ text: group, classname: DEFAULT_CSS_CLASSNAME });
|
|
45
40
|
}
|
|
46
41
|
|
|
47
42
|
return badges;
|
|
@@ -52,23 +47,23 @@ const printBadges = (type, options) => {
|
|
|
52
47
|
return "";
|
|
53
48
|
}
|
|
54
49
|
|
|
55
|
-
const badges = getTypeBadges(type
|
|
50
|
+
const badges = getTypeBadges(type);
|
|
56
51
|
|
|
57
52
|
if (badges.length === 0) {
|
|
58
53
|
return "";
|
|
59
54
|
}
|
|
60
55
|
|
|
61
|
-
return badges
|
|
62
|
-
.map(
|
|
63
|
-
(badge) =>
|
|
64
|
-
`<Badge class="secondary" text="${
|
|
65
|
-
hasProperty(badge, "singular") ? badge.singular : badge
|
|
66
|
-
}"/>`,
|
|
67
|
-
)
|
|
68
|
-
.join(" ");
|
|
56
|
+
return badges.map((badge) => printBadge(badge)).join(" ");
|
|
69
57
|
};
|
|
70
58
|
|
|
59
|
+
function printBadge({ text, classname }) {
|
|
60
|
+
const textString = hasProperty(text, "singular") ? text.singular : text;
|
|
61
|
+
const formattedText = escapeMDX(textString);
|
|
62
|
+
return `<Badge class="badge ${classname}" text="${formattedText}"/>`;
|
|
63
|
+
}
|
|
64
|
+
|
|
71
65
|
module.exports = {
|
|
72
|
-
printBadges,
|
|
73
66
|
getTypeBadges,
|
|
67
|
+
printBadge,
|
|
68
|
+
printBadges,
|
|
74
69
|
};
|
package/src/common.js
CHANGED
|
@@ -1,55 +1,66 @@
|
|
|
1
1
|
const {
|
|
2
|
-
string: { escapeMDX },
|
|
3
|
-
object: { hasProperty, isEmpty },
|
|
4
2
|
graphql: { isDeprecated, getConstDirectiveMap },
|
|
3
|
+
object: { hasProperty, isEmpty },
|
|
4
|
+
string: { escapeMDX },
|
|
5
5
|
} = require("@graphql-markdown/utils");
|
|
6
6
|
|
|
7
|
-
const {
|
|
8
|
-
|
|
9
|
-
const { MARKDOWN_EOP, NO_DESCRIPTION_TEXT } = require("./const/strings");
|
|
10
|
-
|
|
11
|
-
const printDeprecation = (type) => {
|
|
12
|
-
if (isDeprecated(type) === false) {
|
|
13
|
-
return "";
|
|
14
|
-
}
|
|
7
|
+
const { getCustomDirectiveResolver } = require("./directive");
|
|
15
8
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
9
|
+
const {
|
|
10
|
+
DEPRECATED,
|
|
11
|
+
MARKDOWN_EOL,
|
|
12
|
+
MARKDOWN_EOP,
|
|
13
|
+
NO_DESCRIPTION_TEXT,
|
|
14
|
+
} = require("./const/strings");
|
|
23
15
|
|
|
24
16
|
const printCustomDirectives = (type, options) => {
|
|
25
17
|
const constDirectiveMap = getConstDirectiveMap(type, options);
|
|
26
18
|
|
|
27
|
-
if (
|
|
19
|
+
if (isEmpty(constDirectiveMap)) {
|
|
28
20
|
return "";
|
|
29
21
|
}
|
|
30
22
|
|
|
31
23
|
const content = Object.values(constDirectiveMap)
|
|
32
24
|
.map((constDirectiveOption) =>
|
|
33
|
-
|
|
25
|
+
getCustomDirectiveResolver("descriptor", type, constDirectiveOption, ""),
|
|
34
26
|
)
|
|
27
|
+
.filter((text) => text.length > 0)
|
|
35
28
|
.join(MARKDOWN_EOP);
|
|
36
29
|
|
|
37
|
-
return `${
|
|
30
|
+
return `${MARKDOWN_EOP}${content}`;
|
|
38
31
|
};
|
|
39
32
|
|
|
40
|
-
const
|
|
33
|
+
const formatDescription = (type, noText = NO_DESCRIPTION_TEXT) => {
|
|
41
34
|
const replacement = typeof noText === "string" ? noText : NO_DESCRIPTION_TEXT;
|
|
42
35
|
const description =
|
|
43
36
|
hasProperty(type, "description") && typeof type.description === "string"
|
|
44
37
|
? escapeMDX(type.description)
|
|
45
38
|
: replacement;
|
|
46
|
-
|
|
39
|
+
return `${MARKDOWN_EOP}${description}`;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const printDeprecation = (type) => {
|
|
43
|
+
if (isDeprecated(type) === false) {
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const reason =
|
|
48
|
+
typeof type.deprecationReason === "string"
|
|
49
|
+
? type.deprecationReason + MARKDOWN_EOL
|
|
50
|
+
: "";
|
|
51
|
+
|
|
52
|
+
return `${MARKDOWN_EOP}:::caution ${DEPRECATED.toUpperCase()}${MARKDOWN_EOL}${reason}:::`;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const printDescription = (type, options, noText) => {
|
|
56
|
+
const description = formatDescription(type, noText);
|
|
47
57
|
const customDirectives = printCustomDirectives(type, options);
|
|
48
|
-
|
|
58
|
+
const deprecation = printDeprecation(type);
|
|
59
|
+
return `${deprecation}${description}${customDirectives}`;
|
|
49
60
|
};
|
|
50
61
|
|
|
51
62
|
module.exports = {
|
|
63
|
+
printCustomDirectives,
|
|
52
64
|
printDeprecation,
|
|
53
65
|
printDescription,
|
|
54
|
-
printCustomDirectives,
|
|
55
66
|
};
|
package/src/const/mdx.js
CHANGED
|
@@ -3,7 +3,7 @@ export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5
|
|
|
3
3
|
|
|
4
4
|
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></>
|
|
5
5
|
|
|
6
|
-
export const Badge = (props) => <><span className={
|
|
6
|
+
export const Badge = (props) => <><span className={props.class}>{props.text}</span></>
|
|
7
7
|
|
|
8
8
|
import { useState } from 'react';
|
|
9
9
|
|
package/src/const/strings.js
CHANGED
|
@@ -1,41 +1,48 @@
|
|
|
1
1
|
const ROOT_TYPE_LOCALE = {
|
|
2
|
-
QUERY: { singular: "query", plural: "queries" },
|
|
3
|
-
MUTATION: { singular: "mutation", plural: "mutations" },
|
|
4
|
-
SUBSCRIPTION: { singular: "subscription", plural: "subscriptions" },
|
|
5
|
-
TYPE: { singular: "object", plural: "objects" },
|
|
6
|
-
INTERFACE: { singular: "interface", plural: "interfaces" },
|
|
7
2
|
DIRECTIVE: { singular: "directive", plural: "directives" },
|
|
8
|
-
SCALAR: { singular: "scalar", plural: "scalars" },
|
|
9
3
|
ENUM: { singular: "enum", plural: "enums" },
|
|
4
|
+
INPUT: { singular: "input", plural: "inputs" },
|
|
5
|
+
INTERFACE: { singular: "interface", plural: "interfaces" },
|
|
6
|
+
MUTATION: { singular: "mutation", plural: "mutations" },
|
|
10
7
|
OPERATION: { singular: "operation", plural: "operations" },
|
|
8
|
+
QUERY: { singular: "query", plural: "queries" },
|
|
9
|
+
SCALAR: { singular: "scalar", plural: "scalars" },
|
|
10
|
+
SUBSCRIPTION: { singular: "subscription", plural: "subscriptions" },
|
|
11
|
+
TYPE: { singular: "object", plural: "objects" },
|
|
11
12
|
UNION: { singular: "union", plural: "unions" },
|
|
12
|
-
INPUT: { singular: "input", plural: "inputs" },
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
const HEADER_SECTION_ITEM_LEVEL = "#####";
|
|
15
16
|
const HEADER_SECTION_LEVEL = "###";
|
|
16
17
|
const HEADER_SECTION_SUB_LEVEL = "####";
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
const NO_DESCRIPTION_TEXT = "No description";
|
|
20
|
+
|
|
21
|
+
const FRONT_MATTER = "---";
|
|
22
|
+
const MARKDOWN_CODE_INDENTATION = " ";
|
|
19
23
|
const MARKDOWN_EOL = "\n";
|
|
20
24
|
const MARKDOWN_EOP = "\n\n";
|
|
21
|
-
const MARKDOWN_SOC = `${MARKDOWN_EOL}\`\`\`graphql${MARKDOWN_EOL}`;
|
|
22
25
|
const MARKDOWN_EOC = `${MARKDOWN_EOL}\`\`\`${MARKDOWN_EOL}`;
|
|
23
|
-
const
|
|
24
|
-
const FRONT_MATTER = "---";
|
|
26
|
+
const MARKDOWN_SOC = `${MARKDOWN_EOL}\`\`\`graphql${MARKDOWN_EOL}`;
|
|
25
27
|
|
|
26
28
|
const DEPRECATED = "deprecated";
|
|
27
29
|
|
|
30
|
+
const HIDE_DEPRECATED = `<><span className="deprecated">Hide deprecated</span></>`;
|
|
31
|
+
const SHOW_DEPRECATED = `<><span className="deprecated">Show deprecated</span></>`;
|
|
32
|
+
|
|
28
33
|
module.exports = {
|
|
29
|
-
|
|
34
|
+
DEPRECATED,
|
|
35
|
+
FRONT_MATTER,
|
|
36
|
+
HEADER_SECTION_ITEM_LEVEL,
|
|
30
37
|
HEADER_SECTION_LEVEL,
|
|
31
38
|
HEADER_SECTION_SUB_LEVEL,
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
HIDE_DEPRECATED,
|
|
40
|
+
MARKDOWN_CODE_INDENTATION,
|
|
41
|
+
MARKDOWN_EOC,
|
|
34
42
|
MARKDOWN_EOL,
|
|
35
43
|
MARKDOWN_EOP,
|
|
36
44
|
MARKDOWN_SOC,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
DEPRECATED,
|
|
45
|
+
NO_DESCRIPTION_TEXT,
|
|
46
|
+
ROOT_TYPE_LOCALE,
|
|
47
|
+
SHOW_DEPRECATED,
|
|
41
48
|
};
|
package/src/directive.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const {
|
|
2
2
|
graphql: { getConstDirectiveMap },
|
|
3
|
-
object: { hasProperty },
|
|
4
3
|
} = require("@graphql-markdown/utils");
|
|
5
4
|
const {
|
|
6
5
|
HEADER_SECTION_LEVEL,
|
|
7
6
|
HEADER_SECTION_SUB_LEVEL,
|
|
8
|
-
MARKDOWN_EOP,
|
|
9
7
|
MARKDOWN_EOL,
|
|
8
|
+
MARKDOWN_EOP,
|
|
10
9
|
} = require("./const/strings");
|
|
11
10
|
const { printLink } = require("./link");
|
|
11
|
+
const { printBadge } = require("./badge");
|
|
12
12
|
|
|
13
13
|
function printCustomDirectives(type, options) {
|
|
14
14
|
const constDirectiveMap = getConstDirectiveMap(type, options);
|
|
@@ -20,11 +20,17 @@ function printCustomDirectives(type, options) {
|
|
|
20
20
|
return "";
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const directives = Object.values(constDirectiveMap)
|
|
24
24
|
.map((constDirectiveOption) =>
|
|
25
25
|
printCustomDirective(type, constDirectiveOption, options),
|
|
26
26
|
)
|
|
27
|
-
.
|
|
27
|
+
.filter((value) => typeof value !== "undefined");
|
|
28
|
+
|
|
29
|
+
if (directives.length === 0) {
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const content = directives.join(MARKDOWN_EOP);
|
|
28
34
|
|
|
29
35
|
return `${HEADER_SECTION_LEVEL} Directives${MARKDOWN_EOP}${content}${MARKDOWN_EOP}`;
|
|
30
36
|
}
|
|
@@ -34,25 +40,66 @@ function printCustomDirective(type, constDirectiveOption, options) {
|
|
|
34
40
|
...options,
|
|
35
41
|
withAttributes: false,
|
|
36
42
|
});
|
|
37
|
-
const description =
|
|
43
|
+
const description = getCustomDirectiveResolver(
|
|
44
|
+
"descriptor",
|
|
45
|
+
type,
|
|
46
|
+
constDirectiveOption,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
if (typeof description === "undefined") {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
38
52
|
|
|
39
53
|
return `${HEADER_SECTION_SUB_LEVEL} ${typeNameLink}${MARKDOWN_EOL}> ${description}${MARKDOWN_EOL}> `;
|
|
40
54
|
}
|
|
41
55
|
|
|
42
|
-
function
|
|
56
|
+
function getCustomTags(type, options) {
|
|
57
|
+
const constDirectiveMap = getConstDirectiveMap(type, options);
|
|
58
|
+
|
|
43
59
|
if (
|
|
44
|
-
typeof
|
|
45
|
-
!
|
|
46
|
-
typeof constDirectiveOption.descriptor !== "function"
|
|
60
|
+
typeof constDirectiveMap !== "object" ||
|
|
61
|
+
!Object.keys(constDirectiveMap).length
|
|
47
62
|
) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return Object.values(constDirectiveMap)
|
|
67
|
+
.map((constDirectiveOption) =>
|
|
68
|
+
getCustomDirectiveResolver("tag", type, constDirectiveOption),
|
|
69
|
+
)
|
|
70
|
+
.filter((value) => typeof value !== "undefined");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const printCustomTags = (type, options) => {
|
|
74
|
+
const badges = getCustomTags(type, options);
|
|
75
|
+
|
|
76
|
+
if (badges.length === 0) {
|
|
48
77
|
return "";
|
|
49
78
|
}
|
|
50
79
|
|
|
51
|
-
return
|
|
80
|
+
return badges.map((badge) => printBadge(badge)).join(" ");
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
function getCustomDirectiveResolver(
|
|
84
|
+
resolver,
|
|
85
|
+
type,
|
|
86
|
+
constDirectiveOption,
|
|
87
|
+
fallback = undefined,
|
|
88
|
+
) {
|
|
89
|
+
if (
|
|
90
|
+
typeof constDirectiveOption === "undefined" ||
|
|
91
|
+
typeof constDirectiveOption[resolver] !== "function"
|
|
92
|
+
) {
|
|
93
|
+
return fallback;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return constDirectiveOption[resolver](constDirectiveOption.type, type);
|
|
52
97
|
}
|
|
53
98
|
|
|
54
99
|
module.exports = {
|
|
55
|
-
|
|
100
|
+
getCustomDirectiveResolver,
|
|
101
|
+
getCustomTags,
|
|
56
102
|
printCustomDirective,
|
|
57
|
-
|
|
103
|
+
printCustomDirectives,
|
|
104
|
+
printCustomTags,
|
|
58
105
|
};
|
package/src/link.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
const {
|
|
2
|
-
string: { toSlug },
|
|
3
|
-
url: { pathUrl },
|
|
4
|
-
object: { hasProperty },
|
|
5
2
|
graphql: {
|
|
6
|
-
isEnumType,
|
|
7
|
-
isUnionType,
|
|
8
|
-
isObjectType,
|
|
9
|
-
isScalarType,
|
|
10
|
-
isOperation,
|
|
11
|
-
isDirectiveType,
|
|
12
|
-
isInterfaceType,
|
|
13
3
|
getNamedType,
|
|
14
|
-
isInputType,
|
|
15
|
-
hasDirective,
|
|
16
4
|
getTypeName,
|
|
5
|
+
hasDirective,
|
|
6
|
+
isDeprecated,
|
|
7
|
+
isDirectiveType,
|
|
8
|
+
isEnumType,
|
|
9
|
+
isInputType,
|
|
10
|
+
isInterfaceType,
|
|
11
|
+
isLeafType,
|
|
17
12
|
isListType,
|
|
18
13
|
isNonNullType,
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
isObjectType,
|
|
15
|
+
isOperation,
|
|
16
|
+
isScalarType,
|
|
17
|
+
isUnionType,
|
|
21
18
|
},
|
|
19
|
+
object: { hasProperty },
|
|
20
|
+
string: { toSlug },
|
|
21
|
+
url: { pathUrl },
|
|
22
22
|
} = require("@graphql-markdown/utils");
|
|
23
23
|
|
|
24
24
|
const { getGroup } = require("./group");
|
|
@@ -139,7 +139,12 @@ class Link {
|
|
|
139
139
|
static printLink = (type, options) => {
|
|
140
140
|
let text;
|
|
141
141
|
|
|
142
|
-
const link = Link.toLink(
|
|
142
|
+
const link = Link.toLink(
|
|
143
|
+
type,
|
|
144
|
+
getTypeName(type, type.toString()),
|
|
145
|
+
undefined,
|
|
146
|
+
options,
|
|
147
|
+
);
|
|
143
148
|
|
|
144
149
|
if (Link.hasOptionWithAttributes(options) === false) {
|
|
145
150
|
text =
|
package/src/printer.js
CHANGED
|
@@ -19,7 +19,7 @@ const {
|
|
|
19
19
|
|
|
20
20
|
const { printRelations } = require("./relation");
|
|
21
21
|
const { printDescription } = require("./common");
|
|
22
|
-
const { printCustomDirectives } = require("./directive");
|
|
22
|
+
const { printCustomDirectives, printCustomTags } = require("./directive");
|
|
23
23
|
const {
|
|
24
24
|
printOperationMetadata,
|
|
25
25
|
printCodeOperation,
|
|
@@ -143,6 +143,8 @@ class Printer {
|
|
|
143
143
|
|
|
144
144
|
static printCustomDirectives = printCustomDirectives;
|
|
145
145
|
|
|
146
|
+
static printCustomTags = printCustomTags;
|
|
147
|
+
|
|
146
148
|
static printTypeMetadata = (type, options) => {
|
|
147
149
|
let metadata;
|
|
148
150
|
|
|
@@ -202,12 +204,14 @@ class Printer {
|
|
|
202
204
|
type,
|
|
203
205
|
printTypeOptions,
|
|
204
206
|
);
|
|
207
|
+
const tags = Printer.printCustomTags(type, printTypeOptions);
|
|
205
208
|
const metadata = Printer.printTypeMetadata(type, printTypeOptions);
|
|
206
209
|
const relations = Printer.printRelations(type, printTypeOptions);
|
|
207
210
|
|
|
208
211
|
return [
|
|
209
212
|
header,
|
|
210
213
|
mdx,
|
|
214
|
+
tags,
|
|
211
215
|
description,
|
|
212
216
|
code,
|
|
213
217
|
customDirectives,
|
package/src/section.js
CHANGED
|
@@ -3,16 +3,21 @@ const {
|
|
|
3
3
|
} = require("@graphql-markdown/utils");
|
|
4
4
|
const { hasProperty } = require("@graphql-markdown/utils/src/object");
|
|
5
5
|
|
|
6
|
+
const { printDescription } = require("./common");
|
|
7
|
+
const { printBadges } = require("./badge");
|
|
8
|
+
const { printLink, printParentLink } = require("./link");
|
|
9
|
+
const { printCustomTags } = require("./directive");
|
|
10
|
+
|
|
6
11
|
const {
|
|
12
|
+
HEADER_SECTION_ITEM_LEVEL,
|
|
7
13
|
HEADER_SECTION_LEVEL,
|
|
8
14
|
HEADER_SECTION_SUB_LEVEL,
|
|
9
|
-
|
|
15
|
+
HIDE_DEPRECATED,
|
|
10
16
|
MARKDOWN_EOL,
|
|
11
17
|
MARKDOWN_EOP,
|
|
18
|
+
SHOW_DEPRECATED,
|
|
12
19
|
} = require("./const/strings");
|
|
13
|
-
|
|
14
|
-
const { printBadges } = require("./badge");
|
|
15
|
-
const { printLink, printParentLink } = require("./link");
|
|
20
|
+
|
|
16
21
|
const { OPTION_DEPRECATED } = require("./const/options");
|
|
17
22
|
|
|
18
23
|
const sectionLevels = [
|
|
@@ -21,9 +26,6 @@ const sectionLevels = [
|
|
|
21
26
|
HEADER_SECTION_ITEM_LEVEL,
|
|
22
27
|
];
|
|
23
28
|
|
|
24
|
-
const SHOW_DEPRECATED = `<><span className="deprecated">Show deprecated</span></>`;
|
|
25
|
-
const HIDE_DEPRECATED = `<><span className="deprecated">Hide deprecated</span></>`;
|
|
26
|
-
|
|
27
29
|
const printMetadataSection = (type, values, section, options) => {
|
|
28
30
|
switch (options.printDeprecated) {
|
|
29
31
|
case OPTION_DEPRECATED.GROUP: {
|
|
@@ -157,9 +159,10 @@ const printSectionItem = (type, options) => {
|
|
|
157
159
|
`${MARKDOWN_EOL}> `,
|
|
158
160
|
);
|
|
159
161
|
const badges = printBadges(type, options);
|
|
162
|
+
const tags = printCustomTags(type, options);
|
|
160
163
|
const parentTypeLink = printParentLink(type, options);
|
|
161
164
|
|
|
162
|
-
let section = `${level} ${typeNameLink}${parentTypeLink} ${badges}${MARKDOWN_EOL}> ${description}${MARKDOWN_EOL}> `;
|
|
165
|
+
let section = `${level} ${typeNameLink}${parentTypeLink} ${badges} ${tags}${MARKDOWN_EOL}> ${description}${MARKDOWN_EOL}> `;
|
|
163
166
|
if (isParametrizedField(type)) {
|
|
164
167
|
section += printSectionItems(type.args, {
|
|
165
168
|
...options,
|
|
@@ -179,6 +182,4 @@ module.exports = {
|
|
|
179
182
|
printSectionItem,
|
|
180
183
|
printSectionItems,
|
|
181
184
|
printMetadataSection,
|
|
182
|
-
SHOW_DEPRECATED,
|
|
183
|
-
HIDE_DEPRECATED,
|
|
184
185
|
};
|