@forsakringskassan/docs-generator 2.14.5 → 2.15.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.
|
@@ -101,6 +101,17 @@ function getExampleName(filename) {
|
|
|
101
101
|
return path$1.parse(filename).name;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
function normalizeLanguage(lang) {
|
|
105
|
+
switch (lang) {
|
|
106
|
+
case "ts":
|
|
107
|
+
return "typescript";
|
|
108
|
+
case "js":
|
|
109
|
+
return "javascript";
|
|
110
|
+
default:
|
|
111
|
+
return lang;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
104
115
|
function removeLinesInline(lines, { begin, end }) {
|
|
105
116
|
for (let i = begin; i <= end; i++) {
|
|
106
117
|
lines[i] = "";
|
|
@@ -119,11 +130,12 @@ function removeLinesInline(lines, { begin, end }) {
|
|
|
119
130
|
function cutSnippets(code) {
|
|
120
131
|
const lines = code.split(/\n/).map((it, index, lines2) => index < lines2.length - 1 ? `${it}
|
|
121
132
|
` : it);
|
|
122
|
-
const directive =
|
|
133
|
+
const directive = /(?:\/\* +--- +cut (?<js>above|below|begin|end) +--- +\*\/|<!---? +cut (?<html>above|below|begin|end) +---?>)/;
|
|
123
134
|
let buffer = -1;
|
|
124
135
|
lines.forEach((line, index) => {
|
|
125
136
|
const match = line.match(directive);
|
|
126
|
-
const
|
|
137
|
+
const { js, html } = match?.groups ?? { js: null, html: null };
|
|
138
|
+
const instruction = js ?? html;
|
|
127
139
|
if (!instruction) {
|
|
128
140
|
return;
|
|
129
141
|
}
|
|
@@ -182,11 +194,14 @@ function maybeDedent(value) {
|
|
|
182
194
|
}
|
|
183
195
|
}
|
|
184
196
|
const transformations = {
|
|
197
|
+
html: [cutSnippets, maybeDedent],
|
|
198
|
+
vue: [cutSnippets, maybeDedent],
|
|
185
199
|
javascript: [cutSnippets, stripEslintComments, maybeDedent],
|
|
186
200
|
typescript: [cutSnippets, stripEslintComments, maybeDedent]
|
|
187
201
|
};
|
|
188
202
|
function transformCode(code, lang) {
|
|
189
|
-
const
|
|
203
|
+
const normalizedLanguage = normalizeLanguage(lang);
|
|
204
|
+
const fns = transformations[normalizedLanguage] ?? [];
|
|
190
205
|
for (const fn of fns) {
|
|
191
206
|
code = fn(code);
|
|
192
207
|
}
|
|
@@ -280,16 +295,6 @@ function generateStaticExample(options) {
|
|
|
280
295
|
};
|
|
281
296
|
}
|
|
282
297
|
|
|
283
|
-
function normalizeLanguage(lang) {
|
|
284
|
-
switch (lang) {
|
|
285
|
-
case "ts":
|
|
286
|
-
return "typescript";
|
|
287
|
-
case "js":
|
|
288
|
-
return "javascript";
|
|
289
|
-
default:
|
|
290
|
-
return lang;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
298
|
function parseInfostring(infostring) {
|
|
294
299
|
const [rawLanguage, ...rawTags] = infostring.trim().split(/\s+/);
|
|
295
300
|
return {
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var vendor = require('./vendor-Dlhn3sOl.js');
|
|
|
6
6
|
var path$1 = require('node:path');
|
|
7
7
|
var require$$1 = require('crypto');
|
|
8
8
|
require('node:crypto');
|
|
9
|
-
var createMarkdownRenderer = require('./create-markdown-renderer-
|
|
9
|
+
var createMarkdownRenderer = require('./create-markdown-renderer-CDFtdfff.js');
|
|
10
10
|
var node_child_process = require('node:child_process');
|
|
11
11
|
var util = require('node:util');
|
|
12
12
|
var vueDocgenApi = require('vue-docgen-api');
|
package/dist/markdown.js
CHANGED