@forsakringskassan/docs-generator 3.1.2 → 3.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/{create-markdown-renderer-fg4eQJx_.mjs → create-markdown-renderer-DLvvsGCZ.mjs} +93 -66
- package/dist/create-markdown-renderer-DLvvsGCZ.mjs.map +1 -0
- package/dist/{format-code.worker-DnB63s6w.mjs → format-code.worker-BRTVVuKa.mjs} +2 -2
- package/dist/{format-code.worker-DnB63s6w.mjs.map → format-code.worker-BRTVVuKa.mjs.map} +1 -1
- package/dist/index.d.mts +52 -0
- package/dist/index.mjs +21 -16
- package/dist/index.mjs.map +1 -1
- package/dist/markdown.d.mts +50 -0
- package/dist/markdown.mjs +2 -2
- package/dist/processors/selectable-version.mjs +3 -2
- package/dist/runtime.mjs +31 -13
- package/dist/{vendor-DWCXj2K2.mjs → vendor-DR1Vkbzf.mjs} +6 -3
- package/dist/{vendor-DWCXj2K2.mjs.map → vendor-DR1Vkbzf.mjs.map} +1 -1
- package/package.json +14 -6
- package/dist/create-markdown-renderer-fg4eQJx_.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -3,12 +3,12 @@ import { createRequire as $createRequire } from "node:module";
|
|
|
3
3
|
const require = $createRequire(import.meta.url);
|
|
4
4
|
|
|
5
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-
|
|
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-DR1Vkbzf.mjs';
|
|
7
7
|
import path__default from 'node:path';
|
|
8
8
|
import crypto from 'node:crypto';
|
|
9
9
|
import path from 'node:path/posix';
|
|
10
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 parseImport, d as findTag, e as getOutputFilePath, j as htmlencode, k as filePath, c as createMarkdownRenderer, l as generateExample } from './create-markdown-renderer-
|
|
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 parseImport, d as findTag, e as getOutputFilePath, j as htmlencode, k as filePath, c as createMarkdownRenderer, l as generateExample } from './create-markdown-renderer-DLvvsGCZ.mjs';
|
|
12
12
|
import { DocExcerpt } from '@microsoft/tsdoc';
|
|
13
13
|
import fs from 'node:fs/promises';
|
|
14
14
|
import util, { promisify, styleText } from 'node:util';
|
|
@@ -97,7 +97,7 @@ function fileMatcher(patterns) {
|
|
|
97
97
|
});
|
|
98
98
|
return memoize((filename, context) => {
|
|
99
99
|
const matches = fileList.filter((file) => {
|
|
100
|
-
const stem = file.replace(/^(
|
|
100
|
+
const stem = file.replace(/^(?:\.\.\/)+/, "");
|
|
101
101
|
return path__default.matchesGlob(stem, `**/${filename}`);
|
|
102
102
|
});
|
|
103
103
|
if (matches.length === 0) {
|
|
@@ -129,7 +129,7 @@ function formatSize(value) {
|
|
|
129
129
|
return `${String(value)} GB`;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
const matchHeading = /^(#+)(.*)$/gm;
|
|
132
|
+
const matchHeading = /^(#+)([^#].*)$/gm;
|
|
133
133
|
function getHeadings(text) {
|
|
134
134
|
return Array.from(text.matchAll(matchHeading), parseHeading);
|
|
135
135
|
}
|
|
@@ -186,7 +186,7 @@ function getPullRequestID(env) {
|
|
|
186
186
|
return void 0;
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
const RE_MATCH_SSH = /^
|
|
189
|
+
const RE_MATCH_SSH = /^[^@]+@(?<host>[^:]+):(?<path>.*)$/;
|
|
190
190
|
function getRepositoryUrl(value) {
|
|
191
191
|
if (typeof value !== "string") {
|
|
192
192
|
const url = value.repository?.url;
|
|
@@ -232,7 +232,7 @@ function haveOutput(doc) {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
function interpolate(value, data) {
|
|
235
|
-
return value.replaceAll(
|
|
235
|
+
return value.replaceAll(/\{\{([^{}]+)\}\}/g, (match, raw) => {
|
|
236
236
|
const key = raw.trim();
|
|
237
237
|
const value2 = data[key];
|
|
238
238
|
return value2 ?? match;
|
|
@@ -286,7 +286,7 @@ function difference(a, b) {
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
function slugify(value) {
|
|
289
|
-
return value.toLowerCase().replaceAll("/", "--").replaceAll(/[^a-z]+/g, "-").replace(
|
|
289
|
+
return value.toLowerCase().replaceAll("/", "--").replaceAll(/[^a-z]+/g, "-").replace(/^-+|-+$/, "");
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
function isRelease() {
|
|
@@ -1426,8 +1426,8 @@ function findLocation(content, attr) {
|
|
|
1426
1426
|
}
|
|
1427
1427
|
const blockBegin = 2;
|
|
1428
1428
|
return {
|
|
1429
|
-
start: { line: index + blockBegin, column:
|
|
1430
|
-
end: { line: index + blockBegin, column:
|
|
1429
|
+
start: { line: index + blockBegin, column: 0 },
|
|
1430
|
+
end: { line: index + blockBegin, column: attr.length }
|
|
1431
1431
|
};
|
|
1432
1432
|
}
|
|
1433
1433
|
function getSuggestion(attribute) {
|
|
@@ -1682,8 +1682,8 @@ function findDocComment(path, node) {
|
|
|
1682
1682
|
return doc;
|
|
1683
1683
|
}
|
|
1684
1684
|
}
|
|
1685
|
-
const grandparent = path.parentPath
|
|
1686
|
-
if (parent.type === "VariableDeclarator" && grandparent
|
|
1685
|
+
const grandparent = path.parentPath.parent;
|
|
1686
|
+
if (parent.type === "VariableDeclarator" && grandparent.leadingComments) {
|
|
1687
1687
|
const doc = grandparent.leadingComments.find(isDocComment);
|
|
1688
1688
|
if (doc) {
|
|
1689
1689
|
return doc;
|
|
@@ -2858,7 +2858,7 @@ Make sure the name is correct and the template file exists in one of the listed
|
|
|
2858
2858
|
}
|
|
2859
2859
|
}
|
|
2860
2860
|
|
|
2861
|
-
const messageRegex = /^\([^)]+\) \[Line \d+, Column \d
|
|
2861
|
+
const messageRegex = /^\([^)]+\) \[Line \d+, Column \d+\]\n\s+Error: (.*)$/;
|
|
2862
2862
|
function getActualMessage(message) {
|
|
2863
2863
|
const match = messageRegex.exec(message);
|
|
2864
2864
|
if (match) {
|
|
@@ -3002,7 +3002,7 @@ function createTemplateLoader(folders) {
|
|
|
3002
3002
|
return loader;
|
|
3003
3003
|
}
|
|
3004
3004
|
function stripPrettierComments(content) {
|
|
3005
|
-
return content.replaceAll(/\s*<!-- prettier-ignore -->\s*/
|
|
3005
|
+
return content.replaceAll(/\s*<!-- prettier-ignore -->\s*/g, "");
|
|
3006
3006
|
}
|
|
3007
3007
|
async function render(doc, docs, options) {
|
|
3008
3008
|
const { fileInfo } = doc;
|
|
@@ -3013,7 +3013,8 @@ async function render(doc, docs, options) {
|
|
|
3013
3013
|
exampleFileMatcher,
|
|
3014
3014
|
nav,
|
|
3015
3015
|
templateFolders,
|
|
3016
|
-
vendors
|
|
3016
|
+
vendors,
|
|
3017
|
+
linkResolvers
|
|
3017
3018
|
} = options;
|
|
3018
3019
|
if (!haveOutputFile(fileInfo)) {
|
|
3019
3020
|
return null;
|
|
@@ -3110,7 +3111,8 @@ async function render(doc, docs, options) {
|
|
|
3110
3111
|
handleSoftError(error) {
|
|
3111
3112
|
throw error;
|
|
3112
3113
|
},
|
|
3113
|
-
messagebox: options.markdown.messagebox
|
|
3114
|
+
messagebox: options.markdown.messagebox,
|
|
3115
|
+
linkResolvers
|
|
3114
3116
|
});
|
|
3115
3117
|
njk.addFilter("marked", (content2) => {
|
|
3116
3118
|
return markdownRenderer.render(doc, content2);
|
|
@@ -3162,7 +3164,7 @@ async function render(doc, docs, options) {
|
|
|
3162
3164
|
const message = err instanceof Error ? err.message : String(err);
|
|
3163
3165
|
throw new Error(`${prefix}: ${message}`, { cause: err });
|
|
3164
3166
|
}
|
|
3165
|
-
const expandedDst = dst.replaceAll(/\[([
|
|
3167
|
+
const expandedDst = dst.replaceAll(/\[([\s\S]+)\]/g, (match, key) => {
|
|
3166
3168
|
if (key === "hash") {
|
|
3167
3169
|
return getFingerprint(doc.body);
|
|
3168
3170
|
} else {
|
|
@@ -3229,6 +3231,7 @@ function nunjucksProcessor(options) {
|
|
|
3229
3231
|
templateBlocks: context.getAllTemplateBlocks(),
|
|
3230
3232
|
templateData: context.getAllTemplateData(),
|
|
3231
3233
|
vendors: context.vendors,
|
|
3234
|
+
linkResolvers: options.linkResolvers,
|
|
3232
3235
|
addResource(dst, src) {
|
|
3233
3236
|
context.addResource(dst, src);
|
|
3234
3237
|
}
|
|
@@ -3787,6 +3790,7 @@ class Generator {
|
|
|
3787
3790
|
await i18n.init();
|
|
3788
3791
|
await this._prepareFolders();
|
|
3789
3792
|
await this._copyFonts();
|
|
3793
|
+
const linkResolvers = this.processors.map((it) => it.enabled !== false ? it.resolveLink : void 0).filter((it) => Boolean(it));
|
|
3790
3794
|
const processors = [
|
|
3791
3795
|
fileReaderProcessor(sourceFiles),
|
|
3792
3796
|
redirectProcessor(),
|
|
@@ -3806,6 +3810,7 @@ class Generator {
|
|
|
3806
3810
|
exampleFolders,
|
|
3807
3811
|
templateFolders,
|
|
3808
3812
|
setupPath,
|
|
3813
|
+
linkResolvers,
|
|
3809
3814
|
markdown: markdownOptions ?? {}
|
|
3810
3815
|
}),
|
|
3811
3816
|
...this.processors
|