@graphql-markdown/core 1.8.0 → 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.js +3 -0
- 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.js
CHANGED
|
@@ -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",
|
|
@@ -165,6 +166,8 @@ const getPrintTypeOptions = (cliOpts, configOptions) => {
|
|
|
165
166
|
exports.DEFAULT_OPTIONS.printTypeOptions.relatedTypeSection,
|
|
166
167
|
typeBadges: (!cliOpts?.noTypeBadges && configOptions?.typeBadges) ??
|
|
167
168
|
exports.DEFAULT_OPTIONS.printTypeOptions.typeBadges,
|
|
169
|
+
useApiGroup: (!cliOpts?.noApiGroup && configOptions?.useApiGroup) ??
|
|
170
|
+
exports.DEFAULT_OPTIONS.printTypeOptions.useApiGroup,
|
|
168
171
|
};
|
|
169
172
|
};
|
|
170
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": {
|