@graphql-markdown/printer-legacy 1.19.3 → 1.20.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/const/options.d.ts +2 -1
- package/dist/const/options.d.ts.map +1 -1
- package/dist/const/options.js +1 -0
- package/dist/const/strings.d.ts +10 -4
- package/dist/const/strings.d.ts.map +1 -1
- package/dist/const/strings.js +19 -5
- package/dist/decorator.d.ts.map +1 -1
- package/dist/decorator.js +6 -3
- package/dist/graphql/scalar.d.ts +4 -1
- package/dist/graphql/scalar.d.ts.map +1 -1
- package/dist/graphql/scalar.js +18 -4
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +7 -2
- package/dist/printer.d.ts +11 -0
- package/dist/printer.d.ts.map +1 -1
- package/dist/printer.js +22 -2
- package/package.json +5 -5
package/dist/const/options.d.ts
CHANGED
|
@@ -17,11 +17,12 @@ export declare const PRINT_TYPE_DEFAULT_OPTIONS: Required<Omit<PrinterConfigPrin
|
|
|
17
17
|
/**
|
|
18
18
|
* Clean runtime options passed through the printer.
|
|
19
19
|
*/
|
|
20
|
-
export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "decorators" | "entity" | "exampleSection" | "formatCategoryFolderName" | "groups" | "level" | "meta" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
|
|
20
|
+
export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "decorators" | "entity" | "exampleSection" | "formatCategoryFolderName" | "formatMDXTitle" | "groups" | "level" | "meta" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
|
|
21
21
|
collapsible: Maybe<CollapsibleOption>;
|
|
22
22
|
decorators: PrintTypeOptions["decorators"];
|
|
23
23
|
entity: PrintTypeOptions["entity"];
|
|
24
24
|
exampleSection: PrintTypeOptions["exampleSection"];
|
|
25
|
+
formatMDXTitle: PrintTypeOptions["formatMDXTitle"];
|
|
25
26
|
groups: Maybe<SchemaEntitiesGroupMap>;
|
|
26
27
|
level: Maybe<SectionLevelValue>;
|
|
27
28
|
onlyDocDirectives: GraphQLDirective[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/const/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,KAAK,EACL,gBAAgB,EAChB,6BAA6B,EAC7B,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AAcjC,oBAAY,aAAa;IACvB,GAAG,QAAQ;IAEX,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AAED,oBAAY,aAAa;IACvB;;OAEG;IAEH,IAAI,KAAK;IACT,KAAK,MAAM;CACZ;AAED,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAC/C,IAAI,CAAC,6BAA6B,EAAE,gBAAgB,CAAC,CACtD,GAAG;IACF,cAAc,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAQpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CACpC,IAAI,CACF,gBAAgB,EACd,aAAa,GACb,YAAY,GACZ,QAAQ,GACR,gBAAgB,GAChB,0BAA0B,GAC1B,QAAQ,GACR,OAAO,GACP,MAAM,GACN,mBAAmB,GACnB,YAAY,GACZ,QAAQ,GACR,mBAAmB,CACtB,CACF,GAAG;IACF,WAAW,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACtC,UAAU,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC3C,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACnC,cAAc,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACnD,MAAM,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACtC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAChC,iBAAiB,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,MAAM,EAAE,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACtC,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAChC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IACtC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC7B,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;CAgCvC,CAAC"}
|
package/dist/const/options.js
CHANGED
package/dist/const/strings.d.ts
CHANGED
|
@@ -16,8 +16,14 @@ export declare const DEPRECATED: "deprecated";
|
|
|
16
16
|
export declare const NON_NULL: "non-null";
|
|
17
17
|
/** Default placeholder when no schema description is provided. */
|
|
18
18
|
export declare const NO_DESCRIPTION_TEXT: "No description";
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Wraps code in a fenced code block. The fence is longer than any run of
|
|
21
|
+
* backticks in the code, so schema text inside cannot close it early.
|
|
22
|
+
*
|
|
23
|
+
* @param code - the code to wrap.
|
|
24
|
+
* @param language - the fence language, defaults to `graphql`.
|
|
25
|
+
*
|
|
26
|
+
* @returns the fenced code block, surrounded by line breaks.
|
|
27
|
+
*/
|
|
28
|
+
export declare const printCodeBlock: (code: string, language?: string) => string;
|
|
23
29
|
//# sourceMappingURL=strings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/const/strings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,YAAY,GACb,MAAM,yBAAyB,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,cAYrB,CAAC;AAEX,iEAAiE;AACjE,eAAO,MAAM,UAAU,EAAG,YAAqB,CAAC;AAEhD,4DAA4D;AAC5D,eAAO,MAAM,QAAQ,EAAG,UAAmB,CAAC;AAK5C,kEAAkE;AAClE,eAAO,MAAM,mBAAmB,EAAG,gBAAyB,CAAC;AAE7D
|
|
1
|
+
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/const/strings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAG9D,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,YAAY,GACb,MAAM,yBAAyB,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,cAYrB,CAAC;AAEX,iEAAiE;AACjE,eAAO,MAAM,UAAU,EAAG,YAAqB,CAAC;AAEhD,4DAA4D;AAC5D,eAAO,MAAM,QAAQ,EAAG,UAAmB,CAAC;AAK5C,kEAAkE;AAClE,eAAO,MAAM,mBAAmB,EAAG,gBAAyB,CAAC;AAE7D;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,SACnB,MAAM,aACF,MAAM,KACf,MAUF,CAAC"}
|
package/dist/const/strings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.printCodeBlock = exports.NO_DESCRIPTION_TEXT = exports.NON_NULL = exports.DEPRECATED = exports.ROOT_TYPE_LOCALE = exports.MARKDOWN_EOP = exports.MARKDOWN_EOL = exports.MARKDOWN_CODE_INDENTATION = void 0;
|
|
4
4
|
const utils_1 = require("@graphql-markdown/utils");
|
|
5
5
|
var utils_2 = require("@graphql-markdown/utils");
|
|
6
6
|
Object.defineProperty(exports, "MARKDOWN_CODE_INDENTATION", { enumerable: true, get: function () { return utils_2.MARKDOWN_CODE_INDENTATION; } });
|
|
@@ -30,7 +30,21 @@ exports.NON_NULL = "non-null";
|
|
|
30
30
|
const GRAPHQL = "graphql";
|
|
31
31
|
/** Default placeholder when no schema description is provided. */
|
|
32
32
|
exports.NO_DESCRIPTION_TEXT = "No description";
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Wraps code in a fenced code block. The fence is longer than any run of
|
|
35
|
+
* backticks in the code, so schema text inside cannot close it early.
|
|
36
|
+
*
|
|
37
|
+
* @param code - the code to wrap.
|
|
38
|
+
* @param language - the fence language, defaults to `graphql`.
|
|
39
|
+
*
|
|
40
|
+
* @returns the fenced code block, surrounded by line breaks.
|
|
41
|
+
*/
|
|
42
|
+
const printCodeBlock = (code, language = GRAPHQL) => {
|
|
43
|
+
const char = utils_1.MARKDOWN_CODE_SNIPPET[0];
|
|
44
|
+
const longestRun = Math.max(0, ...(code.match(new RegExp(`${char}+`, "g")) ?? []).map((run) => {
|
|
45
|
+
return run.length;
|
|
46
|
+
}));
|
|
47
|
+
const fence = char.repeat(Math.max(3, longestRun + 1));
|
|
48
|
+
return `${utils_1.MARKDOWN_EOL}${fence}${language}${utils_1.MARKDOWN_EOL}${code}${utils_1.MARKDOWN_EOL}${fence}${utils_1.MARKDOWN_EOL}`;
|
|
49
|
+
};
|
|
50
|
+
exports.printCodeBlock = printCodeBlock;
|
package/dist/decorator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../src/decorator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAEV,kBAAkB,EAIlB,mBAAmB,EACnB,UAAU,EAEV,KAAK,EACL,WAAW,EACX,YAAY,EACZ,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAGL,eAAe,EAChB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../src/decorator.ts"],"names":[],"mappings":"AAAA;;;;;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"metatags",
|
|
51
51
|
"mdxDeclaration",
|
|
52
|
+
"title",
|
|
52
53
|
"tags",
|
|
53
54
|
"description",
|
|
54
55
|
"code",
|
|
@@ -96,7 +97,9 @@ const getCustomDirectiveResolver = (resolver, type, constDirectiveOption, fallba
|
|
|
96
97
|
};
|
|
97
98
|
/**
|
|
98
99
|
* Prints a single custom directive entry as a Markdown string, for the
|
|
99
|
-
* built-in "Directives" section.
|
|
100
|
+
* built-in "Directives" section. The descriptor output is treated as text and
|
|
101
|
+
* escaped with `escapeMDX`, like the `customDirective:description` slot, so it
|
|
102
|
+
* cannot inject HTML, JSX or MDX into the page.
|
|
100
103
|
*
|
|
101
104
|
* @internal
|
|
102
105
|
*/
|
|
@@ -109,7 +112,7 @@ const printCustomDirective = (type, constDirectiveOption, options) => {
|
|
|
109
112
|
if (typeof description !== "string") {
|
|
110
113
|
return undefined;
|
|
111
114
|
}
|
|
112
|
-
return `${options_ts_1.SectionLevels.LEVEL.repeat(4)} ${typeNameLink}${strings_ts_1.MARKDOWN_EOL} ${description}${strings_ts_1.MARKDOWN_EOL} `;
|
|
115
|
+
return `${options_ts_1.SectionLevels.LEVEL.repeat(4)} ${typeNameLink}${strings_ts_1.MARKDOWN_EOL} ${(0, utils_1.escapeMDX)(description)}${strings_ts_1.MARKDOWN_EOL} `;
|
|
113
116
|
};
|
|
114
117
|
/**
|
|
115
118
|
* Converts the deprecated `customDirective` option's schema-resolved
|
|
@@ -248,7 +251,7 @@ const getExampleSectionDefinition = () => {
|
|
|
248
251
|
return example ? [{ example }] : [];
|
|
249
252
|
},
|
|
250
253
|
render: (values) => {
|
|
251
|
-
return
|
|
254
|
+
return (0, strings_ts_1.printCodeBlock)(values[0].example);
|
|
252
255
|
},
|
|
253
256
|
};
|
|
254
257
|
};
|
package/dist/graphql/scalar.d.ts
CHANGED
|
@@ -5,9 +5,12 @@
|
|
|
5
5
|
import type { PrintTypeOptions, PageSection, Maybe } from "@graphql-markdown/types";
|
|
6
6
|
/**
|
|
7
7
|
* Generates markdown documentation for a scalar type's specification URL.
|
|
8
|
+
* Only absolute http(s) URLs are printed; the URL is normalized (`URL#href`, which
|
|
9
|
+
* percent-encodes characters such as `"`, `<`, `>` and spaces). Any other value
|
|
10
|
+
* prints no specification section.
|
|
8
11
|
* @param type - The GraphQL scalar type object
|
|
9
12
|
* @param options - Options for printing type information
|
|
10
|
-
* @returns A specification PageSection, or undefined when no URL exists
|
|
13
|
+
* @returns A specification PageSection, or undefined when no valid http(s) URL exists
|
|
11
14
|
*/
|
|
12
15
|
export declare const printSpecification: (type: unknown, options: PrintTypeOptions) => Maybe<PageSection>;
|
|
13
16
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../../src/graphql/scalar.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,KAAK,EACN,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../../src/graphql/scalar.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,KAAK,EACN,MAAM,yBAAyB,CAAC;AAMjC;;;;;;;;GAQG;AAEH,eAAO,MAAM,kBAAkB,SACvB,OAAO,WACJ,gBAAgB,KACxB,KAAK,CAAC,WAAW,CAyBnB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,SACxB,OAAO,WACJ,gBAAgB,KACxB,KAAK,CAAC,WAAW,CAEnB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,SACpB,OAAO,YACH,gBAAgB,KACzB,MAEF,CAAC"}
|
package/dist/graphql/scalar.js
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.printCodeScalar = exports.printScalarMetadata = exports.printSpecification = void 0;
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
|
+
const SPECIFIED_BY_PROTOCOLS = new Set(["http:", "https:"]);
|
|
5
6
|
/**
|
|
6
7
|
* Generates markdown documentation for a scalar type's specification URL.
|
|
8
|
+
* Only absolute http(s) URLs are printed; the URL is normalized (`URL#href`, which
|
|
9
|
+
* percent-encodes characters such as `"`, `<`, `>` and spaces). Any other value
|
|
10
|
+
* prints no specification section.
|
|
7
11
|
* @param type - The GraphQL scalar type object
|
|
8
12
|
* @param options - Options for printing type information
|
|
9
|
-
* @returns A specification PageSection, or undefined when no URL exists
|
|
13
|
+
* @returns A specification PageSection, or undefined when no valid http(s) URL exists
|
|
10
14
|
*/
|
|
11
|
-
//
|
|
15
|
+
// Exported for direct unit testing; reached in production through printScalarMetadata.
|
|
12
16
|
const printSpecification = (type, options) => {
|
|
13
17
|
if (typeof type !== "object" ||
|
|
14
18
|
type === null ||
|
|
@@ -16,9 +20,19 @@ const printSpecification = (type, options) => {
|
|
|
16
20
|
typeof type.specifiedByURL !== "string") {
|
|
17
21
|
return undefined;
|
|
18
22
|
}
|
|
19
|
-
|
|
23
|
+
let href;
|
|
24
|
+
try {
|
|
25
|
+
const parsed = new URL(type.specifiedByURL);
|
|
26
|
+
if (!SPECIFIED_BY_PROTOCOLS.has(parsed.protocol)) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
href = parsed.href;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
20
34
|
return {
|
|
21
|
-
title: options.formatMDXSpecifiedByLink(
|
|
35
|
+
title: options.formatMDXSpecifiedByLink(href),
|
|
22
36
|
level: 3,
|
|
23
37
|
};
|
|
24
38
|
};
|
package/dist/link.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO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gBAAgB,KACxB,KAAK,CAAC,QAAQ,CAUhB,CAAC;AAEF;;;;;;GAMG;AAEH,eAAO,MAAM,mBAAmB,SACxB,OAAO,SACP,KAAK,CAAC,MAAM,CAAC,KAClB,MAkBF,CAAC;AAoBF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,OACpB,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,WACf,gBAAgB,KACxB,MAqCF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,SACpB,OAAO,WACJ,gBAAgB,KACxB,SAAS,GAAG,MAWd,CAAC"}
|
package/dist/link.js
CHANGED
|
@@ -330,8 +330,13 @@ const printLink = (arg, options) => {
|
|
|
330
330
|
const printFormattedLink = (text, link) => {
|
|
331
331
|
// create a permalink if url is not provided or is just a hash
|
|
332
332
|
if ((!link.url || link.url === "#") && typeof link.id === "string") {
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
// without section header ids, the heading id is generated by the
|
|
334
|
+
// framework from the whole heading text (badges included), so there is
|
|
335
|
+
// no known anchor to link to: print the text alone, not a dead `#` link
|
|
336
|
+
if (!options.sectionHeaderId) {
|
|
337
|
+
return text;
|
|
338
|
+
}
|
|
339
|
+
return `[${text}](#${link.id})`;
|
|
335
340
|
}
|
|
336
341
|
return `[${text}](${link.url})`;
|
|
337
342
|
};
|
package/dist/printer.d.ts
CHANGED
|
@@ -78,6 +78,17 @@ export declare class Printer implements IPrinter {
|
|
|
78
78
|
* @returns Formatted header string with optional frontmatter
|
|
79
79
|
*/
|
|
80
80
|
static readonly printHeader: (id: string, title: string, options: PrintTypeOptions) => string;
|
|
81
|
+
/**
|
|
82
|
+
* Prints the visible page title, using the formatter `formatMDXTitle`.
|
|
83
|
+
*
|
|
84
|
+
* Independent of the frontmatter: frameworks that render the frontmatter
|
|
85
|
+
* `title` themselves provide no `formatMDXTitle`, and nothing is printed.
|
|
86
|
+
*
|
|
87
|
+
* @param title - Display title for the type
|
|
88
|
+
* @param options - Printer configuration options
|
|
89
|
+
* @returns Formatted page title, or an empty string
|
|
90
|
+
*/
|
|
91
|
+
static readonly printTitle: (title: string, options: PrintTypeOptions) => string;
|
|
81
92
|
/**
|
|
82
93
|
* Prints the GraphQL type definition as code block
|
|
83
94
|
*
|
package/dist/printer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,KAAK,EAEL,SAAS,EACT,aAAa,EACb,QAAQ,EACR,KAAK,EACL,SAAS,EACT,WAAW,EAEX,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"printer.d.ts","sourceRoot":"","sources":["../src/printer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,KAAK,EAEL,SAAS,EACT,aAAa,EACb,QAAQ,EACR,KAAK,EACL,SAAS,EACT,WAAW,EAEX,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AAkDjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAIL,eAAe,EAEhB,MAAM,gBAAgB,CAAC;AAiFxB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,OAAQ,YAAW,QAAQ;IACtC;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,gBAAgB,CAAoB;IAE7E;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,eAAe,CAAmB;IAE1E,OAAO,CAAC,MAAM,CAAC,aAAa,CAA6B;IAEzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAoC;IAE3D,OAAO,CAAC,MAAM,CAAC,eAAe,CAA0B;IAExD;;OAEG;IACH,MAA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C,QAAQ,CAAC,uBAAuB,CAO7C;IAEF;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAgBlD;IAEF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAY1C;CACH"}
|
package/dist/printer.js
CHANGED
|
@@ -26,6 +26,7 @@ const TYPE_PAGE_HEADER_ORDER = [
|
|
|
26
26
|
"header",
|
|
27
27
|
"metatags",
|
|
28
28
|
"mdxDeclaration",
|
|
29
|
+
"title",
|
|
29
30
|
];
|
|
30
31
|
const TYPE_PAGE_SECTION_ORDER = [
|
|
31
32
|
"tags",
|
|
@@ -201,11 +202,25 @@ class Printer {
|
|
|
201
202
|
*/
|
|
202
203
|
static printHeader = (id, title, options) => {
|
|
203
204
|
if (options.frontMatter === false) {
|
|
204
|
-
|
|
205
|
+
// the formatter page title, if any, is printed by `printTitle`
|
|
206
|
+
return options.formatMDXTitle ? "" : `# ${title}${strings_ts_1.MARKDOWN_EOP}`;
|
|
205
207
|
}
|
|
206
208
|
const fmOptions = options.frontMatter ?? options_ts_1.DEFAULT_OPTIONS.frontMatter;
|
|
207
209
|
return (0, frontmatter_ts_1.printFrontMatter)(title, { ...fmOptions, id }, options);
|
|
208
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* Prints the visible page title, using the formatter `formatMDXTitle`.
|
|
213
|
+
*
|
|
214
|
+
* Independent of the frontmatter: frameworks that render the frontmatter
|
|
215
|
+
* `title` themselves provide no `formatMDXTitle`, and nothing is printed.
|
|
216
|
+
*
|
|
217
|
+
* @param title - Display title for the type
|
|
218
|
+
* @param options - Printer configuration options
|
|
219
|
+
* @returns Formatted page title, or an empty string
|
|
220
|
+
*/
|
|
221
|
+
static printTitle = (title, options) => {
|
|
222
|
+
return options.formatMDXTitle?.(title) ?? "";
|
|
223
|
+
};
|
|
209
224
|
/**
|
|
210
225
|
* Prints the GraphQL type definition as code block
|
|
211
226
|
*
|
|
@@ -243,7 +258,7 @@ class Printer {
|
|
|
243
258
|
default:
|
|
244
259
|
code = `"${(0, graphql_1.getTypeName)(type)}" not supported`;
|
|
245
260
|
}
|
|
246
|
-
return strings_ts_1.
|
|
261
|
+
return (0, strings_ts_1.printCodeBlock)(code.trim());
|
|
247
262
|
};
|
|
248
263
|
/**
|
|
249
264
|
* Formats a single badge into MDX string format
|
|
@@ -448,6 +463,11 @@ class Printer {
|
|
|
448
463
|
relations: Printer.normalizePageSection(relations),
|
|
449
464
|
...Printer.printDecorators(type, printTypeOptions),
|
|
450
465
|
};
|
|
466
|
+
// The visible page title follows the header sections (frontmatter,
|
|
467
|
+
// metatags and MDX imports), whatever the frontmatter option.
|
|
468
|
+
sections.title = {
|
|
469
|
+
content: Printer.printTitle((0, graphql_1.getTypeName)(type), printTypeOptions),
|
|
470
|
+
};
|
|
451
471
|
let sectionOrder = (0, decorator_ts_1.getDecoratorsOrder)(TYPE_PAGE_SECTION_ORDER, printTypeOptions);
|
|
452
472
|
// Emit BEFORE_COMPOSE_PAGE_TYPE event if emitter is configured
|
|
453
473
|
if (Printer.eventEmitter) {
|
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.20.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"test:watch": "vitest --watch"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@graphql-markdown/formatters": "^1.2.
|
|
69
|
-
"@graphql-markdown/graphql": "^1.3.
|
|
70
|
-
"@graphql-markdown/types": "^1.
|
|
71
|
-
"@graphql-markdown/utils": "^1.14.
|
|
68
|
+
"@graphql-markdown/formatters": "^1.2.3",
|
|
69
|
+
"@graphql-markdown/graphql": "^1.3.6",
|
|
70
|
+
"@graphql-markdown/types": "^1.18.0",
|
|
71
|
+
"@graphql-markdown/utils": "^1.14.3"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@graphql-markdown/tooling-config": "^1.0.0"
|