@graphql-markdown/printer-legacy 1.17.0 → 1.19.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/README.md +37 -0
- package/dist/common.d.ts +0 -8
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +10 -31
- package/dist/const/options.d.ts +3 -1
- package/dist/const/options.d.ts.map +1 -1
- package/dist/const/options.js +2 -1
- package/dist/decorator.d.ts +174 -0
- package/dist/decorator.d.ts.map +1 -0
- package/dist/decorator.js +494 -0
- package/dist/frontmatter.d.ts.map +1 -1
- package/dist/frontmatter.js +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +42 -10
- package/dist/printer.d.ts +15 -9
- package/dist/printer.d.ts.map +1 -1
- package/dist/printer.js +32 -25
- package/dist/section.d.ts.map +1 -1
- package/dist/section.js +27 -5
- package/package.json +1 -1
- package/dist/directive.d.ts +0 -44
- package/dist/directive.d.ts.map +0 -1
- package/dist/directive.js +0 -110
package/README.md
CHANGED
|
@@ -5,3 +5,40 @@
|
|
|
5
5
|
[](https://sonarcloud.io/summary/new_code?id=graphql-markdown_printer-legacy)
|
|
6
6
|
[](https://sonarcloud.io/summary/new_code?id=graphql-markdown_printer-legacy)
|
|
7
7
|
[](https://dashboard.stryker-mutator.io/reports/github.com/graphql-markdown/graphql-markdown/main?module=printer-legacy)
|
|
8
|
+
|
|
9
|
+
Legacy Docusaurus-flavored MDX printer for GraphQL-Markdown. Converts GraphQL schema types into MDX pages, and is the printer used by default when no `formatter` is configured. New setups should prefer a formatter preset from [`@graphql-markdown/formatters`](https://www.npmjs.com/package/@graphql-markdown/formatters); this package is kept for backward compatibility with existing Docusaurus configurations and for `customDirective`-based decorators.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
npm install @graphql-markdown/printer-legacy
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
`printer-legacy` is typically consumed indirectly through [`@graphql-markdown/core`](https://www.npmjs.com/package/@graphql-markdown/core), which builds a `Printer` instance from the resolved configuration. It can also be used directly:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { Printer } from "@graphql-markdown/printer-legacy";
|
|
23
|
+
|
|
24
|
+
await Printer.init(schema, baseURL, options);
|
|
25
|
+
const page = await Printer.printType("query", queryType, options);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Custom directive decorators
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { buildCustomDirectiveDecorators } from "@graphql-markdown/printer-legacy";
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Documentation
|
|
35
|
+
|
|
36
|
+
- [Configuration Options](https://graphql-markdown.dev/docs/settings)
|
|
37
|
+
- [Custom Directives](https://graphql-markdown.dev/docs/advanced/custom-directive)
|
|
38
|
+
- [Integration with Frameworks](https://graphql-markdown.dev/docs/advanced/integration-with-frameworks)
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
GraphQL-Markdown packages are 100% free and open-source, under the [MIT license](https://github.com/graphql-markdown/graphql-markdown/blob/main/LICENSE).
|
|
43
|
+
|
|
44
|
+
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/common.d.ts
CHANGED
|
@@ -3,14 +3,6 @@
|
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
5
|
import type { MDXString, PrintTypeOptions } from "@graphql-markdown/types";
|
|
6
|
-
/**
|
|
7
|
-
* Prints documentation for custom directives applied to a type.
|
|
8
|
-
*
|
|
9
|
-
* @param type - GraphQL type to get directives from
|
|
10
|
-
* @param options - Printer configuration options
|
|
11
|
-
* @returns Formatted directive documentation string
|
|
12
|
-
*/
|
|
13
|
-
export declare const getCustomDirectivesText: (type: unknown, options?: PrintTypeOptions) => string;
|
|
14
6
|
/**
|
|
15
7
|
* Generates a warning message block in MDX format.
|
|
16
8
|
* @param warningConfig - Warning configuration object with `text` and optional `title` properties
|
package/dist/common.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAEV,SAAS,EACT,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAkCjC;;;;;GAKG;AAEH,eAAO,MAAM,YAAY,oBACN;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,WACzC,gBAAgB,KACxB,MAUF,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,gBAAgB,SACrB,OAAO,WACJ,gBAAgB,KACxB,MAcF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,SACrB,OAAO,WACJ,gBAAgB,WAChB,MAAM,KACd,SAAS,GAAG,MAYd,CAAC"}
|
package/dist/common.js
CHANGED
|
@@ -4,38 +4,11 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.printDescription = exports.printDeprecation = exports.printWarning =
|
|
7
|
+
exports.printDescription = exports.printDeprecation = exports.printWarning = void 0;
|
|
8
8
|
const utils_1 = require("@graphql-markdown/utils");
|
|
9
9
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
10
10
|
const strings_1 = require("./const/strings");
|
|
11
|
-
const
|
|
12
|
-
/**
|
|
13
|
-
* Prints documentation for custom directives applied to a type.
|
|
14
|
-
*
|
|
15
|
-
* @param type - GraphQL type to get directives from
|
|
16
|
-
* @param options - Printer configuration options
|
|
17
|
-
* @returns Formatted directive documentation string
|
|
18
|
-
*/
|
|
19
|
-
// Used only by unit tests for direct whitebox coverage; not part of the production public API.
|
|
20
|
-
const getCustomDirectivesText = (type, options) => {
|
|
21
|
-
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options?.customDirectives);
|
|
22
|
-
if ((0, utils_1.isEmpty)(constDirectiveMap)) {
|
|
23
|
-
return "";
|
|
24
|
-
}
|
|
25
|
-
const content = Object.values(constDirectiveMap)
|
|
26
|
-
.map((constDirectiveOption) => {
|
|
27
|
-
return (0, directive_1.getCustomDirectiveResolver)("descriptor", type, constDirectiveOption, "");
|
|
28
|
-
})
|
|
29
|
-
.filter((text) => {
|
|
30
|
-
return typeof text === "string" && text.length > 0;
|
|
31
|
-
})
|
|
32
|
-
.map((text) => {
|
|
33
|
-
return (0, utils_1.escapeMDX)(text);
|
|
34
|
-
})
|
|
35
|
-
.join(strings_1.MARKDOWN_EOP);
|
|
36
|
-
return `${strings_1.MARKDOWN_EOP}${content}`;
|
|
37
|
-
};
|
|
38
|
-
exports.getCustomDirectivesText = getCustomDirectivesText;
|
|
11
|
+
const decorator_1 = require("./decorator");
|
|
39
12
|
/**
|
|
40
13
|
* Formats a GraphQL type description or falls back to a default message.
|
|
41
14
|
*
|
|
@@ -92,8 +65,14 @@ exports.printDeprecation = printDeprecation;
|
|
|
92
65
|
*/
|
|
93
66
|
const printDescription = (type, options, noText) => {
|
|
94
67
|
const description = formatDescription(type, noText);
|
|
95
|
-
const customDirectives = (0, exports.getCustomDirectivesText)(type, options);
|
|
96
68
|
const deprecation = (0, exports.printDeprecation)(type, options);
|
|
97
|
-
|
|
69
|
+
// `customDirective`'s `descriptor` handlers reach this line via the
|
|
70
|
+
// decorators pipeline (`printSlotDecorators`), not a dedicated call — see
|
|
71
|
+
// `buildCustomDirectiveDecorators` in `./decorator`.
|
|
72
|
+
const decoratorContent = (0, decorator_1.printSlotDecorators)("description", type, options);
|
|
73
|
+
const decorators = decoratorContent.length > 0
|
|
74
|
+
? `${strings_1.MARKDOWN_EOP}${decoratorContent.join(strings_1.MARKDOWN_EOP)}`
|
|
75
|
+
: "";
|
|
76
|
+
return `${deprecation}${description}${decorators}`;
|
|
98
77
|
};
|
|
99
78
|
exports.printDescription = printDescription;
|
package/dist/const/options.d.ts
CHANGED
|
@@ -17,8 +17,10 @@ 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" | "exampleSection" | "formatCategoryFolderName" | "groups" | "level" | "meta" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
|
|
20
|
+
export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "decorators" | "entity" | "exampleSection" | "formatCategoryFolderName" | "groups" | "level" | "meta" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
|
|
21
21
|
collapsible: Maybe<CollapsibleOption>;
|
|
22
|
+
decorators: PrintTypeOptions["decorators"];
|
|
23
|
+
entity: PrintTypeOptions["entity"];
|
|
22
24
|
exampleSection: PrintTypeOptions["exampleSection"];
|
|
23
25
|
groups: Maybe<SchemaEntitiesGroupMap>;
|
|
24
26
|
level: Maybe<SectionLevelValue>;
|
|
@@ -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;AAcj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AY,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,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;CA+BvC,CAAC"}
|
package/dist/const/options.js
CHANGED
|
@@ -33,7 +33,8 @@ exports.DEFAULT_OPTIONS = {
|
|
|
33
33
|
deprecated: exports.PRINT_TYPE_DEFAULT_OPTIONS.deprecated,
|
|
34
34
|
basePath: "/",
|
|
35
35
|
collapsible: undefined,
|
|
36
|
-
|
|
36
|
+
decorators: undefined,
|
|
37
|
+
entity: undefined,
|
|
37
38
|
exampleSection: undefined,
|
|
38
39
|
groups: undefined,
|
|
39
40
|
frontMatter: {},
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module providing predicate-driven decorators for type pages.
|
|
3
|
+
*
|
|
4
|
+
* A decorator (declared in the top-level `decorators` option) is selected by a
|
|
5
|
+
* predicate over the node being printed — by default, every node — and
|
|
6
|
+
* renders its resolved values through a user callback. There is no built-in
|
|
7
|
+
* notion of "this decorator's own directive": a directive-driven decorator
|
|
8
|
+
* selects its nodes with `predicate: hasDirectiveNamed("name")` and reads
|
|
9
|
+
* that directive's argument values, if any, from `resolve` via
|
|
10
|
+
* `@graphql-markdown/graphql`'s `getDirectiveFromSchema` combined with
|
|
11
|
+
* `getTypeDirectiveValues`/`getTypeDirectiveValuesList` — the same public
|
|
12
|
+
* helpers this module uses internally. A decorator with a title becomes a top-level
|
|
13
|
+
* section of the type page; one without renders bare content, placed relative
|
|
14
|
+
* to the built-in sections, or into a named slot such as the heading's
|
|
15
|
+
* metadata line or a member's description.
|
|
16
|
+
*
|
|
17
|
+
* `customDirective` is the deprecated predecessor of this module. It never
|
|
18
|
+
* reaches this module, or any other part of the printer: `@graphql-markdown/core`
|
|
19
|
+
* converts its schema-resolved directive map into decorator declarations
|
|
20
|
+
* (see {@link buildCustomDirectiveDecorators}) once, before the printer is
|
|
21
|
+
* ever invoked, so both options flow through the exact same resolve/render
|
|
22
|
+
* pipeline below — there is one code path for "select nodes by directive,
|
|
23
|
+
* render descriptor text, a badge, or a section", not two.
|
|
24
|
+
*
|
|
25
|
+
* @packageDocumentation
|
|
26
|
+
*/
|
|
27
|
+
import type { CustomDirectiveMap, DecoratorDefinition, Decorators, Maybe, PageSection, PageSections, PrintTypeOptions } from "@graphql-markdown/types";
|
|
28
|
+
import { getSchemaEntity } from "@graphql-markdown/graphql";
|
|
29
|
+
export { getSchemaEntity };
|
|
30
|
+
/**
|
|
31
|
+
* A decorator, resolved from its declaration under `decorators`.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export type ResolvedDecorator = DecoratorDefinition & {
|
|
36
|
+
/** The decorator id — the key under which it was declared. */
|
|
37
|
+
id: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Section/decorator keys owned by the printer, which a decorator cannot claim.
|
|
41
|
+
*
|
|
42
|
+
* Re-exported from the package root: `@graphql-markdown/core`'s
|
|
43
|
+
* `getDecoratorsOption` validates against this same list (plus `"__proto__"`,
|
|
44
|
+
* reserved only there — see that package's own copy of this comment) so the
|
|
45
|
+
* two entry points, config-file validation and building a decorators map
|
|
46
|
+
* directly against the printer API, can't silently drift apart on which
|
|
47
|
+
* names are reserved.
|
|
48
|
+
*/
|
|
49
|
+
export declare const RESERVED_SECTION_NAMES: readonly string[];
|
|
50
|
+
/**
|
|
51
|
+
* Converts the deprecated `customDirective` option's schema-resolved
|
|
52
|
+
* directive map into decorator declarations, so it flows through the exact
|
|
53
|
+
* same resolve/render pipeline as everything declared under `decorators`.
|
|
54
|
+
*
|
|
55
|
+
* Called once by `@graphql-markdown/core`, right after `customDirectives` is
|
|
56
|
+
* schema-resolved, and merged directly into the top-level `decorators`
|
|
57
|
+
* option before it reaches the printer — `customDirective`/`CustomDirectiveMap`
|
|
58
|
+
* never reach this printer package otherwise; only the three decorators
|
|
59
|
+
* built here do, indistinguishable from any other `decorators` entry except
|
|
60
|
+
* for their reserved ids (see {@link CUSTOM_DIRECTIVE_DECORATOR_IDS}).
|
|
61
|
+
*
|
|
62
|
+
* Returns three entries:
|
|
63
|
+
* - `customDirectives`: the built-in "Directives" section, listing every
|
|
64
|
+
* custom directive declared on a type, positioned right after `code`
|
|
65
|
+
* (its fixed position in the pre-decorators built-in section order).
|
|
66
|
+
* - `customDirective:description`: `customDirective`'s `descriptor`
|
|
67
|
+
* handlers, appended as description text (`position: { into: "description" }`).
|
|
68
|
+
* - `customDirective:tags`: `customDirective`'s `tag` handlers, rendered as
|
|
69
|
+
* badges in the metadata line (`position: { into: "tags" }`).
|
|
70
|
+
*
|
|
71
|
+
* All three share one `resolve`, reading every custom directive matched on
|
|
72
|
+
* a node, in schema declaration order. Matching (including wildcard `"*"`
|
|
73
|
+
* precedence — a named handler wins over `"*"`) is already resolved by
|
|
74
|
+
* `getConstDirectiveMap` (fed by `@graphql-markdown/graphql`'s
|
|
75
|
+
* `getCustomDirectives`, which expands a wildcard into concrete
|
|
76
|
+
* per-directive entries upstream), so this reuses that resolution rather
|
|
77
|
+
* than re-implementing it against the generic predicate system.
|
|
78
|
+
*
|
|
79
|
+
* @param customDirectives - the schema-resolved `customDirective` map, or
|
|
80
|
+
* `undefined`/empty when the option is not in use.
|
|
81
|
+
*
|
|
82
|
+
* @returns the three decorators, or `{}` when `customDirectives` is empty.
|
|
83
|
+
*
|
|
84
|
+
*/
|
|
85
|
+
export declare const buildCustomDirectiveDecorators: (customDirectives: Maybe<CustomDirectiveMap>) => Decorators;
|
|
86
|
+
/**
|
|
87
|
+
* Builds the example section as a decorator definition.
|
|
88
|
+
*
|
|
89
|
+
* The example section is a specialized decorator: it is driven by a schema
|
|
90
|
+
* directive, named by [`printTypeOptions.exampleSection`](https://graphql-markdown.dev/docs/settings#printtypeoptions),
|
|
91
|
+
* and rendered as a code block.
|
|
92
|
+
*
|
|
93
|
+
* It resolves its own value rather than gating on a directive by name,
|
|
94
|
+
* because an example is also derived from the fields of a type carrying no
|
|
95
|
+
* example directive itself — the directive lookup (which schema directive
|
|
96
|
+
* name to use, from `printTypeOptions.exampleSection`) belongs to
|
|
97
|
+
* {@link printExample} alone.
|
|
98
|
+
*
|
|
99
|
+
* @param options - the print options in effect.
|
|
100
|
+
*
|
|
101
|
+
* @returns the example decorator definition.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* const section = getExampleSectionDefinition(options);
|
|
106
|
+
* const example = printDecorator(type, section, options);
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
*/
|
|
110
|
+
export declare const getExampleSectionDefinition: () => ResolvedDecorator;
|
|
111
|
+
/**
|
|
112
|
+
* Prints a single decorator for a type, as a titled page section.
|
|
113
|
+
*
|
|
114
|
+
* Reserved ids are filtered by `getDeclaredDecorators`, not here: the built-in
|
|
115
|
+
* sections are themselves declared with a reserved id.
|
|
116
|
+
*
|
|
117
|
+
* @param type - the GraphQL type being printed.
|
|
118
|
+
* @param decorator - the resolved decorator declaration.
|
|
119
|
+
* @param options - the print options in effect.
|
|
120
|
+
*
|
|
121
|
+
* @returns the rendered page section, or `undefined` when nothing to print.
|
|
122
|
+
*
|
|
123
|
+
*/
|
|
124
|
+
export declare const printDecorator: (type: unknown, decorator: ResolvedDecorator, options: PrintTypeOptions) => Maybe<PageSection>;
|
|
125
|
+
/**
|
|
126
|
+
* Prints every decorator declared in the print options, excluding those
|
|
127
|
+
* targeting a named slot (`position: { into }`) — those are not part of the
|
|
128
|
+
* page's section order and are printed separately, into their slot.
|
|
129
|
+
*
|
|
130
|
+
* Every declared decorator yields an entry, so that composition hooks can
|
|
131
|
+
* restore one which rendered no content. Decorators with a reserved or
|
|
132
|
+
* repeated id are dropped.
|
|
133
|
+
*
|
|
134
|
+
* @param type - the GraphQL type being printed.
|
|
135
|
+
* @param options - the print options in effect.
|
|
136
|
+
*
|
|
137
|
+
* @returns a map of decorator id to rendered section, empty when none is declared.
|
|
138
|
+
*
|
|
139
|
+
*/
|
|
140
|
+
export declare const printDecorators: (type: unknown, options: PrintTypeOptions) => PageSections;
|
|
141
|
+
/**
|
|
142
|
+
* Prints every decorator declared for a named slot (`position: { into: slot }`),
|
|
143
|
+
* as raw content rather than a page section — used to splice decorator output
|
|
144
|
+
* into a slot outside the page's section order, such as the metadata line of a
|
|
145
|
+
* type or field heading, or a member's description.
|
|
146
|
+
*
|
|
147
|
+
* @param slot - the slot name (matches a decorator's `position.into`).
|
|
148
|
+
* @param type - the GraphQL type being printed.
|
|
149
|
+
* @param options - the print options in effect.
|
|
150
|
+
*
|
|
151
|
+
* @returns the rendered content for every decorator targeting `slot`, in
|
|
152
|
+
* declaration order; empty when none target it or render no content.
|
|
153
|
+
*
|
|
154
|
+
*/
|
|
155
|
+
export declare const printSlotDecorators: (slot: string, type: unknown, options: PrintTypeOptions) => string[];
|
|
156
|
+
/**
|
|
157
|
+
* Splices the decorators into the built-in section order.
|
|
158
|
+
*
|
|
159
|
+
* A decorator is placed after or before the section named by its `position`,
|
|
160
|
+
* and appended last when `position` is absent or names an unknown section.
|
|
161
|
+
* A decorator using `into` (a named slot outside the page section order — see
|
|
162
|
+
* {@link DecoratorPosition}) is excluded entirely: it is not part of the page
|
|
163
|
+
* section order and is printed separately, into its slot. Decorators are
|
|
164
|
+
* placed in declaration order, so a decorator may target a previously placed
|
|
165
|
+
* one.
|
|
166
|
+
*
|
|
167
|
+
* @param sectionOrder - the built-in section order.
|
|
168
|
+
* @param options - the print options in effect.
|
|
169
|
+
*
|
|
170
|
+
* @returns the section order including the decorators.
|
|
171
|
+
*
|
|
172
|
+
*/
|
|
173
|
+
export declare const getDecoratorsOrder: (sectionOrder: readonly string[], options: PrintTypeOptions) => string[];
|
|
174
|
+
//# sourceMappingURL=decorator.d.ts.map
|
|
@@ -0,0 +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;AAgBnC,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,GAAG;IACpD,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;;;;;;;;G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