@forsakringskassan/docs-generator 2.42.0 → 2.43.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/{create-markdown-renderer-DX0B9T-x.mjs → create-markdown-renderer-CO5Te-tH.mjs} +38 -30
- package/dist/create-markdown-renderer-CO5Te-tH.mjs.map +1 -0
- package/dist/{format-code.worker-E71lNJrD.mjs → format-code.worker-D7IOA5jE.mjs} +2 -2
- package/dist/{format-code.worker-E71lNJrD.mjs.map → format-code.worker-D7IOA5jE.mjs.map} +1 -1
- package/dist/index.d.mts +36 -2
- package/dist/index.mjs +304 -21
- package/dist/index.mjs.map +1 -1
- package/dist/markdown.d.mts +19 -2
- package/dist/markdown.mjs +2 -2
- package/dist/{vendor-BoRn-ubH.mjs → vendor-BImorfXU.mjs} +7547 -7547
- package/dist/{vendor-BoRn-ubH.mjs.map → vendor-BImorfXU.mjs.map} +1 -1
- package/package.json +3 -1
- package/dist/create-markdown-renderer-DX0B9T-x.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -2,13 +2,15 @@ import { createRequire as $createRequire } from "node:module";
|
|
|
2
2
|
|
|
3
3
|
const require = $createRequire(import.meta.url);
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { t as ts, M as MarkdownIt, d as dedent, g as closest, h as distance, i as fm, j as isCI, Z as Ze, m as moduleImporter, k as cliProgress, l as tinylr, w as watch, n as createInstance, o as fse, p as inter } from './vendor-BoRn-ubH.mjs';
|
|
8
|
-
import { g as generateId, p as parseInfostring, i as isDocumentPage, n as normalizePath, a as getFingerprint, h as hasTag, f as findTag, b as getOutputFilePath, d as htmlencode, e as filePath, c as createMarkdownRenderer, j as generateExample } from './create-markdown-renderer-DX0B9T-x.mjs';
|
|
5
|
+
import { ApiItemKind, ApiModel } from '@microsoft/api-extractor-model';
|
|
6
|
+
import { t as ts, Z as Ze, M as MarkdownIt, d as dedent, g as closest, h as distance, i as fm, j as isCI, m as moduleImporter, k as cliProgress, l as tinylr, w as watch, n as createInstance, o as fse, p as inter } from './vendor-BImorfXU.mjs';
|
|
9
7
|
import path__default from 'node:path';
|
|
10
8
|
import crypto from 'node:crypto';
|
|
9
|
+
import path from 'node:path/posix';
|
|
11
10
|
import { exec, execSync } from 'node:child_process';
|
|
11
|
+
import { g as generateId, f as formatCode, p as parseInfostring, i as isDocumentPage, n as normalizePath, a as getFingerprint, h as hasTag, b as findTag, d as getOutputFilePath, e as htmlencode, j as filePath, c as createMarkdownRenderer, k as generateExample } from './create-markdown-renderer-CO5Te-tH.mjs';
|
|
12
|
+
import { DocExcerpt } from '@microsoft/tsdoc';
|
|
13
|
+
import fs from 'node:fs/promises';
|
|
12
14
|
import util, { promisify } from 'node:util';
|
|
13
15
|
import { codeFrameColumns } from '@babel/code-frame';
|
|
14
16
|
import { parse as parse$1 } from '@babel/parser';
|
|
@@ -74,22 +76,6 @@ function matomoProcessor(options) {
|
|
|
74
76
|
};
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
const documentAttributeKeys = [
|
|
78
|
-
"title",
|
|
79
|
-
"short-title",
|
|
80
|
-
"layout",
|
|
81
|
-
"name",
|
|
82
|
-
"alias",
|
|
83
|
-
"status",
|
|
84
|
-
"visible",
|
|
85
|
-
"include",
|
|
86
|
-
"component",
|
|
87
|
-
"href",
|
|
88
|
-
"search",
|
|
89
|
-
"sortorder",
|
|
90
|
-
"redirect_from"
|
|
91
|
-
];
|
|
92
|
-
|
|
93
79
|
function cacheKey$1(...args) {
|
|
94
80
|
return JSON.stringify(args);
|
|
95
81
|
}
|
|
@@ -252,6 +238,19 @@ function interpolate(value, data) {
|
|
|
252
238
|
});
|
|
253
239
|
}
|
|
254
240
|
|
|
241
|
+
function naturalJoin(values, conjunction = "or") {
|
|
242
|
+
switch (values.length) {
|
|
243
|
+
case 0:
|
|
244
|
+
return "";
|
|
245
|
+
case 1:
|
|
246
|
+
return values[0];
|
|
247
|
+
case 2:
|
|
248
|
+
return `${values[0]} ${conjunction} ${values[1]}`;
|
|
249
|
+
default:
|
|
250
|
+
return `${values.slice(0, -1).join(", ")} ${conjunction} ${values.at(-1)}`;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
255
254
|
function quote(text) {
|
|
256
255
|
return String(text).replaceAll('"', """);
|
|
257
256
|
}
|
|
@@ -300,6 +299,290 @@ function isRelease() {
|
|
|
300
299
|
}
|
|
301
300
|
}
|
|
302
301
|
|
|
302
|
+
const available = {
|
|
303
|
+
interface: ["default", "interface", "properties"]
|
|
304
|
+
};
|
|
305
|
+
function getVariant(kind, tags) {
|
|
306
|
+
const variant = available[kind].find((it) => tags.includes(it));
|
|
307
|
+
return variant ?? "default";
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function isDocumentedItem(item) {
|
|
311
|
+
return "tsdocComment" in item;
|
|
312
|
+
}
|
|
313
|
+
function documentation(node) {
|
|
314
|
+
if (node && isDocumentedItem(node)) {
|
|
315
|
+
const { tsdocComment } = node;
|
|
316
|
+
return renderNode(tsdocComment?.summarySection).trim();
|
|
317
|
+
} else {
|
|
318
|
+
return void 0;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function documentationComment(node) {
|
|
322
|
+
const doc = documentation(node);
|
|
323
|
+
if (doc === void 0) {
|
|
324
|
+
return void 0;
|
|
325
|
+
}
|
|
326
|
+
if (!doc) {
|
|
327
|
+
return "";
|
|
328
|
+
}
|
|
329
|
+
const lines = doc.split("\n");
|
|
330
|
+
const commentLines = lines.map((line) => line ? ` * ${line}` : ` *`);
|
|
331
|
+
return ["/**", ...commentLines, " */"].join("\n");
|
|
332
|
+
}
|
|
333
|
+
function renderNode(docNode) {
|
|
334
|
+
let result = "";
|
|
335
|
+
if (docNode) {
|
|
336
|
+
if (docNode instanceof DocExcerpt) {
|
|
337
|
+
result += docNode.content.toString();
|
|
338
|
+
}
|
|
339
|
+
for (const childNode of docNode.getChildNodes()) {
|
|
340
|
+
result += renderNode(childNode);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
return formatMarkdownLists(result);
|
|
344
|
+
}
|
|
345
|
+
function formatMarkdownLists(text) {
|
|
346
|
+
return text.replaceAll(/(\S)[^\S\n]+([*-])[^\S\n]+/g, "$1\n$2 ");
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function isApiInterface(item) {
|
|
350
|
+
return item.kind === ApiItemKind.Interface;
|
|
351
|
+
}
|
|
352
|
+
function findMemberByName(name, pkg) {
|
|
353
|
+
for (const entryPoint of pkg.entryPoints) {
|
|
354
|
+
for (const member of entryPoint.findMembersByName(name)) {
|
|
355
|
+
if (isApiInterface(member)) {
|
|
356
|
+
return member;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return void 0;
|
|
361
|
+
}
|
|
362
|
+
function getNameFromExcerpt(excerpt) {
|
|
363
|
+
const [token] = excerpt.tokens.slice(
|
|
364
|
+
excerpt.tokenRange.startIndex,
|
|
365
|
+
excerpt.tokenRange.endIndex
|
|
366
|
+
);
|
|
367
|
+
return token.text;
|
|
368
|
+
}
|
|
369
|
+
function getInheritance(item) {
|
|
370
|
+
const pkg = item.getAssociatedPackage();
|
|
371
|
+
if (!pkg) {
|
|
372
|
+
return [];
|
|
373
|
+
}
|
|
374
|
+
const hierarchy = [];
|
|
375
|
+
const visited = /* @__PURE__ */ new Set();
|
|
376
|
+
function traverseParents(current, pkg2) {
|
|
377
|
+
if (visited.has(current.name)) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
visited.add(current.name);
|
|
381
|
+
for (const { excerpt } of current.extendsTypes) {
|
|
382
|
+
const name = getNameFromExcerpt(excerpt);
|
|
383
|
+
const parentInterface = findMemberByName(name, pkg2);
|
|
384
|
+
if (parentInterface) {
|
|
385
|
+
traverseParents(parentInterface, pkg2);
|
|
386
|
+
hierarchy.push(parentInterface);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
traverseParents(item, pkg);
|
|
391
|
+
hierarchy.push(item);
|
|
392
|
+
return hierarchy;
|
|
393
|
+
}
|
|
394
|
+
function collectMembers(item, inherit) {
|
|
395
|
+
if (!inherit) {
|
|
396
|
+
return item.members.filter(isSupported);
|
|
397
|
+
}
|
|
398
|
+
const hierarchy = getInheritance(item);
|
|
399
|
+
const members = /* @__PURE__ */ new Map();
|
|
400
|
+
for (const iface of hierarchy) {
|
|
401
|
+
for (const member of iface.members.filter(isSupported)) {
|
|
402
|
+
members.set(member.name, member);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return [...members.values()];
|
|
406
|
+
}
|
|
407
|
+
function isSupported(item) {
|
|
408
|
+
return [
|
|
409
|
+
ApiItemKind.PropertySignature,
|
|
410
|
+
ApiItemKind.MethodSignature
|
|
411
|
+
].includes(item.kind);
|
|
412
|
+
}
|
|
413
|
+
function renderCode(item, members, options) {
|
|
414
|
+
const inherit = options.inherit ?? false;
|
|
415
|
+
const renderedMembers = members.map((it) => {
|
|
416
|
+
const summary = documentationComment(it);
|
|
417
|
+
const comment = summary ? `
|
|
418
|
+
${summary}` : "";
|
|
419
|
+
return `${comment}
|
|
420
|
+
${it.excerpt.text}`;
|
|
421
|
+
});
|
|
422
|
+
const header = item.excerpt.text.replace(/^export /, "").trimEnd();
|
|
423
|
+
const extendsIndex = header.indexOf(" extends ");
|
|
424
|
+
const declaration = inherit && extendsIndex !== -1 ? header.slice(0, extendsIndex) : header;
|
|
425
|
+
const source = `${declaration} { ${renderedMembers.join("")} }`;
|
|
426
|
+
return [
|
|
427
|
+
"```ts nocompile nolint",
|
|
428
|
+
formatCode(source, "docs/api-interface.ts"),
|
|
429
|
+
"```"
|
|
430
|
+
].join("\n");
|
|
431
|
+
}
|
|
432
|
+
function renderProperties(members) {
|
|
433
|
+
return members.map((it) => {
|
|
434
|
+
const optional = it.isOptional ? " {@optional}" : "";
|
|
435
|
+
const summary = documentation(it);
|
|
436
|
+
const lines = summary ? summary.split("\n").map((it2, i) => {
|
|
437
|
+
if (it2.trim() === "") {
|
|
438
|
+
return "\n";
|
|
439
|
+
}
|
|
440
|
+
const prefix = i === 0 ? ": " : " ";
|
|
441
|
+
return `${prefix}${it2.trim()}
|
|
442
|
+
`;
|
|
443
|
+
}) : [": ‐\n"];
|
|
444
|
+
return [`\`${it.excerpt.text}\`${optional}
|
|
445
|
+
`, ...lines].join("");
|
|
446
|
+
}).join("\n");
|
|
447
|
+
}
|
|
448
|
+
function renderInterface() {
|
|
449
|
+
return {
|
|
450
|
+
default(item, options) {
|
|
451
|
+
const inherit = options.inherit ?? false;
|
|
452
|
+
return renderCode(item, collectMembers(item, inherit), options);
|
|
453
|
+
},
|
|
454
|
+
interface(item, options) {
|
|
455
|
+
const inherit = options.inherit ?? false;
|
|
456
|
+
return renderCode(item, collectMembers(item, inherit), options);
|
|
457
|
+
},
|
|
458
|
+
properties(item, options) {
|
|
459
|
+
const inherit = options.inherit ?? true;
|
|
460
|
+
return renderProperties(collectMembers(item, inherit));
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function getFilenames(patterns) {
|
|
466
|
+
return Ze(patterns, { posix: true });
|
|
467
|
+
}
|
|
468
|
+
function pluralize(text, array) {
|
|
469
|
+
const s = array.length !== 1 ? "s" : "";
|
|
470
|
+
return `${text}${s}`;
|
|
471
|
+
}
|
|
472
|
+
function loadedMessage(kind, array) {
|
|
473
|
+
return [array.length, pluralize(kind, array), "loaded"];
|
|
474
|
+
}
|
|
475
|
+
function getInheritOption(tags) {
|
|
476
|
+
if (tags.includes("inherit")) {
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
if (tags.includes("noinherit")) {
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
return void 0;
|
|
483
|
+
}
|
|
484
|
+
function walk(root, fns) {
|
|
485
|
+
const t = fns;
|
|
486
|
+
for (const member of root.members) {
|
|
487
|
+
const fn = t[member.kind];
|
|
488
|
+
if (fn) {
|
|
489
|
+
fn(member);
|
|
490
|
+
}
|
|
491
|
+
walk(member, fns);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
function isAmbigious(name, names) {
|
|
495
|
+
const found = names.get(name);
|
|
496
|
+
return found.length > 1 ? found : null;
|
|
497
|
+
}
|
|
498
|
+
function createPartial(options) {
|
|
499
|
+
const { id, name, fullPath, names, render } = options;
|
|
500
|
+
return {
|
|
501
|
+
kind: "partial",
|
|
502
|
+
id,
|
|
503
|
+
alias: [],
|
|
504
|
+
name: `interface:${name}`,
|
|
505
|
+
body(tags, reference) {
|
|
506
|
+
if (reference.kind === "name") {
|
|
507
|
+
const ambigious = isAmbigious(name, names);
|
|
508
|
+
if (ambigious) {
|
|
509
|
+
const quoted = ambigious.map((it) => `"${it}"`);
|
|
510
|
+
const ids = naturalJoin(quoted, "and");
|
|
511
|
+
throw new Error(
|
|
512
|
+
`Ambiguous name "${name}", found ${ambigious.length} interfaces matching this name: ${ids}`
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return render(tags);
|
|
517
|
+
},
|
|
518
|
+
format: "markdown",
|
|
519
|
+
fileInfo: {
|
|
520
|
+
fullPath
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
function apiExtractorProcessor(options = {}) {
|
|
525
|
+
const { apiModel: patterns = [], enabled = true } = options;
|
|
526
|
+
return {
|
|
527
|
+
name: "apiExtractorProcessor",
|
|
528
|
+
after: "generate-docs",
|
|
529
|
+
async handler(context) {
|
|
530
|
+
if (!enabled) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const symbols = {
|
|
534
|
+
interface: []
|
|
535
|
+
};
|
|
536
|
+
for (const filename of await getFilenames(patterns)) {
|
|
537
|
+
const apiModel = new ApiModel();
|
|
538
|
+
const apiPackage = apiModel.loadPackage(filename);
|
|
539
|
+
walk(apiPackage, {
|
|
540
|
+
[ApiItemKind.Interface](item) {
|
|
541
|
+
symbols.interface.push(item);
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
const interfaceRenderer = renderInterface();
|
|
546
|
+
const seenInterfaces = /* @__PURE__ */ new Map();
|
|
547
|
+
for (const item of symbols.interface) {
|
|
548
|
+
const id = item.canonicalReference.toString();
|
|
549
|
+
const found = seenInterfaces.get(item.name) ?? [];
|
|
550
|
+
seenInterfaces.set(item.name, [...found, id]);
|
|
551
|
+
const partial = createPartial({
|
|
552
|
+
id,
|
|
553
|
+
name: item.name,
|
|
554
|
+
names: seenInterfaces,
|
|
555
|
+
fullPath: item.sourceLocation.fileUrl,
|
|
556
|
+
render(tags) {
|
|
557
|
+
const variant = getVariant("interface", tags);
|
|
558
|
+
return interfaceRenderer[variant](item, {
|
|
559
|
+
inherit: getInheritOption(tags)
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
context.addDocument(partial);
|
|
564
|
+
}
|
|
565
|
+
context.log(...loadedMessage("interface", symbols.interface));
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
const documentAttributeKeys = [
|
|
571
|
+
"title",
|
|
572
|
+
"short-title",
|
|
573
|
+
"layout",
|
|
574
|
+
"name",
|
|
575
|
+
"alias",
|
|
576
|
+
"status",
|
|
577
|
+
"visible",
|
|
578
|
+
"include",
|
|
579
|
+
"component",
|
|
580
|
+
"href",
|
|
581
|
+
"search",
|
|
582
|
+
"sortorder",
|
|
583
|
+
"redirect_from"
|
|
584
|
+
];
|
|
585
|
+
|
|
303
586
|
const md$6 = MarkdownIt();
|
|
304
587
|
md$6.renderer.rules.fence = (tokens, idx, _options, collected) => {
|
|
305
588
|
const { content, info } = tokens[idx];
|
|
@@ -3594,5 +3877,5 @@ function searchProcessor() {
|
|
|
3594
3877
|
};
|
|
3595
3878
|
}
|
|
3596
3879
|
|
|
3597
|
-
export { Generator, availableProcessors, cookieProcessor, defineSources, extractExamplesProcessor, frontMatterFileReader, htmlRedirectProcessor, isRelease, livereloadProcessor, manifestProcessor, matomoProcessor, motdProcessor, navigationFileReader, processorRuntimeName, redirectFileProcessor, searchProcessor, selectableVersionProcessor, sourceUrlProcessor, topnavProcessor, versionBannerProcessor, versionProcessor, vueFileReader };
|
|
3880
|
+
export { Generator, apiExtractorProcessor, availableProcessors, cookieProcessor, defineSources, extractExamplesProcessor, frontMatterFileReader, htmlRedirectProcessor, isRelease, livereloadProcessor, manifestProcessor, matomoProcessor, motdProcessor, navigationFileReader, processorRuntimeName, redirectFileProcessor, searchProcessor, selectableVersionProcessor, sourceUrlProcessor, topnavProcessor, versionBannerProcessor, versionProcessor, vueFileReader };
|
|
3598
3881
|
//# sourceMappingURL=index.mjs.map
|