@graphql-markdown/docusaurus 1.27.0 → 1.28.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 CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { LoadContext, Plugin, PluginOptions } from "@docusaurus/types";
2
- import type { ConfigOptions, ExperimentalConfigOptions } from "@graphql-markdown/types";
3
- export default function pluginGraphQLDocGenerator(_: LoadContext, options: ConfigOptions & ExperimentalConfigOptions & Partial<PluginOptions>): Promise<Plugin>;
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 core_1 = require("@graphql-markdown/core");
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
- const config = await (0, core_1.buildConfig)(options, {}, options.id);
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
- .command(command)
37
- .description(description)
38
- .option("-s, --schema <schema>", "Schema location")
39
- .option("-r, --root <rootPath>", "Root folder for doc generation")
40
- .option("-b, --base <baseURL>", "Base URL to be used by Docusaurus")
41
- .option("-l, --link <linkRoot>", "Root for links in documentation")
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,2 @@
1
+ import type { MDXString } from "@graphql-markdown/types";
2
+ export declare const mdxDeclaration: MDXString;
@@ -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)' }}>&nbsp;●&nbsp;</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,12 @@
1
+ import type { AdmonitionType, Badge, Maybe, MDXString, MetaOptions, TypeLink } from "@graphql-markdown/types";
2
+ export { mdxDeclaration } from "./components";
3
+ export declare const formatMDXBadge: ({ text, classname }: Badge) => MDXString;
4
+ export declare const formatMDXAdmonition: ({ text, title, type }: AdmonitionType, meta: Maybe<MetaOptions>) => MDXString;
5
+ export declare const formatMDXBullet: (text?: string) => MDXString;
6
+ export declare const formatMDXDetails: ({ dataOpen, dataClose, }: {
7
+ dataOpen: Maybe<string>;
8
+ dataClose: Maybe<string>;
9
+ }) => MDXString;
10
+ export declare const formatMDXSpecifiedByLink: (url: string) => MDXString;
11
+ export declare const formatMDXNameEntity: (name: string, parentType?: Maybe<string>) => MDXString;
12
+ export declare const formatMDXLink: ({ text, url }: TypeLink) => TypeLink;
@@ -0,0 +1,45 @@
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.mdxDeclaration = void 0;
4
+ const MARKDOWN_EOL = "\n";
5
+ const MARKDOWN_EOP = `${MARKDOWN_EOL.repeat(2)}`;
6
+ const LINK_MDX_EXTENSION = ".mdx";
7
+ var components_1 = require("./components");
8
+ Object.defineProperty(exports, "mdxDeclaration", { enumerable: true, get: function () { return components_1.mdxDeclaration; } });
9
+ const formatMDXBadge = ({ text, classname }) => {
10
+ return `<Badge class="badge ${classname}" text="${text}"/>`;
11
+ };
12
+ exports.formatMDXBadge = formatMDXBadge;
13
+ const formatMDXAdmonition = ({ text, title, type }, meta) => {
14
+ const isDocusaurus = meta?.generatorFrameworkName === "docusaurus";
15
+ if (isDocusaurus && meta.generatorFrameworkVersion?.startsWith("2")) {
16
+ const oldType = type === "warning" ? "caution" : type;
17
+ return `${MARKDOWN_EOP}:::${oldType} ${title}${text}:::`;
18
+ }
19
+ return `${MARKDOWN_EOP}:::${type}[${title}]${text}:::`;
20
+ };
21
+ exports.formatMDXAdmonition = formatMDXAdmonition;
22
+ const formatMDXBullet = (text = "") => {
23
+ return `<Bullet />${text}`;
24
+ };
25
+ exports.formatMDXBullet = formatMDXBullet;
26
+ const formatMDXDetails = ({ dataOpen, dataClose, }) => {
27
+ return `${MARKDOWN_EOP}<Details dataOpen="Hide ${dataOpen}" dataClose="Show ${dataClose}">${MARKDOWN_EOP}\r${MARKDOWN_EOP}</Details>${MARKDOWN_EOP}`;
28
+ };
29
+ exports.formatMDXDetails = formatMDXDetails;
30
+ const formatMDXSpecifiedByLink = (url) => {
31
+ return `<SpecifiedBy url="${url}"/>`;
32
+ };
33
+ exports.formatMDXSpecifiedByLink = formatMDXSpecifiedByLink;
34
+ const formatMDXNameEntity = (name, parentType) => {
35
+ const parentName = parentType ? `${parentType}.` : "";
36
+ return `<code style={{ fontWeight: 'normal' }}>${parentName}<b>${name}</b></code>`;
37
+ };
38
+ exports.formatMDXNameEntity = formatMDXNameEntity;
39
+ const formatMDXLink = ({ text, url }) => {
40
+ return {
41
+ text,
42
+ url: `${url}${LINK_MDX_EXTENSION}`,
43
+ };
44
+ };
45
+ 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.27.0",
8
+ "version": "1.28.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,12 @@
51
65
  "docs": "typedoc"
52
66
  },
53
67
  "dependencies": {
54
- "@docusaurus/utils": ">=3.2.0",
55
- "@graphql-markdown/core": "^1.13.0",
56
- "@graphql-markdown/logger": "^1.0.5",
57
- "@graphql-markdown/printer-legacy": "^1.10.0"
68
+ "@graphql-markdown/cli": "^0.2.0",
69
+ "@docusaurus/utils": ">=3.2.0"
58
70
  },
59
71
  "devDependencies": {
60
- "@docusaurus/types": "^3.5.0",
61
- "@graphql-markdown/types": "^1.5.0"
72
+ "@docusaurus/types": "^3.7.0",
73
+ "@graphql-markdown/types": "^1.6.0"
62
74
  },
63
75
  "peerDependencies": {
64
76
  "@docusaurus/logger": "*"