@graphql-markdown/formatters 1.0.2 → 1.1.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/dist/defaults.d.ts +35 -0
- package/dist/defaults.d.ts.map +1 -1
- package/dist/defaults.js +49 -1
- package/dist/docfx/index.d.ts +3 -7
- package/dist/docfx/index.d.ts.map +1 -1
- package/dist/docfx/index.js +114 -43
- package/dist/docusaurus/index.d.ts +16 -0
- package/dist/docusaurus/index.d.ts.map +1 -1
- package/dist/docusaurus/index.js +34 -3
- package/dist/fumadocs/index.d.ts +9 -0
- package/dist/fumadocs/index.d.ts.map +1 -1
- package/dist/fumadocs/index.js +14 -1
- package/dist/honkit/index.d.ts +3 -1
- package/dist/honkit/index.d.ts.map +1 -1
- package/dist/honkit/index.js +5 -2
- package/dist/hugo/index.d.ts +4 -8
- package/dist/hugo/index.d.ts.map +1 -1
- package/dist/hugo/index.js +9 -11
- package/dist/mdbook/index.d.ts +1 -1
- package/dist/mdbook/index.d.ts.map +1 -1
- package/dist/mdbook/index.js +8 -11
- package/dist/mkdocs/index.d.ts +3 -2
- package/dist/mkdocs/index.d.ts.map +1 -1
- package/dist/mkdocs/index.js +7 -9
- package/dist/output.d.ts +58 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +112 -0
- package/dist/starlight/index.d.ts +13 -0
- package/dist/starlight/index.d.ts.map +1 -1
- package/dist/starlight/index.js +14 -1
- package/dist/version.d.ts +61 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +119 -0
- package/dist/vocs/index.d.ts +15 -0
- package/dist/vocs/index.d.ts.map +1 -1
- package/dist/vocs/index.js +16 -1
- package/package.json +1 -1
package/dist/hugo/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hugo/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hugo/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,EAEL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAmCjC;;;;GAIG;AACH,eAAO,MAAM,cAAc,aAAc,KAAK,KAAG,SAEhD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc,SAC9B,KAAK,CAAC,QAAQ,CAAC,KACrB,SAIF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,6BAG1B,iBAAiB,KAAG,SAEtB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,UACxB,KAAK,CAAC,kBAAkB,CAAC,aACrB,KAAK,CAAC,MAAM,EAAE,CAAC,KACzB,SAiBF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,kBAAmB,QAAQ,KAAG,QAKvD,CAAC;AAEF,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAY5D,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,YAAY,EAAG,KAAc,CAAC;AAE3C;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,EAAE,yBAgB3C,CAAC"}
|
package/dist/hugo/index.js
CHANGED
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.beforeGenerateIndexMetafileHook = exports.mdxExtension = exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXBullet = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
|
|
12
|
+
exports.beforeGenerateIndexMetafileHook = exports.mdxExtension = exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXPermalink = exports.formatMDXNameEntity = exports.formatMDXBullet = exports.formatMDXLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
|
|
13
13
|
const node_path_1 = require("node:path");
|
|
14
14
|
const helpers_1 = require("@graphql-markdown/helpers");
|
|
15
15
|
const utils_1 = require("@graphql-markdown/utils");
|
|
16
16
|
const defaults_1 = require("../defaults");
|
|
17
|
+
const output_1 = require("../output");
|
|
17
18
|
/**
|
|
18
19
|
* Maps graphql-markdown admonition types to Hugo GitHub-style alert types (Hugo 0.132+).
|
|
19
20
|
* @see https://gohugo.io/render-hooks/blockquotes/#alerts
|
|
@@ -40,9 +41,7 @@ exports.formatMDXBadge = formatMDXBadge;
|
|
|
40
41
|
/**
|
|
41
42
|
* Formats an admonition using Hugo GitHub-style alert syntax (`> [!TYPE]`).
|
|
42
43
|
* Requires Hugo 0.132 or later.
|
|
43
|
-
* @param
|
|
44
|
-
* @param title - Optional title rendered as bold text after the alert type line
|
|
45
|
-
* @param type - Admonition type (e.g. `note`, `warning`, `danger`) mapped via {@link ALERT_TYPE_MAP}
|
|
44
|
+
* @param admonition - Admonition data with text, optional title, and type (e.g. `note`, `warning`, `danger`) mapped via {@link ALERT_TYPE_MAP}
|
|
46
45
|
* @param _meta - Unused metadata parameter
|
|
47
46
|
* @returns Formatted blockquote alert string
|
|
48
47
|
*/
|
|
@@ -54,8 +53,7 @@ const formatMDXAdmonition = ({ text, title, type }, _meta) => {
|
|
|
54
53
|
exports.formatMDXAdmonition = formatMDXAdmonition;
|
|
55
54
|
/**
|
|
56
55
|
* Formats a collapsible block as an HTML `<details>` element.
|
|
57
|
-
* @param
|
|
58
|
-
* @param dataClose - Label shown inside the expanded section
|
|
56
|
+
* @param option - Configuration for open/close label text
|
|
59
57
|
* @returns HTML `<details>`/`<summary>` block string
|
|
60
58
|
*/
|
|
61
59
|
const formatMDXDetails = ({ dataOpen, dataClose, }) => {
|
|
@@ -89,8 +87,7 @@ exports.formatMDXFrontmatter = formatMDXFrontmatter;
|
|
|
89
87
|
/**
|
|
90
88
|
* Strips the `.md` extension from internal links.
|
|
91
89
|
* Hugo serves pages at extensionless URLs — links with `.md` would 404 in the built site.
|
|
92
|
-
* @param
|
|
93
|
-
* @param url - Link target URL, with `.md` extension removed if present
|
|
90
|
+
* @param link - Link data with text and URL; `.md` extension is removed from the URL if present
|
|
94
91
|
* @returns Link object with the cleaned URL
|
|
95
92
|
*/
|
|
96
93
|
const formatMDXLink = ({ text, url }) => {
|
|
@@ -103,6 +100,7 @@ exports.formatMDXLink = formatMDXLink;
|
|
|
103
100
|
var defaults_2 = require("../defaults");
|
|
104
101
|
Object.defineProperty(exports, "formatMDXBullet", { enumerable: true, get: function () { return defaults_2.formatMDXBullet; } });
|
|
105
102
|
Object.defineProperty(exports, "formatMDXNameEntity", { enumerable: true, get: function () { return defaults_2.formatMDXNameEntity; } });
|
|
103
|
+
Object.defineProperty(exports, "formatMDXPermalink", { enumerable: true, get: function () { return defaults_2.formatMDXPermalink; } });
|
|
106
104
|
Object.defineProperty(exports, "formatMDXSpecifiedByLink", { enumerable: true, get: function () { return defaults_2.formatMDXSpecifiedByLink; } });
|
|
107
105
|
/**
|
|
108
106
|
* Creates a Hugo formatter.
|
|
@@ -118,6 +116,7 @@ const createMDXFormatter = (_meta) => {
|
|
|
118
116
|
formatMDXFrontmatter: exports.formatMDXFrontmatter,
|
|
119
117
|
formatMDXLink: exports.formatMDXLink,
|
|
120
118
|
formatMDXNameEntity: defaults_1.formatMDXNameEntity,
|
|
119
|
+
formatMDXPermalink: defaults_1.formatMDXPermalink,
|
|
121
120
|
formatMDXSpecifiedByLink: defaults_1.formatMDXSpecifiedByLink,
|
|
122
121
|
};
|
|
123
122
|
};
|
|
@@ -133,11 +132,10 @@ exports.mdxExtension = ".md";
|
|
|
133
132
|
* @param event - Hook event whose `data` contains `dirPath` (target directory) and `category` (section name)
|
|
134
133
|
*/
|
|
135
134
|
const beforeGenerateIndexMetafileHook = async (event) => {
|
|
136
|
-
const { dirPath, category } = event.data;
|
|
135
|
+
const { dirPath, category, outputAdapter } = event.data;
|
|
137
136
|
const filePath = (0, node_path_1.join)(dirPath, "_index.md");
|
|
138
137
|
const label = (0, utils_1.startCase)(category);
|
|
139
138
|
const content = `${utils_1.FRONT_MATTER_DELIMITER}${utils_1.MARKDOWN_EOL}title: "${label}"${utils_1.MARKDOWN_EOL}type: docs${utils_1.MARKDOWN_EOL}bookCollapseSection: true${utils_1.MARKDOWN_EOL}${utils_1.FRONT_MATTER_DELIMITER}${utils_1.MARKDOWN_EOL}${utils_1.MARKDOWN_EOL}# ${label}${utils_1.MARKDOWN_EOL}${utils_1.MARKDOWN_EOL}`;
|
|
140
|
-
await (0,
|
|
141
|
-
await (0, utils_1.saveFile)(filePath, content);
|
|
139
|
+
await (0, output_1.writeOutput)(filePath, content, outputAdapter, dirPath);
|
|
142
140
|
};
|
|
143
141
|
exports.beforeGenerateIndexMetafileHook = beforeGenerateIndexMetafileHook;
|
package/dist/mdbook/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare const mdxExtension = ".md";
|
|
|
51
51
|
* @returns The link with `.md` appended to extensionless absolute paths
|
|
52
52
|
*/
|
|
53
53
|
export declare const formatMDXLink: (link: TypeLink) => TypeLink;
|
|
54
|
-
export { formatMDXBullet, formatMDXNameEntity, formatMDXSpecifiedByLink, } from "../defaults";
|
|
54
|
+
export { formatMDXBullet, formatMDXNameEntity, formatMDXPermalink, formatMDXSpecifiedByLink, } from "../defaults";
|
|
55
55
|
/**
|
|
56
56
|
* Rewrites absolute generated doc links to page-relative `.md` paths after each page is rendered.
|
|
57
57
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mdbook/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mdbook/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,KAAK,EAEL,SAAS,EACT,QAAQ,EACR,eAAe,EACf,sBAAsB,EACtB,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAoBjC;;;;GAIG;AACH,eAAO,MAAM,cAAc,aAAc,KAAK,KAAG,SAEhD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc,SAC9B,KAAK,CAAC,QAAQ,CAAC,KACrB,SAIF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,kBAE1B,iBAAiB,KAAG,SAEtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,WACvB,KAAK,CAAC,kBAAkB,CAAC,aACtB,KAAK,CAAC,MAAM,EAAE,CAAC,KACzB,SAEF,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC;;;;GAIG;AACH,eAAO,MAAM,aAAa,SAAU,QAAQ,KAAG,QAU9C,CAAC;AAEF,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAyBrB;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,EAAE,sBAIzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAY5D,CAAC;AAeF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,eAkFlC,CAAC"}
|
package/dist/mdbook/index.js
CHANGED
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
* @packageDocumentation
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.afterRenderFilesHook = exports.createMDXFormatter = exports.afterRenderTypeEntitiesHook = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXBullet = exports.formatMDXLink = exports.mdxExtension = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
|
|
13
|
+
exports.afterRenderFilesHook = exports.createMDXFormatter = exports.afterRenderTypeEntitiesHook = exports.formatMDXSpecifiedByLink = exports.formatMDXPermalink = exports.formatMDXNameEntity = exports.formatMDXBullet = exports.formatMDXLink = exports.mdxExtension = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = void 0;
|
|
14
14
|
const node_path_1 = require("node:path");
|
|
15
15
|
const helpers_1 = require("@graphql-markdown/helpers");
|
|
16
16
|
const utils_1 = require("@graphql-markdown/utils");
|
|
17
17
|
const defaults_1 = require("../defaults");
|
|
18
|
+
const output_1 = require("../output");
|
|
18
19
|
/**
|
|
19
20
|
* Formats a badge as Markdown bold text — mdBook has no badge component.
|
|
20
21
|
* @param badge - Badge data containing text
|
|
@@ -60,8 +61,7 @@ exports.formatMDXDetails = formatMDXDetails;
|
|
|
60
61
|
* @returns `# Title\n` when a title is available, otherwise an empty string
|
|
61
62
|
*/
|
|
62
63
|
const formatMDXFrontmatter = (_props, formatted) => {
|
|
63
|
-
|
|
64
|
-
return (title ? `# ${title}${utils_1.MARKDOWN_EOL}` : "");
|
|
64
|
+
return (0, defaults_1.formatMDXFrontmatterTitleOnly)(formatted, true);
|
|
65
65
|
};
|
|
66
66
|
exports.formatMDXFrontmatter = formatMDXFrontmatter;
|
|
67
67
|
/** mdBook expects `.md` files; override the default `.mdx` extension. */
|
|
@@ -85,6 +85,7 @@ exports.formatMDXLink = formatMDXLink;
|
|
|
85
85
|
var defaults_2 = require("../defaults");
|
|
86
86
|
Object.defineProperty(exports, "formatMDXBullet", { enumerable: true, get: function () { return defaults_2.formatMDXBullet; } });
|
|
87
87
|
Object.defineProperty(exports, "formatMDXNameEntity", { enumerable: true, get: function () { return defaults_2.formatMDXNameEntity; } });
|
|
88
|
+
Object.defineProperty(exports, "formatMDXPermalink", { enumerable: true, get: function () { return defaults_2.formatMDXPermalink; } });
|
|
88
89
|
Object.defineProperty(exports, "formatMDXSpecifiedByLink", { enumerable: true, get: function () { return defaults_2.formatMDXSpecifiedByLink; } });
|
|
89
90
|
const rewriteInternalLinks = (content, filePath, outputDir, baseURL) => {
|
|
90
91
|
return content.replaceAll(/\]\((\/[^)\s#]+)(#[^)\s]+)?\)/g, (_match, urlPath, hash = "") => {
|
|
@@ -110,12 +111,7 @@ const rewriteInternalLinks = (content, filePath, outputDir, baseURL) => {
|
|
|
110
111
|
* work correctly regardless of where the book is hosted.
|
|
111
112
|
*/
|
|
112
113
|
const afterRenderTypeEntitiesHook = async (event) => {
|
|
113
|
-
|
|
114
|
-
const content = await (0, utils_1.readFile)(filePath, "utf-8");
|
|
115
|
-
const rewrittenContent = rewriteInternalLinks(content, filePath, outputDir, baseURL);
|
|
116
|
-
if (rewrittenContent !== content) {
|
|
117
|
-
await (0, utils_1.saveFile)(filePath, rewrittenContent);
|
|
118
|
-
}
|
|
114
|
+
await (0, output_1.rewriteRenderedPage)(event, rewriteInternalLinks);
|
|
119
115
|
};
|
|
120
116
|
exports.afterRenderTypeEntitiesHook = afterRenderTypeEntitiesHook;
|
|
121
117
|
/**
|
|
@@ -132,6 +128,7 @@ const createMDXFormatter = (_meta) => {
|
|
|
132
128
|
formatMDXFrontmatter: exports.formatMDXFrontmatter,
|
|
133
129
|
formatMDXLink: exports.formatMDXLink,
|
|
134
130
|
formatMDXNameEntity: defaults_1.formatMDXNameEntity,
|
|
131
|
+
formatMDXPermalink: defaults_1.formatMDXPermalink,
|
|
135
132
|
formatMDXSpecifiedByLink: defaults_1.formatMDXSpecifiedByLink,
|
|
136
133
|
};
|
|
137
134
|
};
|
|
@@ -156,7 +153,7 @@ const SECTION_ORDER = [
|
|
|
156
153
|
* by top-level section (Operations / Types) and category, then writes the file.
|
|
157
154
|
*/
|
|
158
155
|
const afterRenderFilesHook = async (event) => {
|
|
159
|
-
const { baseURL, outputDir, rootDir, pages } = event.data;
|
|
156
|
+
const { baseURL, outputDir, rootDir, pages, outputAdapter } = event.data;
|
|
160
157
|
const summaryPath = (0, node_path_1.join)(rootDir, "SUMMARY.md");
|
|
161
158
|
const allPages = pages
|
|
162
159
|
.flat()
|
|
@@ -203,6 +200,6 @@ const afterRenderFilesHook = async (event) => {
|
|
|
203
200
|
}
|
|
204
201
|
lines.push("");
|
|
205
202
|
}
|
|
206
|
-
await (0,
|
|
203
|
+
await (0, output_1.writeOutput)(summaryPath, lines.join("\n"), outputAdapter);
|
|
207
204
|
};
|
|
208
205
|
exports.afterRenderFilesHook = afterRenderFilesHook;
|
package/dist/mkdocs/index.d.ts
CHANGED
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
import type { AdmonitionType, Badge, CollapsibleOption, Formatter, FrontMatterOptions, Maybe, MDXString, MetaInfo, RenderTypeEntitiesHook } from "@graphql-markdown/types";
|
|
10
|
-
import { formatMDXBullet, formatMDXLink } from "../defaults";
|
|
10
|
+
import { formatMDXBullet, formatMDXLink, formatMDXPermalink } from "../defaults";
|
|
11
11
|
export declare const __default: {
|
|
12
12
|
formatMDXBullet: typeof formatMDXBullet;
|
|
13
13
|
formatMDXLink: typeof formatMDXLink;
|
|
14
|
+
formatMDXPermalink: typeof formatMDXPermalink;
|
|
14
15
|
};
|
|
15
16
|
/**
|
|
16
17
|
* Formats a badge as an inline HTML mark element.
|
|
@@ -60,7 +61,7 @@ export declare const mdxExtension: ".md";
|
|
|
60
61
|
* @param event - Hook payload containing the current file path and renderer output context
|
|
61
62
|
*/
|
|
62
63
|
export declare const afterRenderTypeEntitiesHook: RenderTypeEntitiesHook;
|
|
63
|
-
export { formatMDXBullet } from "../defaults";
|
|
64
|
+
export { formatMDXBullet, formatMDXPermalink } from "../defaults";
|
|
64
65
|
/**
|
|
65
66
|
* Creates an MkDocs Material formatter.
|
|
66
67
|
* @param _meta - Unused metadata parameter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mkdocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mkdocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,QAAQ,EACR,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EACL,eAAe,EAEf,aAAa,EACb,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAGrB,eAAO,MAAM,SAAS;;;;CAIrB,CAAC;AAmCF;;;;GAIG;AACH,eAAO,MAAM,cAAc,aAAc,KAAK,KAAG,SAEhD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc,SAC9B,KAAK,CAAC,QAAQ,CAAC,KACrB,SAIF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,6BAG1B,iBAAiB,KAAG,SAEtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,WACvB,KAAK,CAAC,kBAAkB,CAAC,aACtB,KAAK,CAAC,MAAM,EAAE,CAAC,KACzB,SAEF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,SACxB,MAAM,eACC,KAAK,CAAC,MAAM,CAAC,KACzB,SAGF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAAS,MAAM,KAAG,SAEtD,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,YAAY,EAAG,KAAc,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,EAAE,sBAIzC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAY5D,CAAC"}
|
package/dist/mkdocs/index.js
CHANGED
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.createMDXFormatter = exports.formatMDXBullet = exports.afterRenderTypeEntitiesHook = exports.mdxExtension = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.__default = void 0;
|
|
11
|
+
exports.createMDXFormatter = exports.formatMDXPermalink = exports.formatMDXBullet = exports.afterRenderTypeEntitiesHook = exports.mdxExtension = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.__default = void 0;
|
|
12
12
|
const helpers_1 = require("@graphql-markdown/helpers");
|
|
13
13
|
const utils_1 = require("@graphql-markdown/utils");
|
|
14
14
|
const defaults_1 = require("../defaults");
|
|
15
|
+
const output_1 = require("../output");
|
|
15
16
|
exports.__default = {
|
|
16
17
|
formatMDXBullet: defaults_1.formatMDXBullet,
|
|
17
18
|
formatMDXLink: defaults_1.formatMDXLink,
|
|
19
|
+
formatMDXPermalink: defaults_1.formatMDXPermalink,
|
|
18
20
|
};
|
|
19
21
|
const ADMONITION_TYPE_MAP = {
|
|
20
22
|
note: "note",
|
|
@@ -76,8 +78,7 @@ exports.formatMDXDetails = formatMDXDetails;
|
|
|
76
78
|
* @returns Visible heading string, or empty string if no title is available
|
|
77
79
|
*/
|
|
78
80
|
const formatMDXFrontmatter = (_props, formatted) => {
|
|
79
|
-
|
|
80
|
-
return title ? `# ${title}` : "";
|
|
81
|
+
return (0, defaults_1.formatMDXFrontmatterTitleOnly)(formatted);
|
|
81
82
|
};
|
|
82
83
|
exports.formatMDXFrontmatter = formatMDXFrontmatter;
|
|
83
84
|
/**
|
|
@@ -108,16 +109,12 @@ exports.mdxExtension = ".md";
|
|
|
108
109
|
* @param event - Hook payload containing the current file path and renderer output context
|
|
109
110
|
*/
|
|
110
111
|
const afterRenderTypeEntitiesHook = async (event) => {
|
|
111
|
-
|
|
112
|
-
const content = await (0, utils_1.readFile)(filePath, "utf-8");
|
|
113
|
-
const rewrittenContent = rewriteInternalLinks(content, filePath, outputDir, baseURL);
|
|
114
|
-
if (rewrittenContent !== content) {
|
|
115
|
-
await (0, utils_1.saveFile)(filePath, rewrittenContent);
|
|
116
|
-
}
|
|
112
|
+
await (0, output_1.rewriteRenderedPage)(event, rewriteInternalLinks);
|
|
117
113
|
};
|
|
118
114
|
exports.afterRenderTypeEntitiesHook = afterRenderTypeEntitiesHook;
|
|
119
115
|
var defaults_2 = require("../defaults");
|
|
120
116
|
Object.defineProperty(exports, "formatMDXBullet", { enumerable: true, get: function () { return defaults_2.formatMDXBullet; } });
|
|
117
|
+
Object.defineProperty(exports, "formatMDXPermalink", { enumerable: true, get: function () { return defaults_2.formatMDXPermalink; } });
|
|
121
118
|
/**
|
|
122
119
|
* Creates an MkDocs Material formatter.
|
|
123
120
|
* @param _meta - Unused metadata parameter
|
|
@@ -132,6 +129,7 @@ const createMDXFormatter = (_meta) => {
|
|
|
132
129
|
formatMDXFrontmatter: exports.formatMDXFrontmatter,
|
|
133
130
|
formatMDXLink: defaults_1.formatMDXLink,
|
|
134
131
|
formatMDXNameEntity: exports.formatMDXNameEntity,
|
|
132
|
+
formatMDXPermalink: defaults_1.formatMDXPermalink,
|
|
135
133
|
formatMDXSpecifiedByLink: exports.formatMDXSpecifiedByLink,
|
|
136
134
|
};
|
|
137
135
|
};
|
package/dist/output.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output helpers for formatter lifecycle hooks.
|
|
3
|
+
*
|
|
4
|
+
* Hooks post-process pages the renderer has already written, so they must go
|
|
5
|
+
* through the same destination the renderer used. Reaching for the filesystem
|
|
6
|
+
* directly works only as long as the default adapter is in play, and silently
|
|
7
|
+
* misses every page when the output is redirected elsewhere.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import type { Maybe, OutputAdapter } from "@graphql-markdown/types";
|
|
12
|
+
/**
|
|
13
|
+
* Reads back a page the renderer has written, through its output destination.
|
|
14
|
+
*
|
|
15
|
+
* The page was just written, so nothing coming back means the destination
|
|
16
|
+
* cannot be read - a write-only adapter, a stubbed `readFile`, or a store that
|
|
17
|
+
* is not read-your-writes consistent. Post-processing cannot run without it,
|
|
18
|
+
* which is reported rather than silently skipped.
|
|
19
|
+
*
|
|
20
|
+
* @param filePath - Path of the generated page
|
|
21
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
22
|
+
* @returns The page content, or `undefined` if it cannot be read back
|
|
23
|
+
* @throws An error the first time this adapter cannot read a page back, so the
|
|
24
|
+
* skipped post-processing surfaces once instead of once per page.
|
|
25
|
+
*/
|
|
26
|
+
export declare const readOutput: (filePath: string, outputAdapter: Maybe<OutputAdapter>) => Promise<string | undefined>;
|
|
27
|
+
/**
|
|
28
|
+
* Reads a file the formatter maintains itself, where absence is expected.
|
|
29
|
+
*
|
|
30
|
+
* Unlike {@link readOutput} this reports nothing when there is no content: a
|
|
31
|
+
* navigation or metadata file legitimately does not exist until the formatter
|
|
32
|
+
* creates it on the first page of a directory.
|
|
33
|
+
*
|
|
34
|
+
* @param filePath - Path of the file to read
|
|
35
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
36
|
+
* @returns The file content, or `undefined` when there is none
|
|
37
|
+
*/
|
|
38
|
+
export declare const readOptionalOutput: (filePath: string, outputAdapter: Maybe<OutputAdapter>) => Promise<string | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Writes a file through the output destination, creating its directory first.
|
|
41
|
+
*
|
|
42
|
+
* @param filePath - Path of the file to write
|
|
43
|
+
* @param content - File content
|
|
44
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
45
|
+
*/
|
|
46
|
+
export declare const writeOutput: (filePath: string, content: string, outputAdapter: Maybe<OutputAdapter>, dirPath?: string) => Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Rewrites the content of a page a formatter has just rendered.
|
|
49
|
+
*
|
|
50
|
+
* The read-modify-write around an `afterRenderTypeEntities` hook is identical
|
|
51
|
+
* for every preset that post-processes its own output; only the rewriting
|
|
52
|
+
* differs. Presets supply that and nothing else.
|
|
53
|
+
*
|
|
54
|
+
* @param event - The hook event, carrying the page path and its destination
|
|
55
|
+
* @param rewrite - Returns the new content, or the content unchanged to skip
|
|
56
|
+
*/
|
|
57
|
+
export declare const rewriteRenderedPage: (event: unknown, rewrite: (content: string, filePath: string, outputDir: string, baseURL: string) => string) => Promise<void>;
|
|
58
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AA0BpE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU,aACX,MAAM,iBACD,KAAK,CAAC,aAAa,CAAC,KAClC,OAAO,CAAC,MAAM,GAAG,SAAS,CAgB5B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,aACnB,MAAM,iBACD,KAAK,CAAC,aAAa,CAAC,KAClC,OAAO,CAAC,MAAM,GAAG,SAAS,CAE5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aACZ,MAAM,WACP,MAAM,iBACA,KAAK,CAAC,aAAa,CAAC,YACzB,MAAM,KACf,OAAO,CAAC,IAAI,CAQd,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,UACvB,OAAO,WACL,CACP,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,KACZ,MAAM,KACV,OAAO,CAAC,IAAI,CAuBd,CAAC"}
|
package/dist/output.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Output helpers for formatter lifecycle hooks.
|
|
4
|
+
*
|
|
5
|
+
* Hooks post-process pages the renderer has already written, so they must go
|
|
6
|
+
* through the same destination the renderer used. Reaching for the filesystem
|
|
7
|
+
* directly works only as long as the default adapter is in play, and silently
|
|
8
|
+
* misses every page when the output is redirected elsewhere.
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.rewriteRenderedPage = exports.writeOutput = exports.readOptionalOutput = exports.readOutput = void 0;
|
|
14
|
+
const utils_1 = require("@graphql-markdown/utils");
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the destination a hook must use, falling back to the filesystem.
|
|
17
|
+
*
|
|
18
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
19
|
+
* @returns The adapter to read from and write to
|
|
20
|
+
*/
|
|
21
|
+
const getOutputAdapter = (outputAdapter) => {
|
|
22
|
+
return outputAdapter ?? utils_1.fsOutputAdapter;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Adapters a failed read-back has already been reported for.
|
|
26
|
+
*
|
|
27
|
+
* A destination that cannot read back its own writes fails on every page, so
|
|
28
|
+
* reporting each one would bury the run in identical errors. Keyed by adapter
|
|
29
|
+
* rather than a flag, so one destination going quiet says nothing about
|
|
30
|
+
* another. An adapter instance reused across several runs in one process is
|
|
31
|
+
* therefore reported on its first failing run only.
|
|
32
|
+
*/
|
|
33
|
+
const readBackReported = new WeakSet();
|
|
34
|
+
/**
|
|
35
|
+
* Reads back a page the renderer has written, through its output destination.
|
|
36
|
+
*
|
|
37
|
+
* The page was just written, so nothing coming back means the destination
|
|
38
|
+
* cannot be read - a write-only adapter, a stubbed `readFile`, or a store that
|
|
39
|
+
* is not read-your-writes consistent. Post-processing cannot run without it,
|
|
40
|
+
* which is reported rather than silently skipped.
|
|
41
|
+
*
|
|
42
|
+
* @param filePath - Path of the generated page
|
|
43
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
44
|
+
* @returns The page content, or `undefined` if it cannot be read back
|
|
45
|
+
* @throws An error the first time this adapter cannot read a page back, so the
|
|
46
|
+
* skipped post-processing surfaces once instead of once per page.
|
|
47
|
+
*/
|
|
48
|
+
const readOutput = async (filePath, outputAdapter) => {
|
|
49
|
+
const adapter = getOutputAdapter(outputAdapter);
|
|
50
|
+
const content = await adapter.readFile(filePath);
|
|
51
|
+
if (typeof content === "string") {
|
|
52
|
+
return content;
|
|
53
|
+
}
|
|
54
|
+
if (!readBackReported.has(adapter)) {
|
|
55
|
+
readBackReported.add(adapter);
|
|
56
|
+
throw new Error(`Cannot read back "${filePath}" from the output destination: the formatter cannot post-process what it wrote (e.g. internal link rewriting, navigation/metadata updates) for this run.`);
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
};
|
|
60
|
+
exports.readOutput = readOutput;
|
|
61
|
+
/**
|
|
62
|
+
* Reads a file the formatter maintains itself, where absence is expected.
|
|
63
|
+
*
|
|
64
|
+
* Unlike {@link readOutput} this reports nothing when there is no content: a
|
|
65
|
+
* navigation or metadata file legitimately does not exist until the formatter
|
|
66
|
+
* creates it on the first page of a directory.
|
|
67
|
+
*
|
|
68
|
+
* @param filePath - Path of the file to read
|
|
69
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
70
|
+
* @returns The file content, or `undefined` when there is none
|
|
71
|
+
*/
|
|
72
|
+
const readOptionalOutput = async (filePath, outputAdapter) => {
|
|
73
|
+
return getOutputAdapter(outputAdapter).readFile(filePath);
|
|
74
|
+
};
|
|
75
|
+
exports.readOptionalOutput = readOptionalOutput;
|
|
76
|
+
/**
|
|
77
|
+
* Writes a file through the output destination, creating its directory first.
|
|
78
|
+
*
|
|
79
|
+
* @param filePath - Path of the file to write
|
|
80
|
+
* @param content - File content
|
|
81
|
+
* @param outputAdapter - Adapter carried by the hook event, if any
|
|
82
|
+
*/
|
|
83
|
+
const writeOutput = async (filePath, content, outputAdapter, dirPath) => {
|
|
84
|
+
const adapter = getOutputAdapter(outputAdapter);
|
|
85
|
+
if (typeof dirPath === "string") {
|
|
86
|
+
await adapter.ensureDir?.(dirPath);
|
|
87
|
+
}
|
|
88
|
+
await adapter.writeFile(filePath, content);
|
|
89
|
+
};
|
|
90
|
+
exports.writeOutput = writeOutput;
|
|
91
|
+
/**
|
|
92
|
+
* Rewrites the content of a page a formatter has just rendered.
|
|
93
|
+
*
|
|
94
|
+
* The read-modify-write around an `afterRenderTypeEntities` hook is identical
|
|
95
|
+
* for every preset that post-processes its own output; only the rewriting
|
|
96
|
+
* differs. Presets supply that and nothing else.
|
|
97
|
+
*
|
|
98
|
+
* @param event - The hook event, carrying the page path and its destination
|
|
99
|
+
* @param rewrite - Returns the new content, or the content unchanged to skip
|
|
100
|
+
*/
|
|
101
|
+
const rewriteRenderedPage = async (event, rewrite) => {
|
|
102
|
+
const { baseURL, filePath, outputAdapter, outputDir } = event.data;
|
|
103
|
+
const content = await (0, exports.readOutput)(filePath, outputAdapter);
|
|
104
|
+
if (typeof content !== "string") {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const rewritten = rewrite(content, filePath, outputDir, baseURL);
|
|
108
|
+
if (rewritten !== content) {
|
|
109
|
+
await (0, exports.writeOutput)(filePath, rewritten, outputAdapter);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
exports.rewriteRenderedPage = rewriteRenderedPage;
|
|
@@ -8,6 +8,19 @@
|
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
10
|
import type { AdmonitionType, Badge, Formatter, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
|
|
11
|
+
import { formatMDXEscapedPermalink } from "../defaults";
|
|
12
|
+
/**
|
|
13
|
+
* Formats a permalink for a section header, using the classic `{#id}` syntax
|
|
14
|
+
* escaped to remain valid MDX.
|
|
15
|
+
*
|
|
16
|
+
* Starlight has no built-in custom header id syntax, so the permalink is inert
|
|
17
|
+
* unless a remark plugin such as `remark-custom-heading-id` is configured. Turn
|
|
18
|
+
* it off with `docOptions.sectionHeaderId: false`.
|
|
19
|
+
*
|
|
20
|
+
* @param id - The ID of the section header
|
|
21
|
+
* @returns Formatted permalink string
|
|
22
|
+
*/
|
|
23
|
+
export declare const formatMDXPermalink: typeof formatMDXEscapedPermalink;
|
|
11
24
|
/** File extension used for generated pages. */
|
|
12
25
|
export declare const mdxExtension: ".mdx";
|
|
13
26
|
/** MDX import statement prepended to every generated file to register Starlight components. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/starlight/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/starlight/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAIL,yBAAyB,EAG1B,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,kCAA4B,CAAC;AAE5D,+CAA+C;AAC/C,eAAO,MAAM,YAAY,EAAG,MAAe,CAAC;AAE5C,+FAA+F;AAC/F,eAAO,MAAM,cAAc,EAAE,SAEf,CAAC;AAEf;;;;;GAKG;AACH,eAAO,MAAM,cAAc,wBAAyB,KAAK,KAAG,SAG3D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,0BACP,cAAc,SAC9B,KAAK,CAAC,QAAQ,CAAC,KACrB,SAGF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,SAAU,QAAQ,KAAG,QAE9C,CAAC;AAEF,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAY5D,CAAC"}
|
package/dist/starlight/index.js
CHANGED
|
@@ -9,9 +9,21 @@
|
|
|
9
9
|
* @packageDocumentation
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXLink = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxDeclaration = exports.mdxExtension = void 0;
|
|
12
|
+
exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXNameEntity = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXBullet = exports.formatMDXLink = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxDeclaration = exports.mdxExtension = exports.formatMDXPermalink = void 0;
|
|
13
13
|
const utils_1 = require("@graphql-markdown/utils");
|
|
14
14
|
const defaults_1 = require("../defaults");
|
|
15
|
+
/**
|
|
16
|
+
* Formats a permalink for a section header, using the classic `{#id}` syntax
|
|
17
|
+
* escaped to remain valid MDX.
|
|
18
|
+
*
|
|
19
|
+
* Starlight has no built-in custom header id syntax, so the permalink is inert
|
|
20
|
+
* unless a remark plugin such as `remark-custom-heading-id` is configured. Turn
|
|
21
|
+
* it off with `docOptions.sectionHeaderId: false`.
|
|
22
|
+
*
|
|
23
|
+
* @param id - The ID of the section header
|
|
24
|
+
* @returns Formatted permalink string
|
|
25
|
+
*/
|
|
26
|
+
exports.formatMDXPermalink = defaults_1.formatMDXEscapedPermalink;
|
|
15
27
|
/** File extension used for generated pages. */
|
|
16
28
|
exports.mdxExtension = ".mdx";
|
|
17
29
|
/** MDX import statement prepended to every generated file to register Starlight components. */
|
|
@@ -71,6 +83,7 @@ const createMDXFormatter = (_meta) => {
|
|
|
71
83
|
formatMDXFrontmatter: defaults_1.formatMDXFrontmatter,
|
|
72
84
|
formatMDXLink: exports.formatMDXLink,
|
|
73
85
|
formatMDXNameEntity: defaults_1.formatMDXNameEntity,
|
|
86
|
+
formatMDXPermalink: exports.formatMDXPermalink,
|
|
74
87
|
formatMDXSpecifiedByLink: defaults_1.formatMDXSpecifiedByLink,
|
|
75
88
|
};
|
|
76
89
|
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for gating formatter output on the target framework version.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { Maybe, MetaInfo } from "@graphql-markdown/types";
|
|
7
|
+
/** A framework version, narrowed down to the parts used for comparison. */
|
|
8
|
+
export interface FrameworkVersion {
|
|
9
|
+
major: number;
|
|
10
|
+
minor?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Checks that the generator framework declared in `meta` is `framework`, and
|
|
14
|
+
* that its version matches `version`.
|
|
15
|
+
*
|
|
16
|
+
* Only the parts carried by `version` are compared, so `{ major: 2 }` matches
|
|
17
|
+
* any `2.x` release. An unknown, unparsable or mismatched framework version
|
|
18
|
+
* returns `false`.
|
|
19
|
+
*
|
|
20
|
+
* @param meta - Optional metadata carrying the framework name and version
|
|
21
|
+
* @param framework - The expected framework name, eg `"docusaurus"`
|
|
22
|
+
* @param version - The version to match
|
|
23
|
+
* @returns `true` if the framework and its version match
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```js
|
|
27
|
+
* const meta = {
|
|
28
|
+
* generatorFrameworkName: "docusaurus",
|
|
29
|
+
* generatorFrameworkVersion: "2.4.3",
|
|
30
|
+
* };
|
|
31
|
+
*
|
|
32
|
+
* isFrameworkVersion(meta, "docusaurus", { major: 2 }); // true
|
|
33
|
+
* isFrameworkVersion(meta, "docusaurus", { major: 3 }); // false
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const isFrameworkVersion: (meta: Maybe<MetaInfo>, framework: string, version: FrameworkVersion) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Checks that the generator framework declared in `meta` is `framework`, and
|
|
39
|
+
* that its version is `minVersion` or above.
|
|
40
|
+
*
|
|
41
|
+
* An unknown, unparsable or mismatched framework version returns `false`, so
|
|
42
|
+
* callers fall back to the output supported by every version.
|
|
43
|
+
*
|
|
44
|
+
* @param meta - Optional metadata carrying the framework name and version
|
|
45
|
+
* @param framework - The expected framework name, eg `"docusaurus"`
|
|
46
|
+
* @param minVersion - The minimum version required by the caller
|
|
47
|
+
* @returns `true` if the framework matches and its version is high enough
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```js
|
|
51
|
+
* const meta = {
|
|
52
|
+
* generatorFrameworkName: "docusaurus",
|
|
53
|
+
* generatorFrameworkVersion: "3.10.2",
|
|
54
|
+
* };
|
|
55
|
+
*
|
|
56
|
+
* isFrameworkVersionAtLeast(meta, "docusaurus", { major: 3, minor: 10 }); // true
|
|
57
|
+
* isFrameworkVersionAtLeast(meta, "docusaurus", { major: 4 }); // false
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare const isFrameworkVersionAtLeast: (meta: Maybe<MetaInfo>, framework: string, minVersion: FrameworkVersion) => boolean;
|
|
61
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAE/D,2EAA2E;AAC3E,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAwED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,kBAAkB,SACvB,KAAK,CAAC,QAAQ,CAAC,aACV,MAAM,WACR,gBAAgB,KACxB,OAEF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,yBAAyB,SAC9B,KAAK,CAAC,QAAQ,CAAC,aACV,MAAM,cACL,gBAAgB,KAC3B,OAIF,CAAC"}
|