@graphql-markdown/printer-legacy 1.4.2 → 1.5.0-next.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 +5 -0
- package/dist/badge.js +64 -0
- package/dist/code.d.ts +3 -0
- package/dist/code.js +52 -0
- package/dist/common.d.ts +5 -0
- package/dist/common.js +46 -0
- package/dist/const/mdx.d.ts +2 -0
- package/{src → dist}/const/mdx.js +4 -1
- package/dist/const/options.d.ts +16 -0
- package/dist/const/options.js +30 -0
- package/dist/const/strings.d.ts +12 -0
- package/dist/const/strings.js +26 -0
- package/dist/directive.d.ts +6 -0
- package/dist/directive.js +66 -0
- package/dist/graphql/directive.d.ts +3 -0
- package/dist/graphql/directive.js +34 -0
- package/dist/graphql/enum.d.ts +3 -0
- package/dist/graphql/enum.js +39 -0
- package/dist/graphql/index.d.ts +8 -0
- package/dist/graphql/index.js +24 -0
- package/dist/graphql/input.d.ts +3 -0
- package/dist/graphql/input.js +7 -0
- package/dist/graphql/interface.d.ts +3 -0
- package/dist/graphql/interface.js +7 -0
- package/dist/graphql/object.d.ts +4 -0
- package/dist/graphql/object.js +47 -0
- package/dist/graphql/operation.d.ts +4 -0
- package/dist/graphql/operation.js +27 -0
- package/dist/graphql/scalar.d.ts +4 -0
- package/dist/graphql/scalar.js +26 -0
- package/dist/graphql/union.d.ts +3 -0
- package/dist/graphql/union.js +27 -0
- package/dist/group.d.ts +2 -0
- package/dist/group.js +22 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/link.d.ts +9 -0
- package/dist/link.js +134 -0
- package/dist/printer.d.ts +19 -0
- package/dist/printer.js +152 -0
- package/dist/relation.d.ts +4 -0
- package/dist/relation.js +66 -0
- package/dist/section.d.ts +6 -0
- package/dist/section.js +130 -0
- package/package.json +51 -7
- package/src/badge.js +0 -69
- package/src/code.js +0 -60
- package/src/common.js +0 -66
- package/src/const/options.js +0 -28
- package/src/const/strings.js +0 -48
- package/src/directive.js +0 -105
- package/src/graphql/directive.js +0 -47
- package/src/graphql/enum.js +0 -47
- package/src/graphql/index.js +0 -10
- package/src/graphql/input.js +0 -10
- package/src/graphql/interface.js +0 -10
- package/src/graphql/object.js +0 -56
- package/src/graphql/operation.js +0 -28
- package/src/graphql/scalar.js +0 -30
- package/src/graphql/union.js +0 -31
- package/src/group.js +0 -21
- package/src/index.js +0 -3
- package/src/link.js +0 -183
- package/src/printer.js +0 -242
- package/src/relation.js +0 -82
- package/src/section.js +0 -185
package/src/section.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
graphql: { isParametrizedField, hasDirective, isDeprecated },
|
|
3
|
-
} = require("@graphql-markdown/utils");
|
|
4
|
-
const { hasProperty } = require("@graphql-markdown/utils/src/object");
|
|
5
|
-
|
|
6
|
-
const { printDescription } = require("./common");
|
|
7
|
-
const { printBadges } = require("./badge");
|
|
8
|
-
const { printLink, printParentLink } = require("./link");
|
|
9
|
-
const { printCustomTags } = require("./directive");
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
HEADER_SECTION_ITEM_LEVEL,
|
|
13
|
-
HEADER_SECTION_LEVEL,
|
|
14
|
-
HEADER_SECTION_SUB_LEVEL,
|
|
15
|
-
HIDE_DEPRECATED,
|
|
16
|
-
MARKDOWN_EOL,
|
|
17
|
-
MARKDOWN_EOP,
|
|
18
|
-
SHOW_DEPRECATED,
|
|
19
|
-
} = require("./const/strings");
|
|
20
|
-
|
|
21
|
-
const { OPTION_DEPRECATED } = require("./const/options");
|
|
22
|
-
|
|
23
|
-
const sectionLevels = [
|
|
24
|
-
HEADER_SECTION_LEVEL,
|
|
25
|
-
HEADER_SECTION_SUB_LEVEL,
|
|
26
|
-
HEADER_SECTION_ITEM_LEVEL,
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
const printMetadataSection = (type, values, section, options) => {
|
|
30
|
-
switch (options.printDeprecated) {
|
|
31
|
-
case OPTION_DEPRECATED.GROUP: {
|
|
32
|
-
const { fields, deprecated } = values.reduce(
|
|
33
|
-
(res, arg) => {
|
|
34
|
-
isDeprecated(arg) ? res.deprecated.push(arg) : res.fields.push(arg);
|
|
35
|
-
return res;
|
|
36
|
-
},
|
|
37
|
-
{ fields: [], deprecated: [] },
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
const meta = printSection(fields, section, {
|
|
41
|
-
...options,
|
|
42
|
-
parentType: type.name,
|
|
43
|
-
});
|
|
44
|
-
const deprecatedMeta = printSection(deprecated, "", {
|
|
45
|
-
...options,
|
|
46
|
-
parentType: type.name,
|
|
47
|
-
level: "",
|
|
48
|
-
collapsible: {
|
|
49
|
-
dataOpen: HIDE_DEPRECATED,
|
|
50
|
-
dataClose: SHOW_DEPRECATED,
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
return `${meta}${deprecatedMeta}`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
case OPTION_DEPRECATED.DEFAULT:
|
|
58
|
-
default:
|
|
59
|
-
return printSection(values, section, {
|
|
60
|
-
...options,
|
|
61
|
-
parentType: type.name,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const printSection = (values, section, options) => {
|
|
67
|
-
const level =
|
|
68
|
-
hasProperty(options, "level") &&
|
|
69
|
-
typeof options.level !== "undefined" &&
|
|
70
|
-
options.level !== null
|
|
71
|
-
? options.level
|
|
72
|
-
: HEADER_SECTION_LEVEL;
|
|
73
|
-
|
|
74
|
-
if (!Array.isArray(values) || values.length === 0) {
|
|
75
|
-
return "";
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const levelPosition = sectionLevels.indexOf(level);
|
|
79
|
-
|
|
80
|
-
const [openSection, closeSection] = (() => {
|
|
81
|
-
if (
|
|
82
|
-
hasProperty(options, "collapsible") &&
|
|
83
|
-
hasProperty(options.collapsible, "dataOpen") &&
|
|
84
|
-
hasProperty(options.collapsible, "dataClose")
|
|
85
|
-
) {
|
|
86
|
-
return [
|
|
87
|
-
`${MARKDOWN_EOP}<Details dataOpen={${options.collapsible.dataOpen}} dataClose={${options.collapsible.dataClose}}>${MARKDOWN_EOP}`,
|
|
88
|
-
`${MARKDOWN_EOP}</Details>${MARKDOWN_EOP}`,
|
|
89
|
-
];
|
|
90
|
-
}
|
|
91
|
-
return [MARKDOWN_EOP, MARKDOWN_EOP];
|
|
92
|
-
})();
|
|
93
|
-
|
|
94
|
-
const items = printSectionItems(values, {
|
|
95
|
-
...options,
|
|
96
|
-
collapsible: undefined, // do not propagate collapsible
|
|
97
|
-
level: levelPosition > -1 ? sectionLevels[levelPosition + 1] : undefined,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
if (items === "") {
|
|
101
|
-
return ""; // do not print section is no items printed
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return `${level} ${section}${openSection}${items}${closeSection}`;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const printSectionItems = (values, options) => {
|
|
108
|
-
const level =
|
|
109
|
-
hasProperty(options, "level") &&
|
|
110
|
-
typeof options.level !== "undefined" &&
|
|
111
|
-
options.level !== null
|
|
112
|
-
? options.level
|
|
113
|
-
: HEADER_SECTION_SUB_LEVEL;
|
|
114
|
-
|
|
115
|
-
if (!Array.isArray(values) || values.length === 0) {
|
|
116
|
-
return "";
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return values
|
|
120
|
-
.map(
|
|
121
|
-
(v) =>
|
|
122
|
-
v &&
|
|
123
|
-
printSectionItem(v, {
|
|
124
|
-
...options,
|
|
125
|
-
level,
|
|
126
|
-
}),
|
|
127
|
-
)
|
|
128
|
-
.join(MARKDOWN_EOP);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const printSectionItem = (type, options) => {
|
|
132
|
-
const level =
|
|
133
|
-
hasProperty(options, "level") &&
|
|
134
|
-
typeof options.level !== "undefined" &&
|
|
135
|
-
options.level !== null
|
|
136
|
-
? options.level
|
|
137
|
-
: HEADER_SECTION_SUB_LEVEL;
|
|
138
|
-
|
|
139
|
-
const skipDirective =
|
|
140
|
-
hasProperty(options, "skipDocDirective") &&
|
|
141
|
-
hasDirective(type, options.skipDocDirective) === true;
|
|
142
|
-
const skipDeprecated =
|
|
143
|
-
hasProperty(options, "printDeprecated") &&
|
|
144
|
-
options.printDeprecated === OPTION_DEPRECATED.SKIP &&
|
|
145
|
-
isDeprecated(type) === true;
|
|
146
|
-
|
|
147
|
-
if (
|
|
148
|
-
typeof type === "undefined" ||
|
|
149
|
-
type === null ||
|
|
150
|
-
skipDirective === true ||
|
|
151
|
-
skipDeprecated === true
|
|
152
|
-
) {
|
|
153
|
-
return "";
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const typeNameLink = printLink(type, { ...options, withAttributes: false });
|
|
157
|
-
const description = printDescription(type, options, "").replaceAll(
|
|
158
|
-
"\n",
|
|
159
|
-
`${MARKDOWN_EOL}> `,
|
|
160
|
-
);
|
|
161
|
-
const badges = printBadges(type, options);
|
|
162
|
-
const tags = printCustomTags(type, options);
|
|
163
|
-
const parentTypeLink = printParentLink(type, options);
|
|
164
|
-
|
|
165
|
-
let section = `${level} ${typeNameLink}${parentTypeLink} ${badges} ${tags}${MARKDOWN_EOL}> ${description}${MARKDOWN_EOL}> `;
|
|
166
|
-
if (isParametrizedField(type)) {
|
|
167
|
-
section += printSectionItems(type.args, {
|
|
168
|
-
...options,
|
|
169
|
-
level: HEADER_SECTION_ITEM_LEVEL,
|
|
170
|
-
parentType:
|
|
171
|
-
typeof options.parentType === "undefined"
|
|
172
|
-
? type.name
|
|
173
|
-
: `${options.parentType}.${type.name}`,
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return section;
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
module.exports = {
|
|
181
|
-
printSection,
|
|
182
|
-
printSectionItem,
|
|
183
|
-
printSectionItems,
|
|
184
|
-
printMetadataSection,
|
|
185
|
-
};
|