@graphql-markdown/docusaurus 1.27.0 → 1.29.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/index.d.ts +2 -2
- package/dist/index.js +10 -49
- package/dist/mdx/category.d.ts +2 -0
- package/dist/mdx/category.js +31 -0
- package/dist/mdx/components.d.ts +2 -0
- package/dist/mdx/components.js +32 -0
- package/dist/mdx/index.d.ts +10 -0
- package/dist/mdx/index.js +49 -0
- package/package.json +20 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { LoadContext, Plugin, PluginOptions } from "@docusaurus/types";
|
|
2
|
-
import type {
|
|
3
|
-
export default function pluginGraphQLDocGenerator(_: LoadContext, options:
|
|
2
|
+
import type { GraphQLMarkdownCliOptions } from "@graphql-markdown/types";
|
|
3
|
+
export default function pluginGraphQLDocGenerator(_: LoadContext, options: GraphQLMarkdownCliOptions & Partial<PluginOptions>): Promise<Plugin>;
|
package/dist/index.js
CHANGED
|
@@ -5,68 +5,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = pluginGraphQLDocGenerator;
|
|
7
7
|
const utils_1 = require("@docusaurus/utils");
|
|
8
|
-
const
|
|
8
|
+
const cli_1 = require("@graphql-markdown/cli");
|
|
9
9
|
const logger_1 = __importDefault(require("@graphql-markdown/logger"));
|
|
10
10
|
const NAME = "docusaurus-graphql-doc-generator";
|
|
11
|
-
const COMMAND = "graphql-to-doc";
|
|
12
|
-
const DESCRIPTION = "Generate GraphQL Schema Documentation";
|
|
13
|
-
const DEFAULT_ID = "default";
|
|
14
11
|
const LOGGER_MODULE = "@docusaurus/logger";
|
|
12
|
+
const MDX_PACKAGE = "@graphql-markdown/docusaurus/mdx";
|
|
15
13
|
async function pluginGraphQLDocGenerator(_, options) {
|
|
16
14
|
await (0, logger_1.default)(LOGGER_MODULE);
|
|
17
|
-
const isDefaultId = options.id === DEFAULT_ID;
|
|
18
|
-
const command = isDefaultId ? COMMAND : `${COMMAND}:${options.id}`;
|
|
19
|
-
const description = isDefaultId
|
|
20
|
-
? DESCRIPTION
|
|
21
|
-
: `${DESCRIPTION} for configuration with id ${options.id}`;
|
|
22
15
|
return {
|
|
23
16
|
name: NAME,
|
|
24
17
|
async loadContent() {
|
|
25
18
|
if (options.runOnBuild !== true) {
|
|
26
19
|
return;
|
|
27
20
|
}
|
|
28
|
-
|
|
29
|
-
await (0, core_1.generateDocFromSchema)({
|
|
30
|
-
...config,
|
|
31
|
-
loggerModule: LOGGER_MODULE,
|
|
32
|
-
});
|
|
21
|
+
await (0, cli_1.runGraphQLMarkdown)(options, {}, LOGGER_MODULE);
|
|
33
22
|
},
|
|
34
23
|
extendCli(cli) {
|
|
35
|
-
cli
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.option("-h, --homepage <homepage>", "File location for doc landing page")
|
|
43
|
-
.option("--hierarchy <hierarchy>", "Schema entity hierarchy: `api`, `entity`, `flat`")
|
|
44
|
-
.option("--noCode", "Disable code section for types")
|
|
45
|
-
.option("--noExample", "Disable example section for types")
|
|
46
|
-
.option("--noParentType", "Disable parent type name as field prefix")
|
|
47
|
-
.option("--noRelatedType", "Disable related types sections")
|
|
48
|
-
.option("--noTypeBadges", "Disable badges for types")
|
|
49
|
-
.option("--index", "Enable generated index for categories")
|
|
50
|
-
.option("-f, --force", "Force document generation")
|
|
51
|
-
.option("-d, --diff <diffMethod>", "Set diff method")
|
|
52
|
-
.option("-t, --tmp <tmpDir>", "Set temp dir for schema diff")
|
|
53
|
-
.option("-gbd, --groupByDirective <@directive(field|=fallback)>", "Group documentation by directive")
|
|
54
|
-
.option("--only <@directive...>", "Only print types with matching directive")
|
|
55
|
-
.option("--skip <@directive...>", "Skip types with matching directive")
|
|
56
|
-
.option("--deprecated <option>", "Option for printing deprecated entities: `default`, `group` or `skip`")
|
|
57
|
-
.option("--pretty", "Prettify generated files")
|
|
58
|
-
.action(async (cliOptions) => {
|
|
59
|
-
const config = await (0, core_1.buildConfig)(options, cliOptions, options.id);
|
|
60
|
-
await (0, core_1.generateDocFromSchema)({
|
|
61
|
-
...config,
|
|
62
|
-
docOptions: {
|
|
63
|
-
...config.docOptions,
|
|
64
|
-
generatorFrameworkName: "docusaurus",
|
|
65
|
-
generatorFrameworkVersion: utils_1.DOCUSAURUS_VERSION,
|
|
66
|
-
},
|
|
67
|
-
loggerModule: LOGGER_MODULE,
|
|
68
|
-
});
|
|
69
|
-
});
|
|
24
|
+
cli.addCommand((0, cli_1.getGraphQLMarkdownCli)({
|
|
25
|
+
...options,
|
|
26
|
+
docOptions: {
|
|
27
|
+
generatorFrameworkName: "docusaurus",
|
|
28
|
+
generatorFrameworkVersion: utils_1.DOCUSAURUS_VERSION,
|
|
29
|
+
},
|
|
30
|
+
}, LOGGER_MODULE, MDX_PACKAGE));
|
|
70
31
|
},
|
|
71
32
|
};
|
|
72
33
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateIndexMetafile = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const utils_1 = require("@graphql-markdown/utils");
|
|
6
|
+
const CATEGORY_YAML = "_category_.yml";
|
|
7
|
+
var SidebarPosition;
|
|
8
|
+
(function (SidebarPosition) {
|
|
9
|
+
SidebarPosition[SidebarPosition["FIRST"] = 1] = "FIRST";
|
|
10
|
+
SidebarPosition[SidebarPosition["LAST"] = 999] = "LAST";
|
|
11
|
+
})(SidebarPosition || (SidebarPosition = {}));
|
|
12
|
+
const generateIndexMetafile = async (dirPath, category, options) => {
|
|
13
|
+
const filePath = (0, node_path_1.join)(dirPath, CATEGORY_YAML);
|
|
14
|
+
if (await (0, utils_1.fileExists)(filePath)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const label = (0, utils_1.startCase)(category);
|
|
18
|
+
const link = options?.index !== true
|
|
19
|
+
? "null"
|
|
20
|
+
: `\n type: generated-index\n title: '${label} overview'`;
|
|
21
|
+
const className = typeof options?.styleClass === "string"
|
|
22
|
+
? `className: ${options.styleClass}\n`
|
|
23
|
+
: "";
|
|
24
|
+
const position = typeof options?.sidebarPosition === "number"
|
|
25
|
+
? options.sidebarPosition
|
|
26
|
+
: SidebarPosition.FIRST;
|
|
27
|
+
const content = `label: ${label}\nposition: ${position}\n${className}link: ${link}\ncollapsible: ${options?.collapsible ?? true}\ncollapsed: ${options?.collapsed ?? true}\n`;
|
|
28
|
+
await (0, utils_1.ensureDir)(dirPath);
|
|
29
|
+
await (0, utils_1.saveFile)(filePath, content);
|
|
30
|
+
};
|
|
31
|
+
exports.generateIndexMetafile = generateIndexMetafile;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mdxDeclaration = void 0;
|
|
4
|
+
exports.mdxDeclaration = `
|
|
5
|
+
export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em', color: 'var(--ifm-color-secondary-darkest)' }}> ● </span></>
|
|
6
|
+
|
|
7
|
+
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></>
|
|
8
|
+
|
|
9
|
+
export const Badge = (props) => <><span className={props.class}>{props.text}</span></>
|
|
10
|
+
|
|
11
|
+
import { useState } from 'react';
|
|
12
|
+
|
|
13
|
+
export const Details = ({ dataOpen, dataClose, children, startOpen = false }) => {
|
|
14
|
+
const [open, setOpen] = useState(startOpen);
|
|
15
|
+
return (
|
|
16
|
+
<details {...(open ? { open: true } : {})} className="details" style={{ border:'none', boxShadow:'none', background:'var(--ifm-background-color)' }}>
|
|
17
|
+
<summary
|
|
18
|
+
onClick={(e) => {
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
setOpen((open) => !open);
|
|
21
|
+
}}
|
|
22
|
+
style={{ listStyle:'none' }}
|
|
23
|
+
>
|
|
24
|
+
{open ? dataOpen : dataClose}
|
|
25
|
+
</summary>
|
|
26
|
+
{open && children}
|
|
27
|
+
</details>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AdmonitionType, Badge, CollapsibleOption, Maybe, MDXString, MetaOptions, TypeLink } from "@graphql-markdown/types";
|
|
2
|
+
export { mdxDeclaration } from "./components";
|
|
3
|
+
export { generateIndexMetafile } from "./category";
|
|
4
|
+
export declare const formatMDXBadge: ({ text, classname }: Badge) => MDXString;
|
|
5
|
+
export declare const formatMDXAdmonition: ({ text, title, type }: AdmonitionType, meta: Maybe<MetaOptions>) => MDXString;
|
|
6
|
+
export declare const formatMDXBullet: (text?: string) => MDXString;
|
|
7
|
+
export declare const formatMDXDetails: ({ dataOpen, dataClose, }: CollapsibleOption) => MDXString;
|
|
8
|
+
export declare const formatMDXSpecifiedByLink: (url: string) => MDXString;
|
|
9
|
+
export declare const formatMDXNameEntity: (name: string, parentType?: Maybe<string>) => MDXString;
|
|
10
|
+
export declare const formatMDXLink: ({ text, url }: TypeLink) => TypeLink;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatMDXLink = exports.formatMDXNameEntity = exports.formatMDXSpecifiedByLink = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.generateIndexMetafile = exports.mdxDeclaration = void 0;
|
|
4
|
+
const MARKDOWN_EOL = "\n";
|
|
5
|
+
const MARKDOWN_EOP = `${MARKDOWN_EOL.repeat(2)}`;
|
|
6
|
+
const LINK_MDX_EXTENSION = ".mdx";
|
|
7
|
+
const DEFAULT_CSS_CLASSNAME = "badge--secondary";
|
|
8
|
+
var components_1 = require("./components");
|
|
9
|
+
Object.defineProperty(exports, "mdxDeclaration", { enumerable: true, get: function () { return components_1.mdxDeclaration; } });
|
|
10
|
+
var category_1 = require("./category");
|
|
11
|
+
Object.defineProperty(exports, "generateIndexMetafile", { enumerable: true, get: function () { return category_1.generateIndexMetafile; } });
|
|
12
|
+
const formatMDXBadge = ({ text, classname }) => {
|
|
13
|
+
const style = typeof classname === "string" ? `badge--${classname.toLowerCase()}` : "";
|
|
14
|
+
return `<Badge class="badge ${DEFAULT_CSS_CLASSNAME} ${style}" text="${text}"/>`;
|
|
15
|
+
};
|
|
16
|
+
exports.formatMDXBadge = formatMDXBadge;
|
|
17
|
+
const formatMDXAdmonition = ({ text, title, type }, meta) => {
|
|
18
|
+
const isDocusaurus = meta?.generatorFrameworkName === "docusaurus";
|
|
19
|
+
if (isDocusaurus && meta.generatorFrameworkVersion?.startsWith("2")) {
|
|
20
|
+
const oldType = type === "warning" ? "caution" : type;
|
|
21
|
+
return `${MARKDOWN_EOP}:::${oldType} ${title}${text}:::`;
|
|
22
|
+
}
|
|
23
|
+
return `${MARKDOWN_EOP}:::${type}[${title}]${text}:::`;
|
|
24
|
+
};
|
|
25
|
+
exports.formatMDXAdmonition = formatMDXAdmonition;
|
|
26
|
+
const formatMDXBullet = (text = "") => {
|
|
27
|
+
return `<Bullet />${text}`;
|
|
28
|
+
};
|
|
29
|
+
exports.formatMDXBullet = formatMDXBullet;
|
|
30
|
+
const formatMDXDetails = ({ dataOpen, dataClose, }) => {
|
|
31
|
+
return `${MARKDOWN_EOP}<Details dataOpen="Hide ${dataOpen}" dataClose="Show ${dataClose}">${MARKDOWN_EOP}\r${MARKDOWN_EOP}</Details>${MARKDOWN_EOP}`;
|
|
32
|
+
};
|
|
33
|
+
exports.formatMDXDetails = formatMDXDetails;
|
|
34
|
+
const formatMDXSpecifiedByLink = (url) => {
|
|
35
|
+
return `<SpecifiedBy url="${url}"/>`;
|
|
36
|
+
};
|
|
37
|
+
exports.formatMDXSpecifiedByLink = formatMDXSpecifiedByLink;
|
|
38
|
+
const formatMDXNameEntity = (name, parentType) => {
|
|
39
|
+
const parentName = parentType ? `${parentType}.` : "";
|
|
40
|
+
return `<code style={{ fontWeight: 'normal' }}>${parentName}<b>${name}</b></code>`;
|
|
41
|
+
};
|
|
42
|
+
exports.formatMDXNameEntity = formatMDXNameEntity;
|
|
43
|
+
const formatMDXLink = ({ text, url }) => {
|
|
44
|
+
return {
|
|
45
|
+
text,
|
|
46
|
+
url: `${url}${LINK_MDX_EXTENSION}`,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
exports.formatMDXLink = formatMDXLink;
|
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.29.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -41,6 +41,20 @@
|
|
|
41
41
|
"default": "./dist/index.js"
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
+
"./mdx": {
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/mdx/index.d.ts",
|
|
47
|
+
"default": "./dist/mdx/index.js"
|
|
48
|
+
},
|
|
49
|
+
"import": {
|
|
50
|
+
"types": "./dist/mdx/index.d.ts",
|
|
51
|
+
"default": "./dist/mdx/index.js"
|
|
52
|
+
},
|
|
53
|
+
"default": {
|
|
54
|
+
"types": "./dist/mdx/index.d.ts",
|
|
55
|
+
"default": "./dist/mdx/index.js"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
44
58
|
"./package.json": "./package.json"
|
|
45
59
|
},
|
|
46
60
|
"scripts": {
|
|
@@ -51,14 +65,14 @@
|
|
|
51
65
|
"docs": "typedoc"
|
|
52
66
|
},
|
|
53
67
|
"dependencies": {
|
|
54
|
-
"@
|
|
55
|
-
"@graphql-markdown/core": "^1.13.0",
|
|
68
|
+
"@graphql-markdown/cli": "^0.3.0",
|
|
56
69
|
"@graphql-markdown/logger": "^1.0.5",
|
|
57
|
-
"@graphql-markdown/
|
|
70
|
+
"@graphql-markdown/utils": "^1.8.0",
|
|
71
|
+
"@docusaurus/utils": ">=3.2.0"
|
|
58
72
|
},
|
|
59
73
|
"devDependencies": {
|
|
60
|
-
"@docusaurus/types": "^3.
|
|
61
|
-
"@graphql-markdown/types": "^1.
|
|
74
|
+
"@docusaurus/types": "^3.7.0",
|
|
75
|
+
"@graphql-markdown/types": "^1.7.0"
|
|
62
76
|
},
|
|
63
77
|
"peerDependencies": {
|
|
64
78
|
"@docusaurus/logger": "*"
|