@graphql-markdown/printer-legacy 1.11.0 → 1.12.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 -1
- package/dist/badge.js +18 -10
- package/dist/const/options.d.ts +1 -4
- package/dist/const/options.js +1 -3
- package/dist/const/strings.d.ts +1 -0
- package/dist/const/strings.js +2 -1
- package/dist/directive.js +2 -2
- package/dist/frontmatter.d.ts +2 -3
- package/dist/frontmatter.js +6 -59
- package/dist/graphql/scalar.js +1 -1
- package/dist/mdx/index.d.ts +2 -2
- package/dist/mdx/index.js +24 -59
- package/dist/printer.d.ts +2 -2
- package/dist/printer.js +7 -5
- package/dist/relation.js +2 -2
- package/dist/section.d.ts +1 -2
- package/dist/section.js +9 -23
- package/package.json +4 -5
package/dist/badge.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { Badge, MDXString, Maybe, PrintTypeOptions, SchemaEntitiesGroupMap } from "@graphql-markdown/types";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const CSS_BADGE_CLASSNAME: {
|
|
3
|
+
DEPRECATED: string;
|
|
4
|
+
RELATION: string;
|
|
5
|
+
NON_NULL: string;
|
|
6
|
+
};
|
|
3
7
|
export declare const getTypeBadges: (type: unknown, groups?: Maybe<SchemaEntitiesGroupMap>) => Badge[];
|
|
4
8
|
export declare const printBadge: ({ text, classname }: Badge, options: PrintTypeOptions) => MDXString;
|
|
5
9
|
export declare const printBadges: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
package/dist/badge.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printBadges = exports.printBadge = exports.getTypeBadges = exports.
|
|
3
|
+
exports.printBadges = exports.printBadge = exports.getTypeBadges = exports.CSS_BADGE_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");
|
|
7
7
|
const group_1 = require("./group");
|
|
8
|
-
|
|
8
|
+
const strings_1 = require("./const/strings");
|
|
9
|
+
exports.CSS_BADGE_CLASSNAME = {
|
|
10
|
+
DEPRECATED: "DEPRECATED",
|
|
11
|
+
RELATION: "RELATION",
|
|
12
|
+
NON_NULL: "NON_NULL",
|
|
13
|
+
};
|
|
9
14
|
const getTypeBadges = (type, groups) => {
|
|
10
15
|
const badges = [];
|
|
11
16
|
if (typeof type !== "object" || type === null) {
|
|
@@ -14,28 +19,28 @@ const getTypeBadges = (type, groups) => {
|
|
|
14
19
|
const rootType = ("type" in type ? type.type : type);
|
|
15
20
|
if ((0, graphql_1.isDeprecated)(type)) {
|
|
16
21
|
badges.push({
|
|
17
|
-
text:
|
|
18
|
-
classname:
|
|
22
|
+
text: strings_1.DEPRECATED,
|
|
23
|
+
classname: exports.CSS_BADGE_CLASSNAME.DEPRECATED,
|
|
19
24
|
});
|
|
20
25
|
}
|
|
21
26
|
if ((0, graphql_1.isNonNullType)(rootType)) {
|
|
22
27
|
badges.push({
|
|
23
|
-
text:
|
|
24
|
-
classname: exports.
|
|
28
|
+
text: strings_1.NON_NULL,
|
|
29
|
+
classname: exports.CSS_BADGE_CLASSNAME.NON_NULL,
|
|
25
30
|
});
|
|
26
31
|
}
|
|
27
32
|
if ((0, graphql_1.isListType)(rootType)) {
|
|
28
|
-
badges.push({ text: "list"
|
|
33
|
+
badges.push({ text: "list" });
|
|
29
34
|
}
|
|
30
35
|
const category = (0, link_1.getCategoryLocale)((0, graphql_1.getNamedType)(rootType));
|
|
31
36
|
if (category) {
|
|
32
|
-
badges.push({ text: category
|
|
37
|
+
badges.push({ text: category });
|
|
33
38
|
}
|
|
34
39
|
if (groups) {
|
|
35
40
|
const typeCategory = (typeof category === "string" ? category : category?.plural);
|
|
36
41
|
const group = (0, group_1.getGroup)(rootType, groups, typeCategory);
|
|
37
42
|
if (group && group !== "") {
|
|
38
|
-
badges.push({ text: group
|
|
43
|
+
badges.push({ text: group });
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
return badges;
|
|
@@ -44,7 +49,10 @@ exports.getTypeBadges = getTypeBadges;
|
|
|
44
49
|
const printBadge = ({ text, classname }, options) => {
|
|
45
50
|
const textString = typeof text === "object" ? text.singular : text;
|
|
46
51
|
const formattedText = (0, utils_1.escapeMDX)(textString);
|
|
47
|
-
return options.formatMDXBadge({
|
|
52
|
+
return options.formatMDXBadge({
|
|
53
|
+
text: formattedText,
|
|
54
|
+
classname,
|
|
55
|
+
});
|
|
48
56
|
};
|
|
49
57
|
exports.printBadge = printBadge;
|
|
50
58
|
const printBadges = (type, options) => {
|
package/dist/const/options.d.ts
CHANGED
|
@@ -6,16 +6,13 @@ export declare enum TypeHierarchy {
|
|
|
6
6
|
}
|
|
7
7
|
export declare enum SectionLevels {
|
|
8
8
|
NONE = "",
|
|
9
|
-
|
|
10
|
-
LEVEL_4 = "####",
|
|
11
|
-
LEVEL_5 = "#####"
|
|
9
|
+
LEVEL = "#"
|
|
12
10
|
}
|
|
13
11
|
export declare const PRINT_TYPE_DEFAULT_OPTIONS: Required<PrinterConfigPrintTypeOptions>;
|
|
14
12
|
export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "groups" | "level" | "meta" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
|
|
15
13
|
collapsible: Maybe<CollapsibleOption>;
|
|
16
14
|
groups: Maybe<SchemaEntitiesGroupMap>;
|
|
17
15
|
level: Maybe<SectionLevelValue>;
|
|
18
|
-
mdxSupport: boolean;
|
|
19
16
|
onlyDocDirectives: GraphQLDirective[];
|
|
20
17
|
parentType: Maybe<string>;
|
|
21
18
|
schema: Maybe<GraphQLSchema>;
|
package/dist/const/options.js
CHANGED
|
@@ -14,9 +14,7 @@ var TypeHierarchy;
|
|
|
14
14
|
var SectionLevels;
|
|
15
15
|
(function (SectionLevels) {
|
|
16
16
|
SectionLevels["NONE"] = "";
|
|
17
|
-
SectionLevels["
|
|
18
|
-
SectionLevels["LEVEL_4"] = "####";
|
|
19
|
-
SectionLevels["LEVEL_5"] = "#####";
|
|
17
|
+
SectionLevels["LEVEL"] = "#";
|
|
20
18
|
})(SectionLevels || (exports.SectionLevels = SectionLevels = {}));
|
|
21
19
|
exports.PRINT_TYPE_DEFAULT_OPTIONS = {
|
|
22
20
|
codeSection: true,
|
package/dist/const/strings.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RootTypeLocale } from "@graphql-markdown/types";
|
|
2
2
|
export declare const ROOT_TYPE_LOCALE: RootTypeLocale;
|
|
3
3
|
export declare const DEPRECATED: "deprecated";
|
|
4
|
+
export declare const NON_NULL: "non-null";
|
|
4
5
|
export declare const GRAPHQL: "graphql";
|
|
5
6
|
export declare const NO_DESCRIPTION_TEXT: "No description";
|
|
6
7
|
export declare const MARKDOWN_CODE_SNIPPET: "```";
|
package/dist/const/strings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
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.NON_NULL = 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" },
|
|
@@ -15,6 +15,7 @@ exports.ROOT_TYPE_LOCALE = {
|
|
|
15
15
|
UNION: { singular: "union", plural: "unions" },
|
|
16
16
|
};
|
|
17
17
|
exports.DEPRECATED = "deprecated";
|
|
18
|
+
exports.NON_NULL = "non-null";
|
|
18
19
|
exports.GRAPHQL = "graphql";
|
|
19
20
|
exports.NO_DESCRIPTION_TEXT = "No description";
|
|
20
21
|
exports.MARKDOWN_CODE_SNIPPET = "```";
|
package/dist/directive.js
CHANGED
|
@@ -24,7 +24,7 @@ const printCustomDirective = (type, constDirectiveOption, options) => {
|
|
|
24
24
|
if (typeof description !== "string") {
|
|
25
25
|
return undefined;
|
|
26
26
|
}
|
|
27
|
-
return `${options_1.SectionLevels.
|
|
27
|
+
return `${options_1.SectionLevels.LEVEL.repeat(4)} ${typeNameLink}${strings_1.MARKDOWN_EOL} ${description}${strings_1.MARKDOWN_EOL} `;
|
|
28
28
|
};
|
|
29
29
|
exports.printCustomDirective = printCustomDirective;
|
|
30
30
|
const printCustomDirectives = (type, options) => {
|
|
@@ -43,7 +43,7 @@ const printCustomDirectives = (type, options) => {
|
|
|
43
43
|
return "";
|
|
44
44
|
}
|
|
45
45
|
const content = directives.join(strings_1.MARKDOWN_EOP);
|
|
46
|
-
return `${options_1.SectionLevels.
|
|
46
|
+
return `${options_1.SectionLevels.LEVEL.repeat(3)} Directives${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
|
|
47
47
|
};
|
|
48
48
|
exports.printCustomDirectives = printCustomDirectives;
|
|
49
49
|
const getCustomTags = (type, options) => {
|
package/dist/frontmatter.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { FrontMatterOptions, Maybe } from "@graphql-markdown/types";
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const printFrontMatter: (id: string, title: string, props?: Maybe<FrontMatterOptions>) => string;
|
|
1
|
+
import type { FrontMatterOptions, Maybe, PrintTypeOptions } from "@graphql-markdown/types";
|
|
2
|
+
export declare const printFrontMatter: (title: string, props: Maybe<FrontMatterOptions>, options: PrintTypeOptions) => string;
|
package/dist/frontmatter.js
CHANGED
|
@@ -1,65 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printFrontMatter =
|
|
3
|
+
exports.printFrontMatter = void 0;
|
|
4
4
|
const utils_1 = require("@graphql-markdown/utils");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const formatFrontMatterObject = (props, indentation = 0, prefix) => {
|
|
10
|
-
const frontMatter = [];
|
|
11
|
-
if (!props || typeof props !== "object") {
|
|
12
|
-
return frontMatter;
|
|
13
|
-
}
|
|
14
|
-
for (const [key, value] of Object.entries(props)) {
|
|
15
|
-
frontMatter.push(
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
17
|
-
...(0, exports.formatFrontMatterProp)({ [key]: value }, indentation + 1, prefix));
|
|
18
|
-
prefix = " ".repeat(prefix?.length ?? 0);
|
|
19
|
-
}
|
|
20
|
-
return frontMatter;
|
|
21
|
-
};
|
|
22
|
-
const formatFrontMatterList = (prop, indentation = 0, prefix = "- ") => {
|
|
23
|
-
const frontMatter = [];
|
|
24
|
-
if (!Array.isArray(prop)) {
|
|
25
|
-
return frontMatter;
|
|
5
|
+
const printFrontMatter = (title, props, options) => {
|
|
6
|
+
const frontMatter = (0, utils_1.formatFrontMatterObject)({ ...props, title }, -1);
|
|
7
|
+
if (!options.formatMDXFrontmatter) {
|
|
8
|
+
return "";
|
|
26
9
|
}
|
|
27
|
-
|
|
28
|
-
if (typeof entry === "object") {
|
|
29
|
-
frontMatter.push(...formatFrontMatterObject(entry, -1, prefix).map((item) => {
|
|
30
|
-
return `${tabs(indentation)}${item}`;
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
frontMatter.push(`${tabs(indentation)}- ${(0, utils_1.toString)(entry)}`);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return frontMatter;
|
|
38
|
-
};
|
|
39
|
-
const formatFrontMatterProp = (prop, indentation = 0, prefix) => {
|
|
40
|
-
if (typeof prop === "undefined" || prop === null) {
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
const tabs = strings_1.MARKDOWN_CODE_INDENTATION.repeat(indentation);
|
|
44
|
-
const [key, value] = Object.entries(prop)[0];
|
|
45
|
-
const index = `${tabs}${prefix ?? ""}${key}:`;
|
|
46
|
-
switch (true) {
|
|
47
|
-
case typeof value !== "string" && Array.isArray(value):
|
|
48
|
-
return [index, ...formatFrontMatterList(value, indentation + 1, prefix)];
|
|
49
|
-
case typeof value === "object" && value !== null:
|
|
50
|
-
return [index, ...formatFrontMatterObject(value, indentation, prefix)];
|
|
51
|
-
default:
|
|
52
|
-
return [`${index} ${value}`];
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
exports.formatFrontMatterProp = formatFrontMatterProp;
|
|
56
|
-
const printFrontMatter = (id, title, props) => {
|
|
57
|
-
const frontMatter = formatFrontMatterObject({ ...props, id, title }, -1);
|
|
58
|
-
const header = [
|
|
59
|
-
strings_1.FRONT_MATTER_DELIMITER,
|
|
60
|
-
...frontMatter,
|
|
61
|
-
strings_1.FRONT_MATTER_DELIMITER,
|
|
62
|
-
];
|
|
63
|
-
return header.join(strings_1.MARKDOWN_EOL);
|
|
10
|
+
return options.formatMDXFrontmatter(props, frontMatter);
|
|
64
11
|
};
|
|
65
12
|
exports.printFrontMatter = printFrontMatter;
|
package/dist/graphql/scalar.js
CHANGED
|
@@ -13,7 +13,7 @@ const printSpecification = (type, options) => {
|
|
|
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.
|
|
16
|
+
return `${options_1.SectionLevels.LEVEL.repeat(3)} ${options.formatMDXSpecifiedByLink(url)}${strings_1.MARKDOWN_EOP}`;
|
|
17
17
|
};
|
|
18
18
|
exports.printSpecification = printSpecification;
|
|
19
19
|
const printScalarMetadata = (type, options) => {
|
package/dist/mdx/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MDXSupportType } from "@graphql-markdown/types";
|
|
2
2
|
export declare const mdxDeclaration = "";
|
|
3
3
|
declare const defaultModule: MDXSupportType;
|
|
4
|
-
export declare const mdxModule: (mdxPackage?:
|
|
4
|
+
export declare const mdxModule: (mdxPackage?: Record<string, unknown>) => Promise<Readonly<MDXSupportType>>;
|
|
5
5
|
export default defaultModule;
|
package/dist/mdx/index.js
CHANGED
|
@@ -1,52 +1,18 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.mdxModule = exports.mdxDeclaration = void 0;
|
|
37
4
|
const strings_1 = require("../const/strings");
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
return `<mark class="gqlmd-mdx-badge">${text}</mark>`;
|
|
5
|
+
const formatMDXBadge = (badge) => {
|
|
6
|
+
return `<mark class="gqlmd-mdx-badge">${badge.text}</mark>`;
|
|
41
7
|
};
|
|
42
|
-
const formatMDXAdmonition = ({ text, title, type, icon },
|
|
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()}
|
|
8
|
+
const formatMDXAdmonition = ({ text, title, type, icon }, _meta) => {
|
|
9
|
+
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()} ${title}</span></legend>${strings_1.MARKDOWN_EOL}<span>${text}</span>${strings_1.MARKDOWN_EOL}</fieldset>`;
|
|
44
10
|
};
|
|
45
11
|
const formatMDXBullet = (text = "") => {
|
|
46
12
|
return `<span class="gqlmd-mdx-bullet"> ● </span>${text}`;
|
|
47
13
|
};
|
|
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
|
|
14
|
+
const formatMDXDetails = ({ dataOpen }) => {
|
|
15
|
+
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
16
|
};
|
|
51
17
|
const formatMDXSpecifiedByLink = (url) => {
|
|
52
18
|
return `<span class="gqlmd-mdx-specifiedby">Specification<a class="gqlmd-mdx-specifiedby-link" target="_blank" href="${url}" title="Specified by ${url}">⎘</a></span>`;
|
|
@@ -60,40 +26,39 @@ const formatMDXNameEntity = (name, parentType) => {
|
|
|
60
26
|
const formatMDXLink = (link) => {
|
|
61
27
|
return link;
|
|
62
28
|
};
|
|
29
|
+
const formatMDXFrontmatter = (_props, formatted) => {
|
|
30
|
+
return formatted
|
|
31
|
+
? [strings_1.FRONT_MATTER_DELIMITER, ...formatted, strings_1.FRONT_MATTER_DELIMITER].join(strings_1.MARKDOWN_EOL)
|
|
32
|
+
: "";
|
|
33
|
+
};
|
|
63
34
|
exports.mdxDeclaration = "";
|
|
64
35
|
const defaultModule = {
|
|
65
36
|
formatMDXAdmonition,
|
|
66
37
|
formatMDXBadge,
|
|
67
38
|
formatMDXBullet,
|
|
68
39
|
formatMDXDetails,
|
|
40
|
+
formatMDXFrontmatter,
|
|
69
41
|
formatMDXLink,
|
|
70
42
|
formatMDXNameEntity,
|
|
71
43
|
formatMDXSpecifiedByLink,
|
|
72
44
|
mdxDeclaration: exports.mdxDeclaration,
|
|
73
|
-
mdxSupport: false,
|
|
74
45
|
};
|
|
75
46
|
const mdxModule = async (mdxPackage) => {
|
|
76
47
|
if (!mdxPackage) {
|
|
77
48
|
return defaultModule;
|
|
78
49
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
});
|
|
50
|
+
const module = (mdxPackage.default ?? mdxPackage);
|
|
51
|
+
return {
|
|
52
|
+
formatMDXAdmonition: module.formatMDXAdmonition ?? formatMDXAdmonition,
|
|
53
|
+
formatMDXBadge: module.formatMDXBadge ?? formatMDXBadge,
|
|
54
|
+
formatMDXBullet: module.formatMDXBullet ?? formatMDXBullet,
|
|
55
|
+
formatMDXDetails: module.formatMDXDetails ?? formatMDXDetails,
|
|
56
|
+
formatMDXFrontmatter: module.formatMDXFrontmatter ?? formatMDXFrontmatter,
|
|
57
|
+
formatMDXLink: module.formatMDXLink ?? formatMDXLink,
|
|
58
|
+
formatMDXNameEntity: module.formatMDXNameEntity ?? formatMDXNameEntity,
|
|
59
|
+
formatMDXSpecifiedByLink: module.formatMDXSpecifiedByLink ?? formatMDXSpecifiedByLink,
|
|
60
|
+
mdxDeclaration: module.mdxDeclaration ?? exports.mdxDeclaration,
|
|
61
|
+
};
|
|
97
62
|
};
|
|
98
63
|
exports.mdxModule = mdxModule;
|
|
99
64
|
exports.default = defaultModule;
|
package/dist/printer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CustomDirectiveMap, GraphQLDirective, GraphQLSchema, IPrinter, MDXString, MDXSupportType, Maybe, MetaOptions,
|
|
1
|
+
import type { CustomDirectiveMap, GraphQLDirective, GraphQLSchema, IPrinter, MDXString, MDXSupportType, Maybe, MetaOptions, PrintTypeOptions, PrinterConfigPrintTypeOptions, SchemaEntitiesGroupMap, TypeDeprecatedOption } from "@graphql-markdown/types";
|
|
2
2
|
export declare class Printer implements IPrinter {
|
|
3
3
|
static options: Readonly<Maybe<PrintTypeOptions>>;
|
|
4
4
|
static readonly printDescription: (type: unknown, options: PrintTypeOptions, noText?: string) => MDXString | string;
|
|
@@ -14,7 +14,7 @@ export declare class Printer implements IPrinter {
|
|
|
14
14
|
onlyDocDirectives?: GraphQLDirective[];
|
|
15
15
|
printTypeOptions?: PrinterConfigPrintTypeOptions;
|
|
16
16
|
skipDocDirectives?: GraphQLDirective[];
|
|
17
|
-
}, mdxParser?:
|
|
17
|
+
}, mdxParser?: Record<string, unknown>): Promise<void>;
|
|
18
18
|
static readonly printHeader: (id: string, title: string, options: PrintTypeOptions) => string;
|
|
19
19
|
static readonly printCode: (type: unknown, options: PrintTypeOptions) => string;
|
|
20
20
|
static readonly printExample: (type: unknown, options: PrintTypeOptions) => string;
|
package/dist/printer.js
CHANGED
|
@@ -50,11 +50,11 @@ class Printer {
|
|
|
50
50
|
Printer.printMDXModule = await (0, mdx_1.mdxModule)(mdxParser);
|
|
51
51
|
}
|
|
52
52
|
static printHeader = (id, title, options) => {
|
|
53
|
-
if (
|
|
54
|
-
return
|
|
53
|
+
if (options.frontMatter === false) {
|
|
54
|
+
return `# ${title}${strings_1.MARKDOWN_EOP}`;
|
|
55
55
|
}
|
|
56
56
|
const fmOptions = options.frontMatter ?? options_1.DEFAULT_OPTIONS.frontMatter;
|
|
57
|
-
return (0, frontmatter_1.printFrontMatter)(
|
|
57
|
+
return (0, frontmatter_1.printFrontMatter)(title, { ...fmOptions, id }, options);
|
|
58
58
|
};
|
|
59
59
|
static printCode = (type, options) => {
|
|
60
60
|
let code = "";
|
|
@@ -102,7 +102,7 @@ class Printer {
|
|
|
102
102
|
if (!example) {
|
|
103
103
|
return "";
|
|
104
104
|
}
|
|
105
|
-
return `${options_1.SectionLevels.
|
|
105
|
+
return `${options_1.SectionLevels.LEVEL.repeat(3)} Example${strings_1.MARKDOWN_EOP}${strings_1.MARKDOWN_SOC}${example}${strings_1.MARKDOWN_EOC}${strings_1.MARKDOWN_EOP}`;
|
|
106
106
|
};
|
|
107
107
|
static printTypeMetadata = (type, options) => {
|
|
108
108
|
switch (true) {
|
|
@@ -174,7 +174,9 @@ class Printer {
|
|
|
174
174
|
metadata,
|
|
175
175
|
example,
|
|
176
176
|
relations,
|
|
177
|
-
]
|
|
177
|
+
]
|
|
178
|
+
.join(strings_1.MARKDOWN_EOP)
|
|
179
|
+
.trim();
|
|
178
180
|
};
|
|
179
181
|
}
|
|
180
182
|
exports.Printer = Printer;
|
package/dist/relation.js
CHANGED
|
@@ -35,7 +35,7 @@ const printRelationOf = (type, section, getRelation, options) => {
|
|
|
35
35
|
const category = (0, exports.getRootTypeLocaleFromString)(relation);
|
|
36
36
|
const badge = (0, badge_1.printBadge)({
|
|
37
37
|
text: category,
|
|
38
|
-
classname: badge_1.
|
|
38
|
+
classname: badge_1.CSS_BADGE_CLASSNAME.RELATION,
|
|
39
39
|
}, options);
|
|
40
40
|
data = data.concat(types.map((t) => {
|
|
41
41
|
const link = (0, link_1.getRelationLink)(category, t, options);
|
|
@@ -50,7 +50,7 @@ const printRelationOf = (type, section, getRelation, options) => {
|
|
|
50
50
|
return a.localeCompare(b);
|
|
51
51
|
})
|
|
52
52
|
.join(options.formatMDXBullet());
|
|
53
|
-
return `${options_1.SectionLevels.
|
|
53
|
+
return `${options_1.SectionLevels.LEVEL.repeat(3)} ${section}${strings_1.MARKDOWN_EOP}${content}${strings_1.MARKDOWN_EOP}`;
|
|
54
54
|
};
|
|
55
55
|
exports.printRelationOf = printRelationOf;
|
|
56
56
|
const printRelations = (type, options) => {
|
package/dist/section.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { MDXString, PrintTypeOptions
|
|
2
|
-
export declare const sectionLevels: SectionLevel[];
|
|
1
|
+
import type { MDXString, PrintTypeOptions } from "@graphql-markdown/types";
|
|
3
2
|
export declare const printSectionItem: <T>(type: T, options: PrintTypeOptions) => MDXString | string;
|
|
4
3
|
export declare const printSectionItems: <V>(values: V | V[], options: PrintTypeOptions) => MDXString | string;
|
|
5
4
|
export declare const printSection: <V>(values: 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.printMetadataSection = exports.printSection = exports.printSectionItems = exports.printSectionItem =
|
|
3
|
+
exports.printMetadataSection = exports.printSection = exports.printSectionItems = exports.printSectionItem = 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");
|
|
@@ -8,15 +8,8 @@ const link_1 = require("./link");
|
|
|
8
8
|
const directive_1 = require("./directive");
|
|
9
9
|
const strings_1 = require("./const/strings");
|
|
10
10
|
const options_1 = require("./const/options");
|
|
11
|
-
exports.sectionLevels = [
|
|
12
|
-
options_1.SectionLevels.LEVEL_3,
|
|
13
|
-
options_1.SectionLevels.LEVEL_4,
|
|
14
|
-
options_1.SectionLevels.LEVEL_5,
|
|
15
|
-
];
|
|
16
11
|
const printSectionItem = (type, options) => {
|
|
17
|
-
const level = "level" in options && typeof options.level === "
|
|
18
|
-
? options.level
|
|
19
|
-
: options_1.SectionLevels.LEVEL_4;
|
|
12
|
+
const level = "level" in options && typeof options.level === "number" ? options.level : 4;
|
|
20
13
|
if (!(0, link_1.hasPrintableDirective)(type, options)) {
|
|
21
14
|
return "";
|
|
22
15
|
}
|
|
@@ -27,7 +20,7 @@ const printSectionItem = (type, options) => {
|
|
|
27
20
|
const badges = (0, badge_1.printBadges)(type, options);
|
|
28
21
|
const tags = (0, directive_1.printCustomTags)(type, options);
|
|
29
22
|
const parentTypeLink = (0, link_1.printParentLink)(type, options);
|
|
30
|
-
const title = `${level} ${typeNameLink}${parentTypeLink} ${badges} ${tags}${strings_1.MARKDOWN_EOL}`;
|
|
23
|
+
const title = `${options_1.SectionLevels.LEVEL.repeat(level)} ${typeNameLink}${parentTypeLink} ${badges} ${tags}${strings_1.MARKDOWN_EOL}`;
|
|
31
24
|
const description = (0, common_1.printDescription)(type, options, "")
|
|
32
25
|
.trim()
|
|
33
26
|
.replaceAll("\n", `${strings_1.MARKDOWN_EOL}`);
|
|
@@ -36,7 +29,7 @@ const printSectionItem = (type, options) => {
|
|
|
36
29
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
37
30
|
section += (0, exports.printSectionItems)(type.args, {
|
|
38
31
|
...options,
|
|
39
|
-
level:
|
|
32
|
+
level: 5,
|
|
40
33
|
parentType: typeof options.parentType === "undefined"
|
|
41
34
|
? type.name
|
|
42
35
|
: `${options.parentType}.${type.name}`,
|
|
@@ -49,9 +42,7 @@ const printSectionItems = (values, options) => {
|
|
|
49
42
|
if (!Array.isArray(values) || values.length === 0) {
|
|
50
43
|
return "";
|
|
51
44
|
}
|
|
52
|
-
const level = ("level" in options && typeof options.level === "
|
|
53
|
-
? options.level
|
|
54
|
-
: options_1.SectionLevels.LEVEL_4);
|
|
45
|
+
const level = ("level" in options && typeof options.level === "number" ? options.level : 4);
|
|
55
46
|
return values
|
|
56
47
|
.map((v) => {
|
|
57
48
|
return (v &&
|
|
@@ -67,10 +58,7 @@ const printSection = (values, section, options) => {
|
|
|
67
58
|
if (!Array.isArray(values) || values.length === 0) {
|
|
68
59
|
return "";
|
|
69
60
|
}
|
|
70
|
-
const level = ("level" in options && typeof options.level === "
|
|
71
|
-
? options.level
|
|
72
|
-
: options_1.SectionLevels.LEVEL_3);
|
|
73
|
-
const levelPosition = exports.sectionLevels.indexOf(level);
|
|
61
|
+
const level = ("level" in options && typeof options.level === "number" ? options.level : 3);
|
|
74
62
|
const [openSection, closeSection] = (() => {
|
|
75
63
|
if (typeof options.collapsible?.dataOpen === "string" &&
|
|
76
64
|
typeof options.collapsible.dataClose === "string") {
|
|
@@ -81,14 +69,12 @@ const printSection = (values, section, options) => {
|
|
|
81
69
|
const items = (0, exports.printSectionItems)(values, {
|
|
82
70
|
...options,
|
|
83
71
|
collapsible: undefined, // do not propagate collapsible
|
|
84
|
-
level: (
|
|
85
|
-
? exports.sectionLevels[levelPosition + 1]
|
|
86
|
-
: undefined),
|
|
72
|
+
level: level >= 3 && level <= 5 ? (level + 1) : undefined,
|
|
87
73
|
});
|
|
88
74
|
if (items === "") {
|
|
89
75
|
return ""; // do not print section is no items printed
|
|
90
76
|
}
|
|
91
|
-
return `${level} ${section}${openSection}${items}${closeSection}`;
|
|
77
|
+
return `${options_1.SectionLevels.LEVEL.repeat(level)} ${section}${openSection}${items}${closeSection}`;
|
|
92
78
|
};
|
|
93
79
|
exports.printSection = printSection;
|
|
94
80
|
const printMetadataSection = (type, values, section, options) => {
|
|
@@ -117,7 +103,7 @@ const printMetadataSection = (type, values, section, options) => {
|
|
|
117
103
|
const deprecatedMeta = (0, exports.printSection)(deprecated, "", {
|
|
118
104
|
...options,
|
|
119
105
|
parentType: type.name,
|
|
120
|
-
level:
|
|
106
|
+
level: 0,
|
|
121
107
|
collapsible: {
|
|
122
108
|
dataOpen: strings_1.DEPRECATED,
|
|
123
109
|
dataClose: strings_1.DEPRECATED,
|
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.12.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -56,12 +56,11 @@
|
|
|
56
56
|
"docs": "typedoc"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@graphql-markdown/graphql": "^1.1.
|
|
60
|
-
"@graphql-markdown/
|
|
61
|
-
"@graphql-markdown/utils": "^1.7.1"
|
|
59
|
+
"@graphql-markdown/graphql": "^1.1.6",
|
|
60
|
+
"@graphql-markdown/utils": "^1.8.0"
|
|
62
61
|
},
|
|
63
62
|
"devDependencies": {
|
|
64
|
-
"@graphql-markdown/types": "^1.
|
|
63
|
+
"@graphql-markdown/types": "^1.7.0"
|
|
65
64
|
},
|
|
66
65
|
"resolutions": {
|
|
67
66
|
"micromatch": "4.0.8"
|