@graphql-markdown/docusaurus 1.28.0 → 1.29.1

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/README.md CHANGED
@@ -3,10 +3,8 @@
3
3
  [![Latest Version](https://img.shields.io/npm/v/@graphql-markdown/docusaurus?style=flat)](https://www.npmjs.com/package/@graphql-markdown/docusaurus)
4
4
  [![GitHub License](https://img.shields.io/github/license/graphql-markdown/graphql-markdown?style=flat)](https://raw.githubusercontent.com/graphql-markdown/graphql-markdown/main/LICENSE)
5
5
  [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=graphql-markdown_docusaurus&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=graphql-markdown_docusaurus)
6
- <!--
7
6
  [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=graphql-markdown_docusaurus&metric=coverage)](https://sonarcloud.io/summary/new_code?id=graphql-markdown_docusaurus)
8
- [![Mutation Score](https://img.shields.io/endpoint?label=mutation%20score&style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fgraphql-markdown%2Fgraphql-markdown%2Fmain%3Fmodule%3Ddocusarus)](https://dashboard.stryker-mutator.io/reports/github.com/graphql-markdown/graphql-markdown/main?module=docusarus)
9
- -->
7
+ [![Mutation Score](https://img.shields.io/endpoint?label=mutation%20score&style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fgraphql-markdown%2Fgraphql-markdown%2Fmain%3Fmodule%3Ddocusaurus)](https://dashboard.stryker-mutator.io/reports/github.com/graphql-markdown/graphql-markdown/main?module=docusaurus)
10
8
 
11
9
  **Docusaurus** [docs feature](https://docusaurus.io/docs/docs-introduction) plugin for generating **Markdown documentation** from a **GraphQL schema**.
12
10
 
@@ -16,7 +14,7 @@
16
14
  npm init docusaurus my-website https://github.com/graphql-markdown/template.git
17
15
  ```
18
16
 
19
- > _If you already have an existing Docusaurus installation, then see the [documentation](https://graphql-markdown.dev/docs/get-started) for alternative installation._
17
+ > _If you already have an existing Docusaurus installation, then see the [documentation](https://graphql-markdown.dev/docs/get-started/#existing-docusaurus-site) for an alternative installation._
20
18
 
21
19
  ## Usage
22
20
 
@@ -40,4 +38,4 @@ See [documentation troubleshooting](https://graphql-markdown.dev/docs/troublesho
40
38
 
41
39
  GraphQL-Markdown packages are 100% free and open-source, under the [MIT license](https://github.com/graphql-markdown/graphql-markdown/blob/main/LICENSE).
42
40
 
43
- This package is [Treeware](https://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/graphql-markdown/graphql-markdown) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
41
+ This package is [Treeware](https://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/graphql-markdown/graphql-markdown) to thank us for our work. By contributing to the Treeware forest, you’ll be creating employment for local families and restoring wildlife habitats.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  import type { LoadContext, Plugin, PluginOptions } from "@docusaurus/types";
2
2
  import type { GraphQLMarkdownCliOptions } from "@graphql-markdown/types";
3
+ /**
4
+ *
5
+ */
3
6
  export default function pluginGraphQLDocGenerator(_: LoadContext, options: GraphQLMarkdownCliOptions & Partial<PluginOptions>): Promise<Plugin>;
package/dist/index.js CHANGED
@@ -10,16 +10,30 @@ const logger_1 = __importDefault(require("@graphql-markdown/logger"));
10
10
  const NAME = "docusaurus-graphql-doc-generator";
11
11
  const LOGGER_MODULE = "@docusaurus/logger";
12
12
  const MDX_PACKAGE = "@graphql-markdown/docusaurus/mdx";
13
+ /**
14
+ *
15
+ */
13
16
  async function pluginGraphQLDocGenerator(_, options) {
14
17
  await (0, logger_1.default)(LOGGER_MODULE);
15
18
  return {
16
19
  name: NAME,
20
+ /**
21
+ * @experimental
22
+ */
17
23
  async loadContent() {
18
24
  if (options.runOnBuild !== true) {
19
25
  return;
20
26
  }
21
27
  await (0, cli_1.runGraphQLMarkdown)(options, {}, LOGGER_MODULE);
22
28
  },
29
+ /**
30
+ * Extends Docusaurus CLI with GraphQL Documentation generator command.
31
+ * This method adds a custom command to generate GraphQL documentation
32
+ * using the configured options.
33
+ *
34
+ * @param cli - The Docusaurus CLI instance to extend
35
+ * @returns void
36
+ */
23
37
  extendCli(cli) {
24
38
  cli.addCommand((0, cli_1.getGraphQLMarkdownCli)({
25
39
  ...options,
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @module mdx
3
+ * This module provides utilities for generating MDX index files in Docusaurus format.
4
+ */
5
+ import type { GenerateIndexMetafileType } from "@graphql-markdown/types";
6
+ export declare const generateIndexMetafile: GenerateIndexMetafileType;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /**
3
+ * @module mdx
4
+ * This module provides utilities for generating MDX index files in Docusaurus format.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.generateIndexMetafile = void 0;
8
+ const node_path_1 = require("node:path");
9
+ const utils_1 = require("@graphql-markdown/utils");
10
+ const CATEGORY_YAML = "_category_.yml";
11
+ var SidebarPosition;
12
+ (function (SidebarPosition) {
13
+ SidebarPosition[SidebarPosition["FIRST"] = 1] = "FIRST";
14
+ SidebarPosition[SidebarPosition["LAST"] = 999] = "LAST";
15
+ })(SidebarPosition || (SidebarPosition = {}));
16
+ const generateIndexMetafile = async (dirPath, category, options) => {
17
+ const filePath = (0, node_path_1.join)(dirPath, CATEGORY_YAML);
18
+ if (await (0, utils_1.fileExists)(filePath)) {
19
+ return;
20
+ }
21
+ const label = (0, utils_1.startCase)(category);
22
+ const link = options?.index !== true
23
+ ? "null"
24
+ : `\n type: generated-index\n title: '${label} overview'`;
25
+ const className = typeof options?.styleClass === "string"
26
+ ? `className: ${options.styleClass}\n`
27
+ : "";
28
+ const position = typeof options?.sidebarPosition === "number"
29
+ ? options.sidebarPosition
30
+ : SidebarPosition.FIRST;
31
+ const content = `label: ${label}\nposition: ${position}\n${className}link: ${link}\ncollapsible: ${options?.collapsible ?? true}\ncollapsed: ${options?.collapsed ?? true}\n`;
32
+ await (0, utils_1.ensureDir)(dirPath);
33
+ await (0, utils_1.saveFile)(filePath, content);
34
+ };
35
+ exports.generateIndexMetafile = generateIndexMetafile;
@@ -1,2 +1,6 @@
1
+ /**
2
+ * @module mdx
3
+ * This module provides MDX React components.
4
+ */
1
5
  import type { MDXString } from "@graphql-markdown/types";
2
6
  export declare const mdxDeclaration: MDXString;
@@ -1,4 +1,8 @@
1
1
  "use strict";
2
+ /**
3
+ * @module mdx
4
+ * This module provides MDX React components.
5
+ */
2
6
  Object.defineProperty(exports, "__esModule", { value: true });
3
7
  exports.mdxDeclaration = void 0;
4
8
  exports.mdxDeclaration = `
@@ -1,12 +1,45 @@
1
- import type { AdmonitionType, Badge, Maybe, MDXString, MetaOptions, TypeLink } from "@graphql-markdown/types";
1
+ /**
2
+ * @module mdx
3
+ * This module provides utilities for generating MDX content in Docusaurus format.
4
+ * It includes functions for creating badges, admonitions, bullet points, collapsible sections,
5
+ * specification links, and other MDX-specific formatting for GraphQL documentation.
6
+ *
7
+ * @primaryExport
8
+ */
9
+ import type { AdmonitionType, Badge, CollapsibleOption, Maybe, MDXString, MetaOptions, TypeLink } from "@graphql-markdown/types";
2
10
  export { mdxDeclaration } from "./components";
11
+ export { generateIndexMetafile } from "./category";
3
12
  export declare const formatMDXBadge: ({ text, classname }: Badge) => MDXString;
13
+ /**
14
+ * Formats an admonition block in MDX format
15
+ * @param param - The admonition configuration object
16
+ * @param meta - Optional metadata for generator configuration
17
+ * @returns Formatted MDX string for the admonition
18
+ */
4
19
  export declare const formatMDXAdmonition: ({ text, title, type }: AdmonitionType, meta: Maybe<MetaOptions>) => MDXString;
20
+ /**
21
+ * Creates a bullet point element in MDX format
22
+ * @param text - Optional text to append after the bullet point
23
+ * @returns Formatted MDX string for the bullet point
24
+ */
5
25
  export declare const formatMDXBullet: (text?: string) => MDXString;
6
- export declare const formatMDXDetails: ({ dataOpen, dataClose, }: {
7
- dataOpen: Maybe<string>;
8
- dataClose: Maybe<string>;
9
- }) => MDXString;
26
+ /**
27
+ * Creates a collapsible details section in MDX format
28
+ * @param param - The collapsible section configuration
29
+ * @returns Formatted MDX string for the collapsible section
30
+ */
31
+ export declare const formatMDXDetails: ({ dataOpen, dataClose, }: CollapsibleOption) => MDXString;
32
+ /**
33
+ * Creates a link to the specification documentation
34
+ * @param url - The URL to the specification
35
+ * @returns Formatted MDX string for the specification link
36
+ */
10
37
  export declare const formatMDXSpecifiedByLink: (url: string) => MDXString;
38
+ /**
39
+ * Formats a name entity with optional parent type
40
+ * @param name - The name to format
41
+ * @param parentType - Optional parent type to prefix the name
42
+ * @returns Formatted MDX string for the name entity
43
+ */
11
44
  export declare const formatMDXNameEntity: (name: string, parentType?: Maybe<string>) => MDXString;
12
45
  export declare const formatMDXLink: ({ text, url }: TypeLink) => TypeLink;
package/dist/mdx/index.js CHANGED
@@ -1,15 +1,34 @@
1
1
  "use strict";
2
+ /**
3
+ * @module mdx
4
+ * This module provides utilities for generating MDX content in Docusaurus format.
5
+ * It includes functions for creating badges, admonitions, bullet points, collapsible sections,
6
+ * specification links, and other MDX-specific formatting for GraphQL documentation.
7
+ *
8
+ * @primaryExport
9
+ */
2
10
  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;
11
+ exports.formatMDXLink = exports.formatMDXNameEntity = exports.formatMDXSpecifiedByLink = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.generateIndexMetafile = exports.mdxDeclaration = void 0;
12
+ const utils_1 = require("@graphql-markdown/utils");
4
13
  const MARKDOWN_EOL = "\n";
5
14
  const MARKDOWN_EOP = `${MARKDOWN_EOL.repeat(2)}`;
6
15
  const LINK_MDX_EXTENSION = ".mdx";
16
+ const DEFAULT_CSS_CLASSNAME = "badge--secondary";
7
17
  var components_1 = require("./components");
8
18
  Object.defineProperty(exports, "mdxDeclaration", { enumerable: true, get: function () { return components_1.mdxDeclaration; } });
19
+ var category_1 = require("./category");
20
+ Object.defineProperty(exports, "generateIndexMetafile", { enumerable: true, get: function () { return category_1.generateIndexMetafile; } });
9
21
  const formatMDXBadge = ({ text, classname }) => {
10
- return `<Badge class="badge ${classname}" text="${text}"/>`;
22
+ const style = typeof classname === "string" ? `badge--${classname.toLowerCase()}` : "";
23
+ return `<Badge class="badge ${DEFAULT_CSS_CLASSNAME} ${style}" text="${text}"/>`;
11
24
  };
12
25
  exports.formatMDXBadge = formatMDXBadge;
26
+ /**
27
+ * Formats an admonition block in MDX format
28
+ * @param param - The admonition configuration object
29
+ * @param meta - Optional metadata for generator configuration
30
+ * @returns Formatted MDX string for the admonition
31
+ */
13
32
  const formatMDXAdmonition = ({ text, title, type }, meta) => {
14
33
  const isDocusaurus = meta?.generatorFrameworkName === "docusaurus";
15
34
  if (isDocusaurus && meta.generatorFrameworkVersion?.startsWith("2")) {
@@ -19,21 +38,42 @@ const formatMDXAdmonition = ({ text, title, type }, meta) => {
19
38
  return `${MARKDOWN_EOP}:::${type}[${title}]${text}:::`;
20
39
  };
21
40
  exports.formatMDXAdmonition = formatMDXAdmonition;
41
+ /**
42
+ * Creates a bullet point element in MDX format
43
+ * @param text - Optional text to append after the bullet point
44
+ * @returns Formatted MDX string for the bullet point
45
+ */
22
46
  const formatMDXBullet = (text = "") => {
23
47
  return `<Bullet />${text}`;
24
48
  };
25
49
  exports.formatMDXBullet = formatMDXBullet;
50
+ /**
51
+ * Creates a collapsible details section in MDX format
52
+ * @param param - The collapsible section configuration
53
+ * @returns Formatted MDX string for the collapsible section
54
+ */
26
55
  const formatMDXDetails = ({ dataOpen, dataClose, }) => {
27
56
  return `${MARKDOWN_EOP}<Details dataOpen="Hide ${dataOpen}" dataClose="Show ${dataClose}">${MARKDOWN_EOP}\r${MARKDOWN_EOP}</Details>${MARKDOWN_EOP}`;
28
57
  };
29
58
  exports.formatMDXDetails = formatMDXDetails;
59
+ /**
60
+ * Creates a link to the specification documentation
61
+ * @param url - The URL to the specification
62
+ * @returns Formatted MDX string for the specification link
63
+ */
30
64
  const formatMDXSpecifiedByLink = (url) => {
31
65
  return `<SpecifiedBy url="${url}"/>`;
32
66
  };
33
67
  exports.formatMDXSpecifiedByLink = formatMDXSpecifiedByLink;
68
+ /**
69
+ * Formats a name entity with optional parent type
70
+ * @param name - The name to format
71
+ * @param parentType - Optional parent type to prefix the name
72
+ * @returns Formatted MDX string for the name entity
73
+ */
34
74
  const formatMDXNameEntity = (name, parentType) => {
35
75
  const parentName = parentType ? `${parentType}.` : "";
36
- return `<code style={{ fontWeight: 'normal' }}>${parentName}<b>${name}</b></code>`;
76
+ return `<code style={{ fontWeight: 'normal' }}>${(0, utils_1.escapeMDX)(parentName)}<b>${(0, utils_1.escapeMDX)(name)}</b></code>`;
37
77
  };
38
78
  exports.formatMDXNameEntity = formatMDXNameEntity;
39
79
  const formatMDXLink = ({ text, url }) => {
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.28.0",
8
+ "version": "1.29.1",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
@@ -65,12 +65,14 @@
65
65
  "docs": "typedoc"
66
66
  },
67
67
  "dependencies": {
68
- "@graphql-markdown/cli": "^0.2.0",
68
+ "@graphql-markdown/cli": "^0.3.1",
69
+ "@graphql-markdown/logger": "^1.0.5",
70
+ "@graphql-markdown/utils": "^1.8.1",
69
71
  "@docusaurus/utils": ">=3.2.0"
70
72
  },
71
73
  "devDependencies": {
72
74
  "@docusaurus/types": "^3.7.0",
73
- "@graphql-markdown/types": "^1.6.0"
75
+ "@graphql-markdown/types": "^1.7.0"
74
76
  },
75
77
  "peerDependencies": {
76
78
  "@docusaurus/logger": "*"