@xyd-js/uniform 0.1.0-xyd.2 → 0.1.0-xyd.3
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/content.cjs +133 -0
- package/dist/content.cjs.map +1 -0
- package/dist/content.d.cts +4 -0
- package/dist/content.d.ts +4 -0
- package/dist/content.js +95 -0
- package/dist/content.js.map +1 -0
- package/dist/index.cjs +173 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +27 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +134 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown.cjs +270 -0
- package/dist/markdown.cjs.map +1 -0
- package/dist/markdown.d.cts +6 -0
- package/dist/markdown.d.ts +6 -0
- package/dist/markdown.js +232 -0
- package/dist/markdown.js.map +1 -0
- package/dist/types-C8Pm_zQH.d.cts +80 -0
- package/dist/types-C8Pm_zQH.d.ts +80 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/types.ts"],"sourcesContent":["// Define the new PluginV type with a callback function that returns another function\nimport {Reference} from \"./types\";\n\n// Define the new PluginV type with a callback function that returns another function\nexport type UniformPlugin<T> = (cb: (cb: () => T) => void) => (ref: Reference) => void;\n\n// Utility type to infer if a type is an array and avoid wrapping it into an array twice\ntype NormalizeArray<T> = T extends Array<infer U> ? U[] : T;\n\n// Infer the return type of the plugin callback properly and normalize array types\ntype PluginResult<T extends UniformPlugin<any>> = T extends UniformPlugin<infer R> ? R : never;\n\n// Merge all plugin return types into a single object and normalize arrays\ntype MergePluginResults<T extends UniformPlugin<any>[]> = {\n [K in keyof UnionToIntersection<PluginResult<T[number]>>]: NormalizeArray<UnionToIntersection<PluginResult<T[number]>>[K]>\n};\n\n// Utility type to handle intersection to an object type\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;\n\n// Implement the uniform function\nexport default function uniform<T extends UniformPlugin<any>[]>(\n references: Reference[],\n config: { plugins: T }\n) {\n // Infer the merged result type from all plugins\n type ResultType = MergePluginResults<T>;\n\n // Initialize the response with a type-safe out object\n const response: {\n references: Reference[]\n out: { [K in keyof ResultType]: ResultType[K] }\n } = {\n references,\n out: {} as { [K in keyof ResultType]: ResultType[K] }\n };\n\n\n const finishCallbacks = new Set();\n\n config.plugins.forEach((plugin) => {\n const call = plugin(cb => {\n finishCallbacks.add(cb);\n })\n\n references.forEach((ref) => {\n call(ref)\n });\n })\n\n finishCallbacks.forEach(cb => {\n if (typeof cb === \"function\") {\n const resp = cb()\n if (typeof resp !== \"object\") {\n throw new Error(`Invalid callback return type: ${typeof resp}`)\n }\n\n response.out = {\n ...response.out,\n ...resp\n }\n } else {\n throw new Error(`Invalid callback type: ${typeof cb}`)\n }\n });\n\n return response;\n}\n\n// Example usage\n// const examplePlugin: UniformPlugin<{ value: boolean }> = (cb) => {\n// return (ref: Reference) => {\n// };\n// };\n// function examplePlugin(cb: (cb: () => { value: boolean }) => void) {\n// cb(() => ({\n// value: true,\n// }));\n//\n// return (ref: Reference) => {\n//\n// };\n// }\n// const response = uniform([/* references */], {\n// plugins: [examplePlugin],\n// });\n// response.out\n","import path from 'path';\nimport matter from 'gray-matter';\nimport {Sidebar, FrontMatter, PageFrontMatter} from \"@xyd-js/core\";\n\nimport {Reference} from \"./types\";\nimport uniform from \"./index\";\n\n// interface UniformFrontMatter extends FrontMatter { // TODO: it's concept only\n// scopes?: string\n// }\n\ntype GroupMap = {\n [key: string]: {\n __groups: GroupMap\n pages: Set<string>\n }\n}\n\nexport interface pluginNavigationOptions {\n urlPrefix: string\n}\n\nexport function pluginNavigation(options: pluginNavigationOptions) {\n if (!options.urlPrefix) {\n throw new Error(\"urlPrefix is required\")\n }\n\n return function pluginNavigationInner(cb: (cb: () => {\n pageFrontMatter: PageFrontMatter\n sidebar: Sidebar[]\n }) => void) {\n const pageFrontMatter: PageFrontMatter = {}\n const groupMaps: GroupMap = {}\n\n cb(() => {\n return {\n pageFrontMatter: pageFrontMatter,\n sidebar: convertGroupMapsToNavigations(groupMaps) as Sidebar[]\n }\n })\n\n return (ref: Reference) => {\n const content = matter(ref.description || \"\") // TODO: pluginMatter before?\n\n if (content.data) {\n const data = content.data as FrontMatter\n\n const pagePath = path.join(options.urlPrefix, ref.canonical)\n\n if (data.title) {\n pageFrontMatter[pagePath] = {\n title: data.title,\n }\n }\n\n if (data.group) {\n if (typeof content?.data?.group === \"string\") {\n // TODO: seek nested group (it's not always from 0)\n throw new Error(\"group as string is not supported yet\")\n }\n\n content.data.group.reduce((groups: GroupMap, group: string, i: number) => {\n if (!groups[group]) {\n groups[group] = {\n __groups: {},\n pages: new Set()\n }\n }\n\n if (i === content.data.group.length - 1) {\n groups[group].pages.add(pagePath)\n }\n\n return groups[group].__groups\n }, groupMaps)\n }\n\n // back description to original without frontmatter\n ref.description = content.content\n }\n }\n }\n}\n\n\nfunction convertGroupMapsToNavigations(groupMaps: GroupMap): Sidebar[] {\n const nav: Sidebar[] = []\n\n Object.keys(groupMaps).map((groupName) => {\n const current = groupMaps[groupName]\n\n const pages: string[] | Sidebar[] = []\n\n current.pages.forEach((page: string) => {\n pages.push(page)\n })\n\n if (Object.keys(current.__groups).length) {\n const subNav: Sidebar = {\n group: groupName,\n pages: convertGroupMapsToNavigations(current.__groups)\n }\n\n nav.push(subNav)\n } else {\n nav.push({\n group: groupName,\n pages,\n })\n }\n })\n\n return nav\n}\n\n// example usage:\n// const response = uniform([/* references */], {\n// plugins: [pluginNavigation({\n// urlPrefix: \"/docs\"\n// })],\n// });\n\n\n","// TODO: concept only\nexport enum ReferenceCategory {\n // for React\n COMPONENTS = \"components\",\n HOOKS = \"hooks\",\n // end for React\n\n // for API\n REST = \"rest\",\n GRAPHQL = \"graphql\",\n // end for API\n\n // for code\n FUNCTIONS = \"functions\",\n //\n}\n\n// TODO: concept only\nexport enum ReferenceType {\n // for React\n COMPONENT = \"component\",\n HOOK = \"hook\",\n // end for React\n\n // for API\n REST_HTTP_GET = \"rest_get\",\n REST_HTTP_POST = \"rest_post\",\n REST_HTTP_PUT = \"rest_put\",\n REST_HTTP_PATCH = \"rest_patch\",\n REST_HTTP_DELETE = \"rest_delete\",\n // ---\n GRAPHQL_QUERY = \"graphql_query\",\n GRAPHQL_MUTATION = \"graphql_mutation\",\n // end for API\n\n // for code\n FUNCTION_JS = \"function_js\",\n // end for code\n}\n\nexport interface GraphQLReferenceContext {\n}\n\n// TODO: custom value?\nexport interface OpenAPIReferenceContext {\n method: string;\n\n path: string;\n}\n\nexport type ReferenceContext = GraphQLReferenceContext | OpenAPIReferenceContext;\n\nexport interface ExampleRoot {\n groups: ExampleGroup[];\n}\n\nexport interface ExampleGroup {\n description?: string;\n\n examples: Example[];\n}\n\nexport interface Example {\n description?: string; // TODO: replace with title ?\n\n codeblock: CodeBlock;\n}\n\nexport interface CodeBlock {\n title?: string;\n\n tabs: CodeBlockTab[];\n}\n\nexport interface GraphQLExampleContext {\n schema?: any; // TODO:\n}\n\nexport interface OpenAPIExampleContext {\n status?: number;\n\n content?: string;\n}\n\nexport type ExampleContext = GraphQLExampleContext | OpenAPIExampleContext;\n\nexport interface CodeBlockTab {\n // title of the tab e.g \"JavaScript\"\n title: string;\n\n // code in the tab e.g \"console.log('Hello World')\"\n code: string\n \n // language of the code e.g \"js\"\n language: string;\n\n // context of the generation method e.g openapi or graphql\n context?: ExampleContext;\n}\n\nexport interface Reference {\n title: string;\n description: string;\n canonical: string;\n\n definitions: Definition[]\n examples: ExampleRoot\n\n category?: ReferenceCategory; // TODO: do we need that?\n type?: ReferenceType; // TODO: do we need that?\n context?: ReferenceContext;\n}\n\nexport interface Definition {\n title: string;\n\n properties: DefinitionProperty[];\n\n type?: string;\n\n id?: string;\n\n description?: string;\n}\n\nexport interface DefinitionProperty {\n name: string;\n\n type: string;\n\n description: string;\n\n properties?: DefinitionProperty[];\n}"],"mappings":";AAqBe,SAAR,QACH,YACA,QACF;AAKE,Q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AA,mBAAA,UAAO;AACP,EAAAA,mBAAA,aAAU;AAIV,EAAAA,mBAAA,eAAY;AAZJ,SAAAA;AAAA,GAAA;AAiBL,IAAK,gBAAL,kBAAKC,mBAAL;AAEH,EAAAA,eAAA,eAAY;AACZ,EAAAA,eAAA,UAAO;AAIP,EAAAA,eAAA,mBAAgB;AAChB,EAAAA,eAAA,oBAAiB;AACjB,EAAAA,eAAA,mBAAgB;AAChB,EAAAA,eAAA,qBAAkB;AAClB,EAAAA,eAAA,sBAAmB;AAEnB,EAAAA,eAAA,mBAAgB;AAChB,EAAAA,eAAA,sBAAmB;AAInB,EAAAA,eAAA,iBAAc;AAlBN,SAAAA;AAAA,GAAA;","names":["ReferenceCategory","ReferenceType"]}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// markdown.ts
|
|
31
|
+
var markdown_exports = {};
|
|
32
|
+
__export(markdown_exports, {
|
|
33
|
+
compile: () => compile,
|
|
34
|
+
referenceAST: () => referenceAST
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(markdown_exports);
|
|
37
|
+
|
|
38
|
+
// src/markdown/index.ts
|
|
39
|
+
var import_remark = require("remark");
|
|
40
|
+
var import_remark_stringify = __toESM(require("remark-stringify"), 1);
|
|
41
|
+
|
|
42
|
+
// src/markdown/utils.ts
|
|
43
|
+
var import_unist_builder = require("unist-builder");
|
|
44
|
+
var START_DEPTH_LEVEL = 2;
|
|
45
|
+
function root(ast) {
|
|
46
|
+
return (0, import_unist_builder.u)("root", ast);
|
|
47
|
+
}
|
|
48
|
+
function heading(title, canonical, description, refCategory, refType, refContext) {
|
|
49
|
+
const uTitle = (0, import_unist_builder.u)(
|
|
50
|
+
"heading",
|
|
51
|
+
{ depth: START_DEPTH_LEVEL },
|
|
52
|
+
[(0, import_unist_builder.u)("text", `!!references ${title}`)]
|
|
53
|
+
);
|
|
54
|
+
const uCanonical = (0, import_unist_builder.u)(
|
|
55
|
+
"heading",
|
|
56
|
+
{ depth: uTitle.depth + 1 },
|
|
57
|
+
[(0, import_unist_builder.u)("text", `!canonical ${canonical}`)]
|
|
58
|
+
);
|
|
59
|
+
let uDesc = [
|
|
60
|
+
(0, import_unist_builder.u)(
|
|
61
|
+
"heading",
|
|
62
|
+
{ depth: START_DEPTH_LEVEL },
|
|
63
|
+
[(0, import_unist_builder.u)("text", `!description`)]
|
|
64
|
+
),
|
|
65
|
+
(0, import_unist_builder.u)("paragraph", [(0, import_unist_builder.u)("text", description)])
|
|
66
|
+
];
|
|
67
|
+
let uRefCategory;
|
|
68
|
+
if (refCategory) {
|
|
69
|
+
uRefCategory = (0, import_unist_builder.u)(
|
|
70
|
+
"heading",
|
|
71
|
+
{ depth: uTitle.depth + 1 },
|
|
72
|
+
[(0, import_unist_builder.u)("text", `!category ${refCategory}`)]
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
let uRefType;
|
|
76
|
+
if (refType) {
|
|
77
|
+
uRefType = (0, import_unist_builder.u)(
|
|
78
|
+
"heading",
|
|
79
|
+
{ depth: uTitle.depth + 1 },
|
|
80
|
+
[(0, import_unist_builder.u)("text", `!type ${refType}`)]
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
let uContext = [];
|
|
84
|
+
if (refContext && Object.keys(refContext)) {
|
|
85
|
+
uContext.push((0, import_unist_builder.u)(
|
|
86
|
+
"heading",
|
|
87
|
+
{ depth: uTitle.depth + 1 },
|
|
88
|
+
[
|
|
89
|
+
(0, import_unist_builder.u)("text", `!context`)
|
|
90
|
+
]
|
|
91
|
+
));
|
|
92
|
+
for (const [key, value] of Object.entries(refContext)) {
|
|
93
|
+
uContext.push(
|
|
94
|
+
(0, import_unist_builder.u)(
|
|
95
|
+
"heading",
|
|
96
|
+
{ depth: uContext[0].depth + 1 },
|
|
97
|
+
[(0, import_unist_builder.u)("text", `!${key} ${value}`)]
|
|
98
|
+
)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
title: uTitle,
|
|
104
|
+
canonical: uCanonical,
|
|
105
|
+
description: uDesc,
|
|
106
|
+
category: uRefCategory || null,
|
|
107
|
+
type: uRefType || null,
|
|
108
|
+
context: uContext || null
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function examples(examples2) {
|
|
112
|
+
const md = [];
|
|
113
|
+
const uExampleRoot = (0, import_unist_builder.u)(
|
|
114
|
+
"heading",
|
|
115
|
+
{ depth: START_DEPTH_LEVEL + 1 },
|
|
116
|
+
[(0, import_unist_builder.u)("text", `!examples`)]
|
|
117
|
+
);
|
|
118
|
+
md.push(uExampleRoot);
|
|
119
|
+
examples2.groups.forEach((group) => {
|
|
120
|
+
const uExampleGroups = (0, import_unist_builder.u)(
|
|
121
|
+
"heading",
|
|
122
|
+
{ depth: uExampleRoot.depth + 1 },
|
|
123
|
+
[(0, import_unist_builder.u)("text", `!!groups`)]
|
|
124
|
+
);
|
|
125
|
+
md.push(uExampleGroups);
|
|
126
|
+
const uGroupDescription = (0, import_unist_builder.u)(
|
|
127
|
+
"heading",
|
|
128
|
+
{ depth: uExampleGroups.depth + 1 },
|
|
129
|
+
[(0, import_unist_builder.u)("text", `!description ${group.description}`)]
|
|
130
|
+
);
|
|
131
|
+
md.push(uGroupDescription);
|
|
132
|
+
group.examples.forEach((example) => {
|
|
133
|
+
const uExamples = (0, import_unist_builder.u)(
|
|
134
|
+
"heading",
|
|
135
|
+
{ depth: uExampleGroups.depth + 1 },
|
|
136
|
+
[(0, import_unist_builder.u)("text", `!!examples`)]
|
|
137
|
+
);
|
|
138
|
+
md.push(uExamples);
|
|
139
|
+
const codeBlock = (0, import_unist_builder.u)(
|
|
140
|
+
"heading",
|
|
141
|
+
{ depth: uExamples.depth + 1 },
|
|
142
|
+
[(0, import_unist_builder.u)("text", `!codeblock`)]
|
|
143
|
+
);
|
|
144
|
+
md.push(codeBlock);
|
|
145
|
+
const codeBlockTitle = (0, import_unist_builder.u)(
|
|
146
|
+
"heading",
|
|
147
|
+
{ depth: codeBlock.depth + 1 },
|
|
148
|
+
[(0, import_unist_builder.u)("text", `!title ${example.codeblock.title}`)]
|
|
149
|
+
);
|
|
150
|
+
md.push(codeBlockTitle);
|
|
151
|
+
const tabs = (0, import_unist_builder.u)(
|
|
152
|
+
"heading",
|
|
153
|
+
{ depth: codeBlock.depth + 1 },
|
|
154
|
+
[(0, import_unist_builder.u)("text", `!!tabs`)]
|
|
155
|
+
);
|
|
156
|
+
md.push(tabs);
|
|
157
|
+
example.codeblock.tabs.forEach((tab) => {
|
|
158
|
+
const code = (0, import_unist_builder.u)("code", {
|
|
159
|
+
lang: tab.language,
|
|
160
|
+
meta: `!code ${tab.title}`
|
|
161
|
+
}, tab.code);
|
|
162
|
+
md.push(code);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
return md;
|
|
167
|
+
}
|
|
168
|
+
function definitions(definitions2) {
|
|
169
|
+
const md = [];
|
|
170
|
+
definitions2.forEach((definition) => {
|
|
171
|
+
const uDefinition = (0, import_unist_builder.u)(
|
|
172
|
+
"heading",
|
|
173
|
+
{ depth: START_DEPTH_LEVEL + 1 },
|
|
174
|
+
[(0, import_unist_builder.u)("text", `!!definitions`)]
|
|
175
|
+
);
|
|
176
|
+
md.push(uDefinition);
|
|
177
|
+
md.push((0, import_unist_builder.u)(
|
|
178
|
+
"heading",
|
|
179
|
+
{ depth: uDefinition.depth + 1 },
|
|
180
|
+
[(0, import_unist_builder.u)("text", `!title ${definition.title}`)]
|
|
181
|
+
));
|
|
182
|
+
definition.properties.forEach((prop) => {
|
|
183
|
+
properties(
|
|
184
|
+
uDefinition.depth + 1,
|
|
185
|
+
{
|
|
186
|
+
name: prop.name,
|
|
187
|
+
type: prop.type,
|
|
188
|
+
description: prop.description,
|
|
189
|
+
properties: prop.properties
|
|
190
|
+
// TODO: fix ts
|
|
191
|
+
},
|
|
192
|
+
md
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
return md;
|
|
197
|
+
}
|
|
198
|
+
function properties(depth, props, output = []) {
|
|
199
|
+
const paramName = props.name;
|
|
200
|
+
const propTitle = `!!properties ${paramName}`;
|
|
201
|
+
const uPropTitle = (0, import_unist_builder.u)("heading", { depth }, [(0, import_unist_builder.u)("text", propTitle)]);
|
|
202
|
+
const uPropName = (0, import_unist_builder.u)("paragraph", { depth }, [(0, import_unist_builder.u)("text", `!name ${paramName}`)]);
|
|
203
|
+
const uPropType = (0, import_unist_builder.u)("paragraph", { depth }, [(0, import_unist_builder.u)("text", `!type ${props.type}`)]);
|
|
204
|
+
const uPropDesc = (0, import_unist_builder.u)("paragraph", { depth }, [(0, import_unist_builder.u)("text", props.description || "")]);
|
|
205
|
+
output.push(
|
|
206
|
+
uPropTitle,
|
|
207
|
+
uPropName,
|
|
208
|
+
uPropType,
|
|
209
|
+
uPropDesc
|
|
210
|
+
);
|
|
211
|
+
if (props.properties) {
|
|
212
|
+
const deepDepth = depth + 1;
|
|
213
|
+
for (const prop of props.properties) {
|
|
214
|
+
properties(deepDepth, prop, output);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// src/markdown/index.ts
|
|
220
|
+
function compile(ast) {
|
|
221
|
+
return (0, import_remark.remark)().use(import_remark_stringify.default, {
|
|
222
|
+
bullet: "-",
|
|
223
|
+
fences: true,
|
|
224
|
+
listItemIndent: "one",
|
|
225
|
+
incrementListMarker: false,
|
|
226
|
+
handlers: {
|
|
227
|
+
heading(node) {
|
|
228
|
+
return `${"#".repeat(node.depth)} ${node.children[0].value}`;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}).stringify(root(ast));
|
|
232
|
+
}
|
|
233
|
+
function referenceAST(ref) {
|
|
234
|
+
var _a, _b;
|
|
235
|
+
const md = [];
|
|
236
|
+
const mdHeading = heading(
|
|
237
|
+
ref.title,
|
|
238
|
+
ref.canonical,
|
|
239
|
+
ref.description,
|
|
240
|
+
ref.category,
|
|
241
|
+
ref.type,
|
|
242
|
+
ref.context
|
|
243
|
+
);
|
|
244
|
+
if ((_a = mdHeading == null ? void 0 : mdHeading.description) == null ? void 0 : _a.length) {
|
|
245
|
+
md.push(...mdHeading.description);
|
|
246
|
+
}
|
|
247
|
+
md.push(
|
|
248
|
+
mdHeading.title,
|
|
249
|
+
mdHeading.canonical
|
|
250
|
+
);
|
|
251
|
+
if (mdHeading.category) {
|
|
252
|
+
md.push(mdHeading.category);
|
|
253
|
+
}
|
|
254
|
+
if (mdHeading.type) {
|
|
255
|
+
md.push(mdHeading.type);
|
|
256
|
+
}
|
|
257
|
+
if ((_b = mdHeading == null ? void 0 : mdHeading.context) == null ? void 0 : _b.length) {
|
|
258
|
+
md.push(...mdHeading.context);
|
|
259
|
+
}
|
|
260
|
+
const mdExamples = examples(ref.examples);
|
|
261
|
+
const mdDefinitions = definitions(ref.definitions);
|
|
262
|
+
md.push(...mdExamples, ...mdDefinitions);
|
|
263
|
+
return md;
|
|
264
|
+
}
|
|
265
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
266
|
+
0 && (module.exports = {
|
|
267
|
+
compile,
|
|
268
|
+
referenceAST
|
|
269
|
+
});
|
|
270
|
+
//# sourceMappingURL=markdown.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../markdown.ts","../src/markdown/index.ts","../src/markdown/utils.ts"],"sourcesContent":["export * from \"./src/markdown\";\n","import {remark} from \"remark\";\nimport remarkStringify from \"remark-stringify\";\n\nimport {Reference} from \"../types\";\n\nimport {definitions, examples, heading, root} from \"./utils\";\n\n// TODO: any\nexport function compile(ast: any) {\n return remark()\n // .use(unlimitedHeadings)\n .use(remarkStringify, {\n bullet: '-',\n fences: true,\n listItemIndent: 'one',\n incrementListMarker: false,\n handlers: {\n heading(node) {\n return `${\"#\".repeat(node.depth)} ${node.children[0].value}`;\n },\n },\n })\n .stringify(root(ast));\n}\n\nexport function referenceAST(ref: Reference) {\n const md = []\n\n const mdHeading = heading(\n ref.title,\n ref.canonical,\n ref.description,\n ref.category,\n ref.type,\n ref.context\n )\n\n if (mdHeading?.description?.length) {\n md.push(...mdHeading.description)\n }\n\n md.push(\n mdHeading.title,\n mdHeading.canonical,\n )\n\n if (mdHeading.category) {\n md.push(mdHeading.category)\n }\n\n if (mdHeading.type) {\n md.push(mdHeading.type)\n }\n\n if (mdHeading?.context?.length) {\n md.push(...mdHeading.context)\n }\n\n const mdExamples = examples(ref.examples)\n const mdDefinitions = definitions(ref.definitions)\n md.push(...mdExamples, ...mdDefinitions)\n\n return md;\n}\n","import {u} from \"unist-builder\";\n\nimport {\n ExampleRoot,\n Definition,\n ReferenceCategory,\n ReferenceContext,\n ReferenceType,\n DefinitionProperty\n} from \"../types\";\n\n// START_DEPTH_LEVEL is the start depth level for the markdown AST\n// starts from 2 because 1 is reserved for the title\nconst START_DEPTH_LEVEL = 2\n\n// TODO: fix any\nexport function root(ast: any) {\n return u('root', ast);\n}\n\nexport function heading(\n title: string,\n canonical: string,\n description: string,\n refCategory?: ReferenceCategory,\n refType?: ReferenceType,\n refContext?: ReferenceContext\n) {\n const uTitle = u(\n 'heading',\n {depth: START_DEPTH_LEVEL},\n [u('text', `!!references ${title}`)]\n )\n\n const uCanonical = u(\n 'heading',\n {depth: uTitle.depth + 1},\n [u('text', `!canonical ${canonical}`)]\n )\n\n let uDesc = [\n u(\n 'heading',\n {depth: START_DEPTH_LEVEL},\n [u('text', `!description`),]\n ),\n u('paragraph', [u('text', description)])\n ]\n\n\n let uRefCategory\n if (refCategory) {\n uRefCategory = u(\n 'heading',\n {depth: uTitle.depth + 1},\n [u('text', `!category ${refCategory}`)]\n )\n }\n\n let uRefType\n if (refType) {\n uRefType = u(\n 'heading',\n {depth: uTitle.depth + 1},\n [u('text', `!type ${refType}`)]\n )\n }\n\n let uContext = []\n\n if (refContext && Object.keys(refContext)) {\n uContext.push(u(\n 'heading',\n {depth: uTitle.depth + 1},\n [\n u('text', `!context`),\n ]\n ))\n\n\n for (const [key, value] of Object.entries(refContext)) {\n uContext.push(u(\n 'heading',\n {depth: uContext[0].depth + 1},\n [u('text', `!${key} ${value}`)]\n )\n )\n }\n }\n\n return {\n title: uTitle,\n canonical: uCanonical,\n description: uDesc,\n category: uRefCategory || null,\n type: uRefType || null,\n context: uContext || null\n }\n}\n\nexport function examples(examples: ExampleRoot) {\n const md = []\n\n const uExampleRoot = u(\n 'heading',\n {depth: START_DEPTH_LEVEL + 1},\n [u('text', `!examples`)]\n )\n md.push(uExampleRoot)\n\n examples.groups.forEach(group => {\n const uExampleGroups = u(\n 'heading',\n {depth: uExampleRoot.depth + 1},\n [u('text', `!!groups`)]\n )\n md.push(uExampleGroups)\n\n const uGroupDescription = u(\n 'heading',\n {depth: uExampleGroups.depth + 1},\n [u('text', `!description ${group.description}`)]\n )\n md.push(uGroupDescription)\n\n group.examples.forEach(example => {\n const uExamples = u(\n 'heading',\n {depth: uExampleGroups.depth + 1},\n [u('text', `!!examples`)]\n )\n md.push(uExamples)\n\n const codeBlock = u(\n 'heading',\n {depth: uExamples.depth + 1},\n [u('text', `!codeblock`)]\n )\n md.push(codeBlock)\n\n const codeBlockTitle = u(\n 'heading',\n {depth: codeBlock.depth + 1},\n [u('text', `!title ${example.codeblock.title}`)]\n )\n md.push(codeBlockTitle)\n\n const tabs = u(\n 'heading',\n {depth: codeBlock.depth + 1},\n [u('text', `!!tabs`)]\n )\n md.push(tabs)\n\n example.codeblock.tabs.forEach(tab => {\n const code = u('code', {\n lang: tab.language,\n meta: `!code ${tab.title}`\n }, tab.code);\n\n md.push(code)\n })\n\n })\n })\n\n return md\n}\n\nexport function definitions(definitions: Definition[]) {\n const md: any[] = []\n\n definitions.forEach(definition => {\n const uDefinition = u(\n 'heading',\n {depth: START_DEPTH_LEVEL + 1},\n [u('text', `!!definitions`)]\n )\n md.push(uDefinition)\n\n md.push(u(\n 'heading',\n {depth: uDefinition.depth + 1},\n [u('text', `!title ${definition.title}`)]\n ))\n\n definition.properties.forEach(prop => {\n properties(\n uDefinition.depth + 1,\n {\n name: prop.name,\n type: prop.type,\n description: prop.description,\n properties: prop.properties // TODO: fix ts\n },\n md,\n )\n })\n })\n\n return md\n}\n\n// TODO: any[]\nexport function properties(\n depth: number,\n props: DefinitionProperty,\n output: any[] = []\n) {\n const paramName = props.name;\n\n const propTitle = `!!properties ${paramName}`; // TODO: check if `!!properties is enough`\n const uPropTitle = u('heading', {depth}, [u('text', propTitle)]);\n const uPropName = u('paragraph', {depth}, [u('text', `!name ${paramName}`)]);\n const uPropType = u('paragraph', {depth}, [u('text', `!type ${props.type}`)]);\n const uPropDesc = u('paragraph', {depth}, [u('text', props.description || '')]);\n\n output.push(\n uPropTitle,\n uPropName,\n uPropType,\n uPropDesc\n );\n\n if (props.properties) {\n const deepDepth = depth + 1\n\n for (const prop of props.properties) {\n properties(deepDepth, prop, output)\n }\n }\n}\n\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAqB;AACrB,8BAA4B;;;ACD5B,2BAAgB;AAahB,IAAM,oBAAoB;AAGnB,SAAS,KAAK,KAAU;AAC3B,aAAO,wBAAE,QAAQ,GAAG;AACxB;AAEO,SAAS,QACZ,OACA,WACA,aACA,aACA,SACA,YACF;AACE,QAAM,aAAS;AAAA,IACX;AAAA,IACA,EAAC,OAAO,kBAAiB;AAAA,IACzB,KAAC,wBAAE,QAAQ,gBAAgB,KAAK,EAAE,CAAC;AAAA,EACvC;AAEA,QAAM,iBAAa;AAAA,IACf;AAAA,IACA,EAAC,OAAO,OAAO,QAAQ,EAAC;AAAA,IACxB,KAAC,wBAAE,QAAQ,cAAc,SAAS,EAAE,CAAC;AAAA,EACzC;AAEA,MAAI,QAAQ;AAAA,QACR;AAAA,MACI;AAAA,MACA,EAAC,OAAO,kBAAiB;AAAA,MACzB,KAAC,wBAAE,QAAQ,cAAc,CAAE;AAAA,IAC/B;AAAA,QACA,wBAAE,aAAa,KAAC,wBAAE,QAAQ,WAAW,CAAC,CAAC;AAAA,EAC3C;AAGA,MAAI;AACJ,MAAI,aAAa;AACb,uBAAe;AAAA,MACX;AAAA,MACA,EAAC,OAAO,OAAO,QAAQ,EAAC;AAAA,MACxB,KAAC,wBAAE,QA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|
|
3
|
+
import remarkStringify from "remark-stringify";
|
|
4
|
+
|
|
5
|
+
// src/markdown/utils.ts
|
|
6
|
+
import { u } from "unist-builder";
|
|
7
|
+
var START_DEPTH_LEVEL = 2;
|
|
8
|
+
function root(ast) {
|
|
9
|
+
return u("root", ast);
|
|
10
|
+
}
|
|
11
|
+
function heading(title, canonical, description, refCategory, refType, refContext) {
|
|
12
|
+
const uTitle = u(
|
|
13
|
+
"heading",
|
|
14
|
+
{ depth: START_DEPTH_LEVEL },
|
|
15
|
+
[u("text", `!!references ${title}`)]
|
|
16
|
+
);
|
|
17
|
+
const uCanonical = u(
|
|
18
|
+
"heading",
|
|
19
|
+
{ depth: uTitle.depth + 1 },
|
|
20
|
+
[u("text", `!canonical ${canonical}`)]
|
|
21
|
+
);
|
|
22
|
+
let uDesc = [
|
|
23
|
+
u(
|
|
24
|
+
"heading",
|
|
25
|
+
{ depth: START_DEPTH_LEVEL },
|
|
26
|
+
[u("text", `!description`)]
|
|
27
|
+
),
|
|
28
|
+
u("paragraph", [u("text", description)])
|
|
29
|
+
];
|
|
30
|
+
let uRefCategory;
|
|
31
|
+
if (refCategory) {
|
|
32
|
+
uRefCategory = u(
|
|
33
|
+
"heading",
|
|
34
|
+
{ depth: uTitle.depth + 1 },
|
|
35
|
+
[u("text", `!category ${refCategory}`)]
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
let uRefType;
|
|
39
|
+
if (refType) {
|
|
40
|
+
uRefType = u(
|
|
41
|
+
"heading",
|
|
42
|
+
{ depth: uTitle.depth + 1 },
|
|
43
|
+
[u("text", `!type ${refType}`)]
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
let uContext = [];
|
|
47
|
+
if (refContext && Object.keys(refContext)) {
|
|
48
|
+
uContext.push(u(
|
|
49
|
+
"heading",
|
|
50
|
+
{ depth: uTitle.depth + 1 },
|
|
51
|
+
[
|
|
52
|
+
u("text", `!context`)
|
|
53
|
+
]
|
|
54
|
+
));
|
|
55
|
+
for (const [key, value] of Object.entries(refContext)) {
|
|
56
|
+
uContext.push(
|
|
57
|
+
u(
|
|
58
|
+
"heading",
|
|
59
|
+
{ depth: uContext[0].depth + 1 },
|
|
60
|
+
[u("text", `!${key} ${value}`)]
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
title: uTitle,
|
|
67
|
+
canonical: uCanonical,
|
|
68
|
+
description: uDesc,
|
|
69
|
+
category: uRefCategory || null,
|
|
70
|
+
type: uRefType || null,
|
|
71
|
+
context: uContext || null
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function examples(examples2) {
|
|
75
|
+
const md = [];
|
|
76
|
+
const uExampleRoot = u(
|
|
77
|
+
"heading",
|
|
78
|
+
{ depth: START_DEPTH_LEVEL + 1 },
|
|
79
|
+
[u("text", `!examples`)]
|
|
80
|
+
);
|
|
81
|
+
md.push(uExampleRoot);
|
|
82
|
+
examples2.groups.forEach((group) => {
|
|
83
|
+
const uExampleGroups = u(
|
|
84
|
+
"heading",
|
|
85
|
+
{ depth: uExampleRoot.depth + 1 },
|
|
86
|
+
[u("text", `!!groups`)]
|
|
87
|
+
);
|
|
88
|
+
md.push(uExampleGroups);
|
|
89
|
+
const uGroupDescription = u(
|
|
90
|
+
"heading",
|
|
91
|
+
{ depth: uExampleGroups.depth + 1 },
|
|
92
|
+
[u("text", `!description ${group.description}`)]
|
|
93
|
+
);
|
|
94
|
+
md.push(uGroupDescription);
|
|
95
|
+
group.examples.forEach((example) => {
|
|
96
|
+
const uExamples = u(
|
|
97
|
+
"heading",
|
|
98
|
+
{ depth: uExampleGroups.depth + 1 },
|
|
99
|
+
[u("text", `!!examples`)]
|
|
100
|
+
);
|
|
101
|
+
md.push(uExamples);
|
|
102
|
+
const codeBlock = u(
|
|
103
|
+
"heading",
|
|
104
|
+
{ depth: uExamples.depth + 1 },
|
|
105
|
+
[u("text", `!codeblock`)]
|
|
106
|
+
);
|
|
107
|
+
md.push(codeBlock);
|
|
108
|
+
const codeBlockTitle = u(
|
|
109
|
+
"heading",
|
|
110
|
+
{ depth: codeBlock.depth + 1 },
|
|
111
|
+
[u("text", `!title ${example.codeblock.title}`)]
|
|
112
|
+
);
|
|
113
|
+
md.push(codeBlockTitle);
|
|
114
|
+
const tabs = u(
|
|
115
|
+
"heading",
|
|
116
|
+
{ depth: codeBlock.depth + 1 },
|
|
117
|
+
[u("text", `!!tabs`)]
|
|
118
|
+
);
|
|
119
|
+
md.push(tabs);
|
|
120
|
+
example.codeblock.tabs.forEach((tab) => {
|
|
121
|
+
const code = u("code", {
|
|
122
|
+
lang: tab.language,
|
|
123
|
+
meta: `!code ${tab.title}`
|
|
124
|
+
}, tab.code);
|
|
125
|
+
md.push(code);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
return md;
|
|
130
|
+
}
|
|
131
|
+
function definitions(definitions2) {
|
|
132
|
+
const md = [];
|
|
133
|
+
definitions2.forEach((definition) => {
|
|
134
|
+
const uDefinition = u(
|
|
135
|
+
"heading",
|
|
136
|
+
{ depth: START_DEPTH_LEVEL + 1 },
|
|
137
|
+
[u("text", `!!definitions`)]
|
|
138
|
+
);
|
|
139
|
+
md.push(uDefinition);
|
|
140
|
+
md.push(u(
|
|
141
|
+
"heading",
|
|
142
|
+
{ depth: uDefinition.depth + 1 },
|
|
143
|
+
[u("text", `!title ${definition.title}`)]
|
|
144
|
+
));
|
|
145
|
+
definition.properties.forEach((prop) => {
|
|
146
|
+
properties(
|
|
147
|
+
uDefinition.depth + 1,
|
|
148
|
+
{
|
|
149
|
+
name: prop.name,
|
|
150
|
+
type: prop.type,
|
|
151
|
+
description: prop.description,
|
|
152
|
+
properties: prop.properties
|
|
153
|
+
// TODO: fix ts
|
|
154
|
+
},
|
|
155
|
+
md
|
|
156
|
+
);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
return md;
|
|
160
|
+
}
|
|
161
|
+
function properties(depth, props, output = []) {
|
|
162
|
+
const paramName = props.name;
|
|
163
|
+
const propTitle = `!!properties ${paramName}`;
|
|
164
|
+
const uPropTitle = u("heading", { depth }, [u("text", propTitle)]);
|
|
165
|
+
const uPropName = u("paragraph", { depth }, [u("text", `!name ${paramName}`)]);
|
|
166
|
+
const uPropType = u("paragraph", { depth }, [u("text", `!type ${props.type}`)]);
|
|
167
|
+
const uPropDesc = u("paragraph", { depth }, [u("text", props.description || "")]);
|
|
168
|
+
output.push(
|
|
169
|
+
uPropTitle,
|
|
170
|
+
uPropName,
|
|
171
|
+
uPropType,
|
|
172
|
+
uPropDesc
|
|
173
|
+
);
|
|
174
|
+
if (props.properties) {
|
|
175
|
+
const deepDepth = depth + 1;
|
|
176
|
+
for (const prop of props.properties) {
|
|
177
|
+
properties(deepDepth, prop, output);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/markdown/index.ts
|
|
183
|
+
function compile(ast) {
|
|
184
|
+
return remark().use(remarkStringify, {
|
|
185
|
+
bullet: "-",
|
|
186
|
+
fences: true,
|
|
187
|
+
listItemIndent: "one",
|
|
188
|
+
incrementListMarker: false,
|
|
189
|
+
handlers: {
|
|
190
|
+
heading(node) {
|
|
191
|
+
return `${"#".repeat(node.depth)} ${node.children[0].value}`;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}).stringify(root(ast));
|
|
195
|
+
}
|
|
196
|
+
function referenceAST(ref) {
|
|
197
|
+
var _a, _b;
|
|
198
|
+
const md = [];
|
|
199
|
+
const mdHeading = heading(
|
|
200
|
+
ref.title,
|
|
201
|
+
ref.canonical,
|
|
202
|
+
ref.description,
|
|
203
|
+
ref.category,
|
|
204
|
+
ref.type,
|
|
205
|
+
ref.context
|
|
206
|
+
);
|
|
207
|
+
if ((_a = mdHeading == null ? void 0 : mdHeading.description) == null ? void 0 : _a.length) {
|
|
208
|
+
md.push(...mdHeading.description);
|
|
209
|
+
}
|
|
210
|
+
md.push(
|
|
211
|
+
mdHeading.title,
|
|
212
|
+
mdHeading.canonical
|
|
213
|
+
);
|
|
214
|
+
if (mdHeading.category) {
|
|
215
|
+
md.push(mdHeading.category);
|
|
216
|
+
}
|
|
217
|
+
if (mdHeading.type) {
|
|
218
|
+
md.push(mdHeading.type);
|
|
219
|
+
}
|
|
220
|
+
if ((_b = mdHeading == null ? void 0 : mdHeading.context) == null ? void 0 : _b.length) {
|
|
221
|
+
md.push(...mdHeading.context);
|
|
222
|
+
}
|
|
223
|
+
const mdExamples = examples(ref.examples);
|
|
224
|
+
const mdDefinitions = definitions(ref.definitions);
|
|
225
|
+
md.push(...mdExamples, ...mdDefinitions);
|
|
226
|
+
return md;
|
|
227
|
+
}
|
|
228
|
+
export {
|
|
229
|
+
compile,
|
|
230
|
+
referenceAST
|
|
231
|
+
};
|
|
232
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/markdown/index.ts","../src/markdown/utils.ts"],"sourcesContent":["import {remark} from \"remark\";\nimport remarkStringify from \"remark-stringify\";\n\nimport {Reference} from \"../types\";\n\nimport {definitions, examples, heading, root} from \"./utils\";\n\n// TODO: any\nexport function compile(ast: any) {\n return remark()\n // .use(unlimitedHeadings)\n .use(remarkStringify, {\n bullet: '-',\n fences: true,\n listItemIndent: 'one',\n incrementListMarker: false,\n handlers: {\n heading(node) {\n return `${\"#\".repeat(node.depth)} ${node.children[0].value}`;\n },\n },\n })\n .stringify(root(ast));\n}\n\nexport function referenceAST(ref: Reference) {\n const md = []\n\n const mdHeading = heading(\n ref.title,\n ref.canonical,\n ref.description,\n ref.category,\n ref.type,\n ref.context\n )\n\n if (mdHeading?.description?.length) {\n md.push(...mdHeading.description)\n }\n\n md.push(\n mdHeading.title,\n mdHeading.canonical,\n )\n\n if (mdHeading.category) {\n md.push(mdHeading.category)\n }\n\n if (mdHeading.type) {\n md.push(mdHeading.type)\n }\n\n if (mdHeading?.context?.length) {\n md.push(...mdHeading.context)\n }\n\n const mdExamples = examples(ref.examples)\n const mdDefinitions = definitions(ref.definitions)\n md.push(...mdExamples, ...mdDefinitions)\n\n return md;\n}\n","import {u} from \"unist-builder\";\n\nimport {\n ExampleRoot,\n Definition,\n ReferenceCategory,\n ReferenceContext,\n ReferenceType,\n DefinitionProperty\n} from \"../types\";\n\n// START_DEPTH_LEVEL is the start depth level for the markdown AST\n// starts from 2 because 1 is reserved for the title\nconst START_DEPTH_LEVEL = 2\n\n// TODO: fix any\nexport function root(ast: any) {\n return u('root', ast);\n}\n\nexport function heading(\n title: string,\n canonical: string,\n description: string,\n refCategory?: ReferenceCategory,\n refType?: ReferenceType,\n refContext?: ReferenceContext\n) {\n const uTitle = u(\n 'heading',\n {depth: START_DEPTH_LEVEL},\n [u('text', `!!references ${title}`)]\n )\n\n const uCanonical = u(\n 'heading',\n {depth: uTitle.depth + 1},\n [u('text', `!canonical ${canonical}`)]\n )\n\n let uDesc = [\n u(\n 'heading',\n {depth: START_DEPTH_LEVEL},\n [u('text', `!description`),]\n ),\n u('paragraph', [u('text', description)])\n ]\n\n\n let uRefCategory\n if (refCategory) {\n uRefCategory = u(\n 'heading',\n {depth: uTitle.depth + 1},\n [u('text', `!category ${refCategory}`)]\n )\n }\n\n let uRefType\n if (refType) {\n uRefType = u(\n 'heading',\n {depth: uTitle.depth + 1},\n [u('text', `!type ${refType}`)]\n )\n }\n\n let uContext = []\n\n if (refContext && Object.keys(refContext)) {\n uContext.push(u(\n 'heading',\n {depth: uTitle.depth + 1},\n [\n u('text', `!context`),\n ]\n ))\n\n\n for (const [key, value] of Object.entries(refContext)) {\n uContext.push(u(\n 'heading',\n {depth: uContext[0].depth + 1},\n [u('text', `!${key} ${value}`)]\n )\n )\n }\n }\n\n return {\n title: uTitle,\n canonical: uCanonical,\n description: uDesc,\n category: uRefCategory || null,\n type: uRefType || null,\n context: uContext || null\n }\n}\n\nexport function examples(examples: ExampleRoot) {\n const md = []\n\n const uExampleRoot = u(\n 'heading',\n {depth: START_DEPTH_LEVEL + 1},\n [u('text', `!examples`)]\n )\n md.push(uExampleRoot)\n\n examples.groups.forEach(group => {\n const uExampleGroups = u(\n 'heading',\n {depth: uExampleRoot.depth + 1},\n [u('text', `!!groups`)]\n )\n md.push(uExampleGroups)\n\n const uGroupDescription = u(\n 'heading',\n {depth: uExampleGroups.depth + 1},\n [u('text', `!description ${group.description}`)]\n )\n md.push(uGroupDescription)\n\n group.examples.forEach(example => {\n const uExamples = u(\n 'heading',\n {depth: uExampleGroups.depth + 1},\n [u('text', `!!examples`)]\n )\n md.push(uExamples)\n\n const codeBlock = u(\n 'heading',\n {depth: uExamples.depth + 1},\n [u('text', `!codeblock`)]\n )\n md.push(codeBlock)\n\n const codeBlockTitle = u(\n 'heading',\n {depth: codeBlock.depth + 1},\n [u('text', `!title ${example.codeblock.title}`)]\n )\n md.push(codeBlockTitle)\n\n const tabs = u(\n 'heading',\n {depth: codeBlock.depth + 1},\n [u('text', `!!tabs`)]\n )\n md.push(tabs)\n\n example.codeblock.tabs.forEach(tab => {\n const code = u('code', {\n lang: tab.language,\n meta: `!code ${tab.title}`\n }, tab.code);\n\n md.push(code)\n })\n\n })\n })\n\n return md\n}\n\nexport function definitions(definitions: Definition[]) {\n const md: any[] = []\n\n definitions.forEach(definition => {\n const uDefinition = u(\n 'heading',\n {depth: START_DEPTH_LEVEL + 1},\n [u('text', `!!definitions`)]\n )\n md.push(uDefinition)\n\n md.push(u(\n 'heading',\n {depth: uDefinition.depth + 1},\n [u('text', `!title ${definition.title}`)]\n ))\n\n definition.properties.forEach(prop => {\n properties(\n uDefinition.depth + 1,\n {\n name: prop.name,\n type: prop.type,\n description: prop.description,\n properties: prop.properties // TODO: fix ts\n },\n md,\n )\n })\n })\n\n return md\n}\n\n// TODO: any[]\nexport function properties(\n depth: number,\n props: DefinitionProperty,\n output: any[] = []\n) {\n const paramName = props.name;\n\n const propTitle = `!!properties ${paramName}`; // TODO: check if `!!properties is enough`\n const uPropTitle = u('heading', {depth}, [u('text', propTitle)]);\n const uPropName = u('paragraph', {depth}, [u('text', `!name ${paramName}`)]);\n const uPropType = u('paragraph', {depth}, [u('text', `!type ${props.type}`)]);\n const uPropDesc = u('paragraph', {depth}, [u('text', props.description || '')]);\n\n output.push(\n uPropTitle,\n uPropName,\n uPropType,\n uPropDesc\n );\n\n if (props.properties) {\n const deepDepth = depth + 1\n\n for (const prop of props.properties) {\n properties(deepDepth, prop, output)\n }\n }\n}\n\n\n\n"],"mappings":";AAAA,SAAQ,cAAa;AACrB,OAAO,qBAAqB;;;ACD5B,SAAQ,SAAQ;AAahB,IAAM,oBAAoB;AAGnB,SAAS,KAAK,KAAU;AAC3B,SAAO,EAAE,QAAQ,GAAG;AACxB;AAEO,SAAS,QACZ,OACA,WACA,aACA,aACA,SACA,YACF;AACE,QAAM,SAAS;AAAA,IACX;AAAA,IACA,EAAC,OAAO,kBAAiB;AAAA,IACzB,CAAC,EAAE,QAAQ,gBAAgB,KAAK,EAAE,CAAC;AAAA,EACvC;AAEA,QAAM,aAAa;AAAA,IACf;AAAA,IACA,EAAC,OAAO,OAAO,QAAQ,EAAC;AAAA,IACxB,CAAC,EAAE,QAAQ,cAAc,SAAS,EAAE,CAAC;AAAA,EACzC;AAEA,MAAI,QAAQ;AAAA,IACR;AAAA,MACI;AAAA,MACA,EAAC,OAAO,kBAAiB;AAAA,MACzB,CAAC,EAAE,QAAQ,cAAc,CAAE;AAAA,IAC/B;AAAA,IACA,EAAE,aAAa,CAAC,EAAE,QAAQ,WAAW,CAAC,CAAC;AAAA,EAC3C;AAGA,MAAI;AACJ,MAAI,aAAa;AACb,mBAAe;AAAA,MACX;AAAA,MACA,EAAC,OAAO,OAAO,QAAQ,EAAC;AAAA,MACxB,CAAC,EAAE,QAAQ,aAAa,WAAW,EAAE,CAAC;AAAA,IAC1C;AAAA,EACJ;AAEA,MAAI;AACJ,MAAI,SAAS;AACT,eAAW;AAAA,MACP;AAAA,MACA,EAA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