@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/version.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Helpers for gating formatter output on the target framework version.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.isFrameworkVersionAtLeast = exports.isFrameworkVersion = void 0;
|
|
9
|
+
const VERSION_EXPRESSION = /^\D*(?<major>\d+)(?:\.(?<minor>\d+))?/;
|
|
10
|
+
/**
|
|
11
|
+
* Parses the leading `major[.minor]` of a version string.
|
|
12
|
+
*
|
|
13
|
+
* Any prefix (`v`, `^`, `~`) is ignored, as is anything trailing the minor
|
|
14
|
+
* (patch, prerelease, build metadata).
|
|
15
|
+
*
|
|
16
|
+
* @param version - The version string to parse, eg `"3.10.2"`
|
|
17
|
+
* @returns The parsed version, or `undefined` if the string carries no version
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```js
|
|
21
|
+
* parseFrameworkVersion("3.10.2"); // { major: 3, minor: 10 }
|
|
22
|
+
* parseFrameworkVersion("next"); // undefined
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
const parseFrameworkVersion = (version) => {
|
|
26
|
+
const parsed = VERSION_EXPRESSION.exec(version ?? "");
|
|
27
|
+
if (!parsed?.groups) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
// an optional group is typed as always present, but is undefined when absent
|
|
31
|
+
return {
|
|
32
|
+
major: Number(parsed.groups.major),
|
|
33
|
+
minor: Number(parsed.groups.minor || 0),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Compares the generator framework version declared in `meta` with `version`.
|
|
38
|
+
*
|
|
39
|
+
* Only the parts carried by `version` are compared, so `{ major: 2 }` matches
|
|
40
|
+
* any `2.x` release.
|
|
41
|
+
*
|
|
42
|
+
* @param meta - Optional metadata carrying the framework name and version
|
|
43
|
+
* @param framework - The expected framework name, eg `"docusaurus"`
|
|
44
|
+
* @param version - The version to compare against
|
|
45
|
+
* @returns A negative number if the framework version is lower, `0` if it
|
|
46
|
+
* matches, a positive number if it is higher, or `undefined` if the framework
|
|
47
|
+
* does not match or carries no parsable version
|
|
48
|
+
*/
|
|
49
|
+
const compareFrameworkVersion = (meta, framework, version) => {
|
|
50
|
+
if (meta?.generatorFrameworkName !== framework) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const parsed = parseFrameworkVersion(meta.generatorFrameworkVersion);
|
|
54
|
+
if (!parsed) {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
if (parsed.major !== version.major) {
|
|
58
|
+
return parsed.major - version.major;
|
|
59
|
+
}
|
|
60
|
+
return typeof version.minor === "number"
|
|
61
|
+
? (parsed.minor ?? 0) - version.minor
|
|
62
|
+
: 0;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Checks that the generator framework declared in `meta` is `framework`, and
|
|
66
|
+
* that its version matches `version`.
|
|
67
|
+
*
|
|
68
|
+
* Only the parts carried by `version` are compared, so `{ major: 2 }` matches
|
|
69
|
+
* any `2.x` release. An unknown, unparsable or mismatched framework version
|
|
70
|
+
* returns `false`.
|
|
71
|
+
*
|
|
72
|
+
* @param meta - Optional metadata carrying the framework name and version
|
|
73
|
+
* @param framework - The expected framework name, eg `"docusaurus"`
|
|
74
|
+
* @param version - The version to match
|
|
75
|
+
* @returns `true` if the framework and its version match
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```js
|
|
79
|
+
* const meta = {
|
|
80
|
+
* generatorFrameworkName: "docusaurus",
|
|
81
|
+
* generatorFrameworkVersion: "2.4.3",
|
|
82
|
+
* };
|
|
83
|
+
*
|
|
84
|
+
* isFrameworkVersion(meta, "docusaurus", { major: 2 }); // true
|
|
85
|
+
* isFrameworkVersion(meta, "docusaurus", { major: 3 }); // false
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
const isFrameworkVersion = (meta, framework, version) => {
|
|
89
|
+
return compareFrameworkVersion(meta, framework, version) === 0;
|
|
90
|
+
};
|
|
91
|
+
exports.isFrameworkVersion = isFrameworkVersion;
|
|
92
|
+
/**
|
|
93
|
+
* Checks that the generator framework declared in `meta` is `framework`, and
|
|
94
|
+
* that its version is `minVersion` or above.
|
|
95
|
+
*
|
|
96
|
+
* An unknown, unparsable or mismatched framework version returns `false`, so
|
|
97
|
+
* callers fall back to the output supported by every version.
|
|
98
|
+
*
|
|
99
|
+
* @param meta - Optional metadata carrying the framework name and version
|
|
100
|
+
* @param framework - The expected framework name, eg `"docusaurus"`
|
|
101
|
+
* @param minVersion - The minimum version required by the caller
|
|
102
|
+
* @returns `true` if the framework matches and its version is high enough
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```js
|
|
106
|
+
* const meta = {
|
|
107
|
+
* generatorFrameworkName: "docusaurus",
|
|
108
|
+
* generatorFrameworkVersion: "3.10.2",
|
|
109
|
+
* };
|
|
110
|
+
*
|
|
111
|
+
* isFrameworkVersionAtLeast(meta, "docusaurus", { major: 3, minor: 10 }); // true
|
|
112
|
+
* isFrameworkVersionAtLeast(meta, "docusaurus", { major: 4 }); // false
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
const isFrameworkVersionAtLeast = (meta, framework, minVersion) => {
|
|
116
|
+
const compared = compareFrameworkVersion(meta, framework, minVersion);
|
|
117
|
+
return typeof compared === "number" && compared >= 0;
|
|
118
|
+
};
|
|
119
|
+
exports.isFrameworkVersionAtLeast = isFrameworkVersionAtLeast;
|
package/dist/vocs/index.d.ts
CHANGED
|
@@ -6,6 +6,21 @@
|
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
8
|
import type { AdmonitionType, Badge, Formatter, Maybe, MDXString, MetaInfo, TypeLink } from "@graphql-markdown/types";
|
|
9
|
+
import { formatMDXEscapedPermalink } from "../defaults";
|
|
10
|
+
/**
|
|
11
|
+
* Formats a permalink for a section header, using the classic `{#id}` syntax
|
|
12
|
+
* escaped to remain valid MDX.
|
|
13
|
+
*
|
|
14
|
+
* Vocs has no custom header id syntax, so the permalink is inert unless a
|
|
15
|
+
* remark plugin is configured. Turn it off with
|
|
16
|
+
* `docOptions.sectionHeaderId: false`.
|
|
17
|
+
*
|
|
18
|
+
* @see https://vocs.dev/docs/markdown
|
|
19
|
+
*
|
|
20
|
+
* @param id - The ID of the section header
|
|
21
|
+
* @returns Formatted permalink string
|
|
22
|
+
*/
|
|
23
|
+
export declare const formatMDXPermalink: typeof formatMDXEscapedPermalink;
|
|
9
24
|
/** MDX import statement and inline component definitions prepended to every generated file. */
|
|
10
25
|
export declare const mdxDeclaration: MDXString;
|
|
11
26
|
/** File extension used for generated pages. */
|
package/dist/vocs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;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/vocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAEL,yBAAyB,EAG1B,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,kCAA4B,CAAC;AAE5D,+FAA+F;AAC/F,eAAO,MAAM,cAAc,EAAE,SAEf,CAAC;AAEf,+CAA+C;AAC/C,eAAO,MAAM,YAAY,EAAG,MAAe,CAAC;AAE5C;;;;;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;;;;GAIG;AACH,eAAO,MAAM,eAAe,qBAAgB,SAE3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,kBAAmB,QAAQ,KAAG,QAKvD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,SACxB,MAAM,eACC,KAAK,CAAC,MAAM,CAAC,KACzB,SAKF,CAAC;AAEF,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,KAAK,CAAC,QAAQ,CAAC,KAAG,SAY5D,CAAC"}
|
package/dist/vocs/index.js
CHANGED
|
@@ -7,10 +7,24 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxExtension = exports.mdxDeclaration = void 0;
|
|
10
|
+
exports.createMDXFormatter = exports.formatMDXSpecifiedByLink = exports.formatMDXFrontmatter = exports.formatMDXDetails = exports.formatMDXNameEntity = exports.formatMDXLink = exports.formatMDXBullet = exports.formatMDXAdmonition = exports.formatMDXBadge = exports.mdxExtension = exports.mdxDeclaration = exports.formatMDXPermalink = void 0;
|
|
11
11
|
const helpers_1 = require("@graphql-markdown/helpers");
|
|
12
12
|
const utils_1 = require("@graphql-markdown/utils");
|
|
13
13
|
const defaults_1 = require("../defaults");
|
|
14
|
+
/**
|
|
15
|
+
* Formats a permalink for a section header, using the classic `{#id}` syntax
|
|
16
|
+
* escaped to remain valid MDX.
|
|
17
|
+
*
|
|
18
|
+
* Vocs has no custom header id syntax, so the permalink is inert unless a
|
|
19
|
+
* remark plugin is configured. Turn it off with
|
|
20
|
+
* `docOptions.sectionHeaderId: false`.
|
|
21
|
+
*
|
|
22
|
+
* @see https://vocs.dev/docs/markdown
|
|
23
|
+
*
|
|
24
|
+
* @param id - The ID of the section header
|
|
25
|
+
* @returns Formatted permalink string
|
|
26
|
+
*/
|
|
27
|
+
exports.formatMDXPermalink = defaults_1.formatMDXEscapedPermalink;
|
|
14
28
|
/** MDX import statement and inline component definitions prepended to every generated file. */
|
|
15
29
|
exports.mdxDeclaration = `
|
|
16
30
|
export const Bullet = () => <><span style={{ fontWeight: 'normal', fontSize: '.5em' }}> ● </span></>
|
|
@@ -92,6 +106,7 @@ const createMDXFormatter = (_meta) => {
|
|
|
92
106
|
formatMDXFrontmatter: defaults_1.formatMDXFrontmatter,
|
|
93
107
|
formatMDXLink: exports.formatMDXLink,
|
|
94
108
|
formatMDXNameEntity: exports.formatMDXNameEntity,
|
|
109
|
+
formatMDXPermalink: exports.formatMDXPermalink,
|
|
95
110
|
formatMDXSpecifiedByLink: defaults_1.formatMDXSpecifiedByLink,
|
|
96
111
|
};
|
|
97
112
|
};
|