@forsakringskassan/docs-generator 2.2.1 → 2.3.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/compile-example.js +2 -2
- package/dist/{create-markdown-renderer-xVpSTRxi.js → create-markdown-renderer-CipdiqUn.js} +1 -1
- package/dist/index.d.ts +35 -5
- package/dist/index.js +97 -28
- package/dist/markdown.js +2 -2
- package/dist/runtime.js +146 -144
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/{vendor-D59s3fBh.js → vendor-BJuS1z3U.js} +171 -95
- package/dist/{vue3-0ybYLno6.js → vue3-BapCBGbN.js} +1 -1
- package/package.json +2 -2
package/dist/compile-example.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
var path$1 = require('node:path');
|
|
4
4
|
var esbuild = require('esbuild');
|
|
5
5
|
var vue = require('vue');
|
|
6
|
-
var vue3 = require('./vue3-
|
|
6
|
+
var vue3 = require('./vue3-BapCBGbN.js');
|
|
7
7
|
var path = require('node:path/posix');
|
|
8
8
|
require('@vue/compiler-sfc');
|
|
9
|
-
require('./vendor-
|
|
9
|
+
require('./vendor-BJuS1z3U.js');
|
|
10
10
|
require('typescript');
|
|
11
11
|
require('node:url');
|
|
12
12
|
require('fs');
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,17 @@ export declare interface CompileOptions {
|
|
|
26
26
|
* Extra attributes to include in the `<link>` or `<script>` tag.
|
|
27
27
|
*/
|
|
28
28
|
attributes: AttributeTable;
|
|
29
|
+
/**
|
|
30
|
+
* Assets with higher priority is sorted and loaded earlier than assets with
|
|
31
|
+
* lower.
|
|
32
|
+
*
|
|
33
|
+
* The builtin priorities:
|
|
34
|
+
*
|
|
35
|
+
* - Default is `0`.
|
|
36
|
+
* - Processor runtime assets uses `50`.
|
|
37
|
+
* - Bootstrap runtime uses `100`.
|
|
38
|
+
*/
|
|
39
|
+
priority: number;
|
|
29
40
|
}
|
|
30
41
|
|
|
31
42
|
declare interface Component {
|
|
@@ -345,6 +356,19 @@ export declare interface NormalizedDocumentAttributes {
|
|
|
345
356
|
sortorder: number;
|
|
346
357
|
}
|
|
347
358
|
|
|
359
|
+
/**
|
|
360
|
+
* Interface representing `package.json`.
|
|
361
|
+
*
|
|
362
|
+
* @public
|
|
363
|
+
*/
|
|
364
|
+
export declare interface PackageJson {
|
|
365
|
+
readonly name: string;
|
|
366
|
+
readonly version: string;
|
|
367
|
+
readonly repository?: {
|
|
368
|
+
readonly url?: string;
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
348
372
|
/**
|
|
349
373
|
* @public
|
|
350
374
|
*/
|
|
@@ -378,6 +402,7 @@ export declare interface ProcessorContext {
|
|
|
378
402
|
*/
|
|
379
403
|
addTemplateBlock<T>(container: string, id: string, renderer: TemplateBlockRenderer<T>): void;
|
|
380
404
|
/* Excluded from this release type: getAllTemplateBlocks */
|
|
405
|
+
/* Excluded from this release type: hasTemplate */
|
|
381
406
|
setTopNavigation(root: NavigationSection): void;
|
|
382
407
|
setSideNavigation(root: NavigationSection): void;
|
|
383
408
|
getAllTemplateData(): Record<string, unknown>;
|
|
@@ -461,10 +486,7 @@ export declare function searchProcessor(): Processor;
|
|
|
461
486
|
*
|
|
462
487
|
* @public
|
|
463
488
|
*/
|
|
464
|
-
export declare function selectableVersionProcessor(pkg:
|
|
465
|
-
name: string;
|
|
466
|
-
version: string;
|
|
467
|
-
}, container: string, options?: ProcessorOptions): Processor;
|
|
489
|
+
export declare function selectableVersionProcessor(pkg: PackageJson, container: string, options?: ProcessorOptions): Processor;
|
|
468
490
|
|
|
469
491
|
/**
|
|
470
492
|
* Options passed from the example compiler to the `setup` function.
|
|
@@ -494,6 +516,14 @@ export declare interface SourceFiles {
|
|
|
494
516
|
transform?(doc: Document_2): Document_2;
|
|
495
517
|
}
|
|
496
518
|
|
|
519
|
+
/**
|
|
520
|
+
* Processor that provide `componentSourceUrl` template function used for resolving
|
|
521
|
+
* component source urls.
|
|
522
|
+
*
|
|
523
|
+
* @public
|
|
524
|
+
*/
|
|
525
|
+
export declare function sourceUrlProcessor(pkg: PackageJson, options: SourceUrlProcessorOptions): Processor;
|
|
526
|
+
|
|
497
527
|
/**
|
|
498
528
|
* Processor that provide `componentSourceUrl` template function used for resolving
|
|
499
529
|
* component source urls.
|
|
@@ -503,7 +533,7 @@ export declare interface SourceFiles {
|
|
|
503
533
|
export declare function sourceUrlProcessor(options: SourceUrlProcessorOptions): Processor;
|
|
504
534
|
|
|
505
535
|
/**
|
|
506
|
-
* Options for {@link sourceUrlProcessor}.
|
|
536
|
+
* Options for {@link sourceUrlProcessor#}.
|
|
507
537
|
*
|
|
508
538
|
* @public
|
|
509
539
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var fs = require('node:fs/promises');
|
|
4
|
-
var vendor = require('./vendor-
|
|
4
|
+
var vendor = require('./vendor-BJuS1z3U.js');
|
|
5
5
|
var path = require('node:path');
|
|
6
6
|
var require$$1 = require('crypto');
|
|
7
|
-
var createMarkdownRenderer = require('./create-markdown-renderer-
|
|
7
|
+
var createMarkdownRenderer = require('./create-markdown-renderer-CipdiqUn.js');
|
|
8
8
|
var node_child_process = require('node:child_process');
|
|
9
9
|
var path$1 = require('node:path/posix');
|
|
10
10
|
require('node:crypto');
|
|
11
11
|
var util = require('node:util');
|
|
12
12
|
var fs$1 = require('node:fs');
|
|
13
13
|
var vue = require('vue');
|
|
14
|
-
var vue3 = require('./vue3-
|
|
14
|
+
var vue3 = require('./vue3-BapCBGbN.js');
|
|
15
15
|
var vueDocgenApi = require('vue-docgen-api');
|
|
16
16
|
var sass = require('sass');
|
|
17
17
|
var node_url = require('node:url');
|
|
@@ -128,6 +128,39 @@ function getIntegrity(source) {
|
|
|
128
128
|
return `sha384-${hash}`;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
function getPullRequestID(env) {
|
|
132
|
+
if (env.JOB_BASE_NAME) {
|
|
133
|
+
const name = env.JOB_BASE_NAME;
|
|
134
|
+
const match = name.match(/^PR-(\d+)$/);
|
|
135
|
+
return match ? match[1] : void 0;
|
|
136
|
+
}
|
|
137
|
+
if (env.GITHUB_REF) {
|
|
138
|
+
const name = env.GITHUB_REF;
|
|
139
|
+
const match = name.match(/^refs\/pull\/([^/]+)\/merge$/);
|
|
140
|
+
return match ? match[1] : void 0;
|
|
141
|
+
}
|
|
142
|
+
return void 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const RE_MATCH_SSH = /^(ssh:\/\/)?(?<user>[^@]+)@(?<host>[^:]+):(?<path>.*)$/;
|
|
146
|
+
function getRepositoryUrl(value) {
|
|
147
|
+
if (typeof value !== "string") {
|
|
148
|
+
const url = value.repository?.url;
|
|
149
|
+
if (!url) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
value = url;
|
|
153
|
+
}
|
|
154
|
+
value = value.replace(/^git[+]/, "");
|
|
155
|
+
const ssh = value.match(RE_MATCH_SSH);
|
|
156
|
+
if (ssh) {
|
|
157
|
+
const { host, path } = ssh.groups;
|
|
158
|
+
value = `https://${host}/${path}`;
|
|
159
|
+
}
|
|
160
|
+
value = value.replace(/[.]git$/, "");
|
|
161
|
+
return value;
|
|
162
|
+
}
|
|
163
|
+
|
|
131
164
|
function cacheKey$1(...args) {
|
|
132
165
|
return JSON.stringify(args);
|
|
133
166
|
}
|
|
@@ -169,7 +202,7 @@ function haveOutput(doc) {
|
|
|
169
202
|
}
|
|
170
203
|
|
|
171
204
|
function interpolate(value, data) {
|
|
172
|
-
return value.replace(/{{([^}]+)}}/g, (match, raw) => {
|
|
205
|
+
return value.replace(/{{([^{}]+)}}/g, (match, raw) => {
|
|
173
206
|
const key = raw.trim();
|
|
174
207
|
return data[key] ?? match;
|
|
175
208
|
});
|
|
@@ -435,14 +468,6 @@ async function getGitBranch() {
|
|
|
435
468
|
return branch;
|
|
436
469
|
}
|
|
437
470
|
}
|
|
438
|
-
function getPullRequestID() {
|
|
439
|
-
if (process.env.JOB_BASE_NAME) {
|
|
440
|
-
const name = process.env.JOB_BASE_NAME;
|
|
441
|
-
const match = name.match(/PR-(\d+)/);
|
|
442
|
-
return match ? match[1] : void 0;
|
|
443
|
-
}
|
|
444
|
-
return void 0;
|
|
445
|
-
}
|
|
446
471
|
async function getSCMData(pkg, options) {
|
|
447
472
|
const commitHash = await gitCommitHash("full");
|
|
448
473
|
const commitShort = await gitCommitHash("short");
|
|
@@ -450,8 +475,9 @@ async function getSCMData(pkg, options) {
|
|
|
450
475
|
return null;
|
|
451
476
|
}
|
|
452
477
|
const { homepage } = pkg;
|
|
453
|
-
const
|
|
454
|
-
const
|
|
478
|
+
const repository = getRepositoryUrl(pkg) ?? "";
|
|
479
|
+
const pr = getPullRequestID(process.env);
|
|
480
|
+
const prUrl = pr ? interpolate(options.prUrlFormat, { homepage, pr, repository }) : void 0;
|
|
455
481
|
return {
|
|
456
482
|
branch: await getGitBranch(),
|
|
457
483
|
commitShort,
|
|
@@ -459,7 +485,8 @@ async function getSCMData(pkg, options) {
|
|
|
459
485
|
commitUrl: interpolate(options.commitUrlFormat, {
|
|
460
486
|
hash: commitHash,
|
|
461
487
|
short: commitShort,
|
|
462
|
-
homepage
|
|
488
|
+
homepage,
|
|
489
|
+
repository
|
|
463
490
|
}),
|
|
464
491
|
pr,
|
|
465
492
|
prUrl
|
|
@@ -598,12 +625,15 @@ function generateStaticExample(options) {
|
|
|
598
625
|
};
|
|
599
626
|
}
|
|
600
627
|
|
|
601
|
-
function sourceUrlProcessor(
|
|
628
|
+
function sourceUrlProcessor(...args) {
|
|
629
|
+
const pkg = args.length === 2 ? args[0] : {};
|
|
630
|
+
const options = args.length === 2 ? args[1] : args[0];
|
|
602
631
|
const {
|
|
603
632
|
enabled = true,
|
|
604
633
|
urlFormat,
|
|
605
634
|
componentFileExtension = "vue"
|
|
606
635
|
} = options;
|
|
636
|
+
const repository = getRepositoryUrl(pkg) ?? "";
|
|
607
637
|
return {
|
|
608
638
|
after: "generate-docs",
|
|
609
639
|
name: "source-url-processor",
|
|
@@ -617,7 +647,12 @@ function sourceUrlProcessor(options) {
|
|
|
617
647
|
const { source, name } = component;
|
|
618
648
|
const filename = source ?? `${name}.${componentFileExtension}`;
|
|
619
649
|
const path = getExampleImport(["./"], filename);
|
|
620
|
-
return interpolate(urlFormat, {
|
|
650
|
+
return interpolate(urlFormat, {
|
|
651
|
+
path,
|
|
652
|
+
hash,
|
|
653
|
+
short,
|
|
654
|
+
repository
|
|
655
|
+
});
|
|
621
656
|
}
|
|
622
657
|
context.setTemplateData("componentSourceUrl", componentSourceUrl);
|
|
623
658
|
}
|
|
@@ -1046,7 +1081,7 @@ const tildeImporter = {
|
|
|
1046
1081
|
async function compileSassString(dst, style) {
|
|
1047
1082
|
const result = await sass.compileStringAsync(style, {
|
|
1048
1083
|
style: "expanded",
|
|
1049
|
-
importers: [tildeImporter]
|
|
1084
|
+
importers: [new sass.NodePackageImporter(), tildeImporter]
|
|
1050
1085
|
});
|
|
1051
1086
|
await fs.mkdir(path.dirname(dst), { recursive: true });
|
|
1052
1087
|
await fs.writeFile(dst, result.css, "utf-8");
|
|
@@ -1078,6 +1113,12 @@ async function compileStyle(assetFolder, name, src) {
|
|
|
1078
1113
|
}
|
|
1079
1114
|
}
|
|
1080
1115
|
|
|
1116
|
+
function byPriority$1({ options: a }, { options: b }) {
|
|
1117
|
+
return b.priority - a.priority;
|
|
1118
|
+
}
|
|
1119
|
+
function toSorted$1(values, comparator) {
|
|
1120
|
+
return [...values].sort(comparator);
|
|
1121
|
+
}
|
|
1081
1122
|
function cssAssetProcessor(assetFolder, assets) {
|
|
1082
1123
|
return {
|
|
1083
1124
|
name: "css-asset-processor",
|
|
@@ -1086,7 +1127,7 @@ function cssAssetProcessor(assetFolder, assets) {
|
|
|
1086
1127
|
const assetInfo = context.getTemplateData("assets") ?? {};
|
|
1087
1128
|
const head = context.getTemplateData("injectHead") ?? [];
|
|
1088
1129
|
const body = context.getTemplateData("injectBody") ?? [];
|
|
1089
|
-
for (const asset of assets) {
|
|
1130
|
+
for (const asset of toSorted$1(assets, byPriority$1)) {
|
|
1090
1131
|
const info = await compileStyle(
|
|
1091
1132
|
assetFolder,
|
|
1092
1133
|
asset.name,
|
|
@@ -1154,6 +1195,12 @@ async function compileScript(assetFolder, name, src, options) {
|
|
|
1154
1195
|
}
|
|
1155
1196
|
}
|
|
1156
1197
|
|
|
1198
|
+
function byPriority({ options: a }, { options: b }) {
|
|
1199
|
+
return b.priority - a.priority;
|
|
1200
|
+
}
|
|
1201
|
+
function toSorted(values, comparator) {
|
|
1202
|
+
return [...values].sort(comparator);
|
|
1203
|
+
}
|
|
1157
1204
|
function jsAssetProcessor(assetFolder, assets) {
|
|
1158
1205
|
return {
|
|
1159
1206
|
name: "js-asset-processor",
|
|
@@ -1162,7 +1209,7 @@ function jsAssetProcessor(assetFolder, assets) {
|
|
|
1162
1209
|
const assetInfo = context.getTemplateData("assets") ?? {};
|
|
1163
1210
|
const head = context.getTemplateData("injectHead") ?? [];
|
|
1164
1211
|
const body = context.getTemplateData("injectBody") ?? [];
|
|
1165
|
-
for (const asset of assets) {
|
|
1212
|
+
for (const asset of toSorted(assets, byPriority)) {
|
|
1166
1213
|
const info = await compileScript(
|
|
1167
1214
|
assetFolder,
|
|
1168
1215
|
asset.name,
|
|
@@ -1228,7 +1275,8 @@ function compileProcessorRuntime(generator, distDir, processors) {
|
|
|
1228
1275
|
const bundled = new URL(`${name}.js`, distDir);
|
|
1229
1276
|
const scriptPath = fs$1.existsSync(bundled) ? bundled : entry.src;
|
|
1230
1277
|
generator.compileScript(assetName, scriptPath, {
|
|
1231
|
-
appendTo: "body"
|
|
1278
|
+
appendTo: "body",
|
|
1279
|
+
priority: 50
|
|
1232
1280
|
});
|
|
1233
1281
|
}
|
|
1234
1282
|
}
|
|
@@ -1449,14 +1497,22 @@ class TemplateLoader {
|
|
|
1449
1497
|
}
|
|
1450
1498
|
}
|
|
1451
1499
|
}
|
|
1500
|
+
hasTemplate(name) {
|
|
1501
|
+
const { templateCache } = this;
|
|
1502
|
+
const cached = templateCache.get(name);
|
|
1503
|
+
if (cached) {
|
|
1504
|
+
return true;
|
|
1505
|
+
}
|
|
1506
|
+
const filePath = this.findTemplateFile(name);
|
|
1507
|
+
return Boolean(filePath);
|
|
1508
|
+
}
|
|
1452
1509
|
async resolveTemplate(name) {
|
|
1453
1510
|
const { templateCache, folders } = this;
|
|
1454
1511
|
const cached = templateCache.get(name);
|
|
1455
1512
|
if (cached) {
|
|
1456
1513
|
return cached;
|
|
1457
1514
|
}
|
|
1458
|
-
const
|
|
1459
|
-
const filePath = searchPaths.find((it) => fs$1.existsSync(it));
|
|
1515
|
+
const filePath = this.findTemplateFile(name);
|
|
1460
1516
|
if (!filePath) {
|
|
1461
1517
|
const searched = folders.map((it) => ` - "${it}"`).join("\n");
|
|
1462
1518
|
const message = `Failed to resolve template "${name}", searched in:
|
|
@@ -1471,6 +1527,11 @@ Make sure the name is correct and the template file exists in one of the listed
|
|
|
1471
1527
|
templateCache.set(name, resolved);
|
|
1472
1528
|
return resolved;
|
|
1473
1529
|
}
|
|
1530
|
+
findTemplateFile(name) {
|
|
1531
|
+
const { folders } = this;
|
|
1532
|
+
const searchPaths = folders.map((it) => path.join(it, name));
|
|
1533
|
+
return searchPaths.find((it) => fs$1.existsSync(it));
|
|
1534
|
+
}
|
|
1474
1535
|
}
|
|
1475
1536
|
|
|
1476
1537
|
function dump(value) {
|
|
@@ -1647,6 +1708,7 @@ async function compileStandalones(options) {
|
|
|
1647
1708
|
}
|
|
1648
1709
|
function createTemplateLoader(folders) {
|
|
1649
1710
|
loader = new TemplateLoader(folders);
|
|
1711
|
+
return loader;
|
|
1650
1712
|
}
|
|
1651
1713
|
async function render(doc, docs, nav, vendors, options) {
|
|
1652
1714
|
const { fileInfo } = doc;
|
|
@@ -1824,7 +1886,6 @@ function nunjucksProcessor(options) {
|
|
|
1824
1886
|
const docs = context.docs.filter((it) => {
|
|
1825
1887
|
return it.fileInfo.outputName;
|
|
1826
1888
|
});
|
|
1827
|
-
createTemplateLoader(options.templateFolders);
|
|
1828
1889
|
progressbar.start(docs.length, 0, {
|
|
1829
1890
|
filename: docs.length > 0 ? docs[0].fileInfo.fullPath : ""
|
|
1830
1891
|
});
|
|
@@ -2128,7 +2189,7 @@ async function stage(stage2, context, processors, { verbose } = { verbose: true
|
|
|
2128
2189
|
}
|
|
2129
2190
|
return generatedFiles;
|
|
2130
2191
|
}
|
|
2131
|
-
function createContext() {
|
|
2192
|
+
function createContext(templateLoader) {
|
|
2132
2193
|
let docs = [];
|
|
2133
2194
|
let vendors = [];
|
|
2134
2195
|
const resources = [];
|
|
@@ -2188,6 +2249,9 @@ function createContext() {
|
|
|
2188
2249
|
getAllTemplateBlocks() {
|
|
2189
2250
|
return templateBlocks;
|
|
2190
2251
|
},
|
|
2252
|
+
hasTemplate(name) {
|
|
2253
|
+
return Boolean(templateLoader?.hasTemplate(name));
|
|
2254
|
+
},
|
|
2191
2255
|
setTopNavigation(root) {
|
|
2192
2256
|
topnav = root;
|
|
2193
2257
|
},
|
|
@@ -2238,7 +2302,8 @@ class Generator {
|
|
|
2238
2302
|
this.sourceFiles = [];
|
|
2239
2303
|
const bootstrapUrl = new URL("runtime-bootstrap.js", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
|
|
2240
2304
|
this.compileScript("bootstrap", bootstrapUrl, {
|
|
2241
|
-
appendTo: "head"
|
|
2305
|
+
appendTo: "head",
|
|
2306
|
+
priority: 100
|
|
2242
2307
|
});
|
|
2243
2308
|
}
|
|
2244
2309
|
compileScript(name, src, options) {
|
|
@@ -2248,6 +2313,7 @@ class Generator {
|
|
|
2248
2313
|
options: {
|
|
2249
2314
|
appendTo: "none",
|
|
2250
2315
|
attributes: {},
|
|
2316
|
+
priority: 0,
|
|
2251
2317
|
...options
|
|
2252
2318
|
}
|
|
2253
2319
|
});
|
|
@@ -2259,6 +2325,7 @@ class Generator {
|
|
|
2259
2325
|
options: {
|
|
2260
2326
|
appendTo: "none",
|
|
2261
2327
|
attributes: {},
|
|
2328
|
+
priority: 0,
|
|
2262
2329
|
...options
|
|
2263
2330
|
}
|
|
2264
2331
|
});
|
|
@@ -2287,7 +2354,8 @@ class Generator {
|
|
|
2287
2354
|
fileReaderProcessor(sourceFiles),
|
|
2288
2355
|
...this.processors
|
|
2289
2356
|
];
|
|
2290
|
-
const
|
|
2357
|
+
const templateLoader = createTemplateLoader([]);
|
|
2358
|
+
const context = createContext(templateLoader);
|
|
2291
2359
|
await stage("generate-docs", context, processors, { verbose: false });
|
|
2292
2360
|
const docs = context.docs.filter(haveOutput);
|
|
2293
2361
|
const pages = docs.map(manifestPageFromDocument);
|
|
@@ -2326,7 +2394,8 @@ class Generator {
|
|
|
2326
2394
|
...this.processors
|
|
2327
2395
|
];
|
|
2328
2396
|
compileProcessorRuntime(this, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)), processors);
|
|
2329
|
-
const
|
|
2397
|
+
const templateLoader = createTemplateLoader(templateFolders);
|
|
2398
|
+
const context = createContext(templateLoader);
|
|
2330
2399
|
const generatedFiles = [
|
|
2331
2400
|
await stage("generate-docs", context, processors),
|
|
2332
2401
|
await stage("generate-nav", context, processors),
|
package/dist/markdown.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var createMarkdownRenderer = require('./create-markdown-renderer-
|
|
4
|
-
require('./vendor-
|
|
3
|
+
var createMarkdownRenderer = require('./create-markdown-renderer-CipdiqUn.js');
|
|
4
|
+
require('./vendor-BJuS1z3U.js');
|
|
5
5
|
require('@vue/compiler-sfc');
|
|
6
6
|
require('typescript');
|
|
7
7
|
require('node:url');
|