@graphql-markdown/core 1.7.3 → 1.9.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/config.d.ts +7 -2
- package/dist/config.js +32 -7
- package/dist/generator.js +1 -0
- package/dist/renderer.d.ts +7 -8
- package/dist/renderer.js +14 -5
- package/package.json +8 -8
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CliOptions, ConfigDocOptions, ConfigOptions, ConfigPrintTypeOptions, CustomDirective, DirectiveName, GroupByDirectiveOptions, LoaderOption, Maybe, Options, TypeDiffMethod } from "@graphql-markdown/types";
|
|
1
|
+
import type { CliOptions, ConfigDocOptions, ConfigOptions, ConfigPrintTypeOptions, CustomDirective, DeprecatedCliOptions, DeprecatedConfigDocOptions, DirectiveName, GroupByDirectiveOptions, LoaderOption, Maybe, Options, TypeDiffMethod } from "@graphql-markdown/types";
|
|
2
2
|
export declare enum DiffMethod {
|
|
3
3
|
NONE = "NONE",
|
|
4
4
|
FORCE = "FORCE"
|
|
@@ -26,7 +26,12 @@ export declare const getVisibilityDirectives: (cliOpts: Maybe<CliOptions>, confi
|
|
|
26
26
|
};
|
|
27
27
|
export declare const getCustomDirectives: (customDirectiveOptions: Maybe<CustomDirective>, skipDocDirective?: Maybe<DirectiveName[]>) => Maybe<CustomDirective>;
|
|
28
28
|
export declare const getDiffMethod: (diff: TypeDiffMethod, force?: boolean) => TypeDiffMethod;
|
|
29
|
-
export declare const
|
|
29
|
+
export declare const parseDeprecatedDocOptions: (cliOpts: Maybe<DeprecatedCliOptions>, configOptions: Maybe<DeprecatedConfigDocOptions>) => Partial<{
|
|
30
|
+
pagination_next: null;
|
|
31
|
+
pagination_prev: null;
|
|
32
|
+
hide_table_of_contents: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
export declare const getDocOptions: (cliOpts?: Maybe<CliOptions & DeprecatedCliOptions>, configOptions?: Maybe<ConfigDocOptions & DeprecatedConfigDocOptions>) => Required<ConfigDocOptions>;
|
|
30
35
|
export declare const getPrintTypeOptions: (cliOpts: Maybe<CliOptions>, configOptions: Maybe<ConfigPrintTypeOptions>) => Required<ConfigPrintTypeOptions>;
|
|
31
36
|
export declare const parseGroupByOption: (groupOptions: unknown) => Maybe<GroupByDirectiveOptions>;
|
|
32
37
|
export declare const buildConfig: (configFileOpts: Maybe<ConfigOptions>, cliOpts: Maybe<CliOptions>, id?: Maybe<string>) => Promise<Options>;
|
package/dist/config.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildConfig = exports.parseGroupByOption = exports.getPrintTypeOptions = exports.getDocOptions = exports.getDiffMethod = exports.getCustomDirectives = exports.getVisibilityDirectives = exports.getSkipDocDirectives = exports.getOnlyDocDirectives = exports.getDocDirective = exports.DEFAULT_OPTIONS = exports.ASSET_HOMEPAGE_LOCATION = exports.PACKAGE_NAME = exports.DOCS_URL = exports.DeprecatedOption = exports.DiffMethod = void 0;
|
|
3
|
+
exports.buildConfig = exports.parseGroupByOption = exports.getPrintTypeOptions = exports.getDocOptions = exports.parseDeprecatedDocOptions = exports.getDiffMethod = exports.getCustomDirectives = exports.getVisibilityDirectives = exports.getSkipDocDirectives = exports.getOnlyDocDirectives = exports.getDocDirective = exports.DEFAULT_OPTIONS = exports.ASSET_HOMEPAGE_LOCATION = exports.PACKAGE_NAME = exports.DOCS_URL = exports.DeprecatedOption = exports.DiffMethod = void 0;
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
5
|
const node_os_1 = require("node:os");
|
|
6
6
|
const graphql_config_1 = require("./graphql-config");
|
|
7
|
+
const logger_1 = require("@graphql-markdown/logger");
|
|
7
8
|
var DiffMethod;
|
|
8
9
|
(function (DiffMethod) {
|
|
9
10
|
DiffMethod["NONE"] = "NONE";
|
|
@@ -25,8 +26,7 @@ exports.DEFAULT_OPTIONS = {
|
|
|
25
26
|
diffMethod: DiffMethod.NONE,
|
|
26
27
|
docOptions: {
|
|
27
28
|
index: false,
|
|
28
|
-
|
|
29
|
-
toc: true,
|
|
29
|
+
frontMatter: {},
|
|
30
30
|
},
|
|
31
31
|
groupByDirective: undefined,
|
|
32
32
|
homepage: exports.ASSET_HOMEPAGE_LOCATION,
|
|
@@ -41,6 +41,7 @@ exports.DEFAULT_OPTIONS = {
|
|
|
41
41
|
parentTypePrefix: true,
|
|
42
42
|
relatedTypeSection: true,
|
|
43
43
|
typeBadges: true,
|
|
44
|
+
useApiGroup: true,
|
|
44
45
|
},
|
|
45
46
|
rootPath: "./docs",
|
|
46
47
|
schema: "./schema.graphql",
|
|
@@ -117,16 +118,38 @@ const getDiffMethod = (diff, force = false) => {
|
|
|
117
118
|
: diff.toLocaleUpperCase();
|
|
118
119
|
};
|
|
119
120
|
exports.getDiffMethod = getDiffMethod;
|
|
121
|
+
const parseDeprecatedDocOptions = (cliOpts, configOptions) => {
|
|
122
|
+
// deprecated, replaced by frontMatter
|
|
123
|
+
let pagination;
|
|
124
|
+
if ((typeof cliOpts?.noPagination !== "undefined" && cliOpts.noPagination) ||
|
|
125
|
+
(typeof configOptions?.pagination !== "undefined" &&
|
|
126
|
+
!configOptions.pagination)) {
|
|
127
|
+
pagination = { pagination_next: null, pagination_prev: null };
|
|
128
|
+
(0, logger_1.log)("Doc option `pagination` is deprecated. Use `frontMatter: { pagination_next: null, pagination_prev: null }` instead.", "warn");
|
|
129
|
+
}
|
|
130
|
+
// deprecated, replaced by frontMatter
|
|
131
|
+
let toc;
|
|
132
|
+
if (typeof cliOpts?.noToc !== "undefined" ||
|
|
133
|
+
typeof configOptions?.toc !== "undefined") {
|
|
134
|
+
toc = {
|
|
135
|
+
hide_table_of_contents: cliOpts?.noToc === true || configOptions?.toc === false,
|
|
136
|
+
};
|
|
137
|
+
(0, logger_1.log)("Doc option `toc` is deprecated. Use `frontMatter: { hide_table_of_contents: true | false }` instead.", "warn");
|
|
138
|
+
}
|
|
139
|
+
return { ...pagination, ...toc };
|
|
140
|
+
};
|
|
141
|
+
exports.parseDeprecatedDocOptions = parseDeprecatedDocOptions;
|
|
120
142
|
const getDocOptions = (cliOpts, configOptions) => {
|
|
143
|
+
const deprecated = (0, exports.parseDeprecatedDocOptions)(cliOpts, configOptions);
|
|
121
144
|
return {
|
|
122
|
-
pagination: (!cliOpts?.noPagination && configOptions?.pagination) ??
|
|
123
|
-
exports.DEFAULT_OPTIONS.docOptions.pagination,
|
|
124
|
-
toc: (!cliOpts?.noToc && configOptions?.toc) ??
|
|
125
|
-
exports.DEFAULT_OPTIONS.docOptions.toc,
|
|
126
145
|
index:
|
|
127
146
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
128
147
|
(cliOpts?.index || configOptions?.index) ??
|
|
129
148
|
exports.DEFAULT_OPTIONS.docOptions.index,
|
|
149
|
+
frontMatter: {
|
|
150
|
+
...deprecated,
|
|
151
|
+
...configOptions?.frontMatter,
|
|
152
|
+
},
|
|
130
153
|
};
|
|
131
154
|
};
|
|
132
155
|
exports.getDocOptions = getDocOptions;
|
|
@@ -143,6 +166,8 @@ const getPrintTypeOptions = (cliOpts, configOptions) => {
|
|
|
143
166
|
exports.DEFAULT_OPTIONS.printTypeOptions.relatedTypeSection,
|
|
144
167
|
typeBadges: (!cliOpts?.noTypeBadges && configOptions?.typeBadges) ??
|
|
145
168
|
exports.DEFAULT_OPTIONS.printTypeOptions.typeBadges,
|
|
169
|
+
useApiGroup: (!cliOpts?.noApiGroup && configOptions?.useApiGroup) ??
|
|
170
|
+
exports.DEFAULT_OPTIONS.printTypeOptions.useApiGroup,
|
|
146
171
|
};
|
|
147
172
|
};
|
|
148
173
|
exports.getPrintTypeOptions = getPrintTypeOptions;
|
package/dist/generator.js
CHANGED
|
@@ -60,6 +60,7 @@ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, doc
|
|
|
60
60
|
const renderer = new renderer_1.Renderer(printer, outputDir, baseURL, groups, prettify, {
|
|
61
61
|
...docOptions,
|
|
62
62
|
deprecated: printTypeOptions.deprecated,
|
|
63
|
+
useApiGroup: printTypeOptions.useApiGroup,
|
|
63
64
|
});
|
|
64
65
|
const pages = await Promise.all(Object.keys(rootTypes).map(async (typeName) => {
|
|
65
66
|
return renderer.renderRootTypes(typeName, rootTypes[typeName]);
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import type { Category,
|
|
1
|
+
import type { Category, Maybe, Printer, RendererDocOptions, SchemaEntitiesGroupMap, SchemaEntity } from "@graphql-markdown/types";
|
|
2
2
|
export declare class Renderer {
|
|
3
3
|
group: Maybe<SchemaEntitiesGroupMap>;
|
|
4
4
|
outputDir: string;
|
|
5
5
|
baseURL: string;
|
|
6
6
|
prettify: boolean;
|
|
7
|
-
options: Maybe<
|
|
8
|
-
deprecated: TypeDeprecatedOption;
|
|
9
|
-
}>;
|
|
7
|
+
options: Maybe<RendererDocOptions>;
|
|
10
8
|
private readonly printer;
|
|
11
|
-
constructor(printer: Printer, outputDir: string, baseURL: string, group: Maybe<SchemaEntitiesGroupMap>, prettify: boolean, docOptions: Maybe<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
constructor(printer: Printer, outputDir: string, baseURL: string, group: Maybe<SchemaEntitiesGroupMap>, prettify: boolean, docOptions: Maybe<RendererDocOptions>);
|
|
10
|
+
generateCategoryMetafile(category: string, dirPath: string, sidebarPosition?: number, styleClass?: string, options?: {
|
|
11
|
+
collapsible: boolean;
|
|
12
|
+
collapsed: boolean;
|
|
13
|
+
}): Promise<void>;
|
|
15
14
|
generateCategoryMetafileType(type: unknown, name: string, rootTypeName: SchemaEntity): Promise<string>;
|
|
16
15
|
renderRootTypes(rootTypeName: SchemaEntity, type: unknown): Promise<Maybe<Maybe<Category>[]>>;
|
|
17
16
|
renderTypeEntities(dirPath: string, name: string, type: unknown): Promise<Maybe<Category>>;
|
package/dist/renderer.js
CHANGED
|
@@ -27,7 +27,10 @@ class Renderer {
|
|
|
27
27
|
this.prettify = prettify;
|
|
28
28
|
this.options = docOptions;
|
|
29
29
|
}
|
|
30
|
-
async generateCategoryMetafile(category, dirPath, sidebarPosition
|
|
30
|
+
async generateCategoryMetafile(category, dirPath, sidebarPosition, styleClass, options = {
|
|
31
|
+
collapsible: true,
|
|
32
|
+
collapsed: true,
|
|
33
|
+
}) {
|
|
31
34
|
const filePath = (0, node_path_1.join)(dirPath, CATEGORY_YAML);
|
|
32
35
|
if (await (0, utils_1.fileExists)(filePath)) {
|
|
33
36
|
return;
|
|
@@ -38,13 +41,19 @@ class Renderer {
|
|
|
38
41
|
? "null"
|
|
39
42
|
: `\n type: generated-index\n title: '${label} overview'`;
|
|
40
43
|
const className = typeof styleClass === "string" ? `className: ${styleClass}\n` : "";
|
|
41
|
-
|
|
44
|
+
const position = typeof sidebarPosition === "number"
|
|
45
|
+
? sidebarPosition
|
|
46
|
+
: SidebarPosition.FIRST;
|
|
47
|
+
await (0, utils_1.saveFile)(filePath, `label: ${label}\nposition: ${position}\n${className}link: ${link}\ncollapsible: ${options.collapsible}\ncollapsed: ${options.collapsed}\n`);
|
|
42
48
|
}
|
|
43
49
|
async generateCategoryMetafileType(type, name, rootTypeName) {
|
|
44
50
|
let dirPath = this.outputDir;
|
|
45
|
-
if (this.options
|
|
46
|
-
|
|
47
|
-
(0,
|
|
51
|
+
if (this.options?.useApiGroup === true) {
|
|
52
|
+
const typeCat = (0, graphql_1.isApiType)(type) ? "api" : "types";
|
|
53
|
+
dirPath = (0, node_path_1.join)(dirPath, (0, utils_1.slugify)(typeCat));
|
|
54
|
+
await this.generateCategoryMetafile(typeCat, dirPath, undefined, "graphql-markdown-api-section", { collapsible: false, collapsed: false });
|
|
55
|
+
}
|
|
56
|
+
if (this.options?.deprecated === "group" && (0, graphql_1.isDeprecated)(type)) {
|
|
48
57
|
dirPath = (0, node_path_1.join)(dirPath, (0, utils_1.slugify)("deprecated"));
|
|
49
58
|
await this.generateCategoryMetafile("deprecated", dirPath, SidebarPosition.LAST, "deprecated");
|
|
50
59
|
}
|
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.9.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -62,18 +62,18 @@
|
|
|
62
62
|
"clean": "rm -rf ./dist"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@graphql-markdown/graphql": "^1.0
|
|
66
|
-
"@graphql-markdown/logger": "^1.0.
|
|
67
|
-
"@graphql-markdown/utils": "^1.6.
|
|
65
|
+
"@graphql-markdown/graphql": "^1.1.0",
|
|
66
|
+
"@graphql-markdown/logger": "^1.0.2",
|
|
67
|
+
"@graphql-markdown/utils": "^1.6.3"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@graphql-markdown/diff": "^1.1.
|
|
71
|
-
"@graphql-markdown/helpers": "^1.0.
|
|
72
|
-
"@graphql-markdown/printer-legacy": "^1.
|
|
70
|
+
"@graphql-markdown/diff": "^1.1.3",
|
|
71
|
+
"@graphql-markdown/helpers": "^1.0.3",
|
|
72
|
+
"@graphql-markdown/printer-legacy": "^1.7.0",
|
|
73
73
|
"graphql-config": "^5.0.3"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@graphql-markdown/types": "^1.
|
|
76
|
+
"@graphql-markdown/types": "^1.2.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependenciesMeta": {
|
|
79
79
|
"@graphql-markdown/printer-legacy": {
|