@forsakringskassan/docs-generator 2.9.2 → 2.10.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
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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-WhFYGWAf.js');
|
|
7
7
|
var path = require('node:path/posix');
|
|
8
8
|
require('@vue/compiler-sfc');
|
|
9
9
|
require('./vendor-DM7XM4qm.js');
|
package/dist/index.js
CHANGED
|
@@ -13,10 +13,11 @@ var vueDocgenApi = require('vue-docgen-api');
|
|
|
13
13
|
var fs$1 = require('node:fs');
|
|
14
14
|
var sass = require('sass');
|
|
15
15
|
var node_url = require('node:url');
|
|
16
|
+
var Module = require('node:module');
|
|
16
17
|
var esbuild$1 = require('esbuild');
|
|
17
18
|
var nunjucks = require('nunjucks');
|
|
18
19
|
var vue = require('vue');
|
|
19
|
-
var vue3 = require('./vue3-
|
|
20
|
+
var vue3 = require('./vue3-WhFYGWAf.js');
|
|
20
21
|
var express = require('express');
|
|
21
22
|
require('fs');
|
|
22
23
|
require('node:events');
|
|
@@ -973,50 +974,63 @@ async function navigationFileReader(filePath, basePath) {
|
|
|
973
974
|
return [doc];
|
|
974
975
|
}
|
|
975
976
|
|
|
977
|
+
function resolveFrom(fromDirectory, moduleId) {
|
|
978
|
+
const fromFile = path.join(fs$1.realpathSync(fromDirectory), "noop.js");
|
|
979
|
+
return Module._resolveFilename(moduleId, {
|
|
980
|
+
id: fromFile,
|
|
981
|
+
filename: fromFile,
|
|
982
|
+
paths: Module._nodeModulePaths(fromDirectory)
|
|
983
|
+
});
|
|
984
|
+
}
|
|
976
985
|
const WEBPACK_NODE_MODULE_PREFIX = "~";
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
findUrl = url
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
986
|
+
function moduleImporter(options) {
|
|
987
|
+
const { cwd } = options;
|
|
988
|
+
return {
|
|
989
|
+
findFileUrl(url) {
|
|
990
|
+
let findUrl = url;
|
|
991
|
+
if (url.startsWith(WEBPACK_NODE_MODULE_PREFIX)) {
|
|
992
|
+
findUrl = url.substring(1);
|
|
993
|
+
}
|
|
994
|
+
const directory = path.dirname(findUrl);
|
|
995
|
+
const fileName = path.basename(findUrl);
|
|
996
|
+
const search = [
|
|
997
|
+
`${fileName}.css`,
|
|
998
|
+
`${fileName}.scss`,
|
|
999
|
+
`_${fileName}.scss`,
|
|
1000
|
+
`${fileName}`
|
|
1001
|
+
];
|
|
1002
|
+
for (const variant of search) {
|
|
1003
|
+
try {
|
|
1004
|
+
const moduleName = path.posix.join(directory, variant);
|
|
1005
|
+
const resolved = resolveFrom(cwd, moduleName);
|
|
1006
|
+
return new URL(node_url.pathToFileURL(resolved));
|
|
1007
|
+
} catch (err) {
|
|
1008
|
+
if (err.code !== "MODULE_NOT_FOUND") {
|
|
1009
|
+
throw err;
|
|
1010
|
+
}
|
|
999
1011
|
}
|
|
1000
1012
|
}
|
|
1013
|
+
return null;
|
|
1001
1014
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
};
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1005
1017
|
|
|
1006
|
-
async function compileSassString(dst, style) {
|
|
1018
|
+
async function compileSassString(dst, style, options = {}) {
|
|
1019
|
+
const { cwd = process.cwd() } = options;
|
|
1007
1020
|
const result = await sass.compileStringAsync(style, {
|
|
1008
1021
|
style: "expanded",
|
|
1009
|
-
importers: [new sass.NodePackageImporter(), moduleImporter]
|
|
1022
|
+
importers: [new sass.NodePackageImporter(), moduleImporter({ cwd })]
|
|
1010
1023
|
});
|
|
1011
1024
|
await fs.mkdir(path.dirname(dst), { recursive: true });
|
|
1012
1025
|
await fs.writeFile(dst, result.css, "utf-8");
|
|
1013
1026
|
}
|
|
1014
1027
|
|
|
1015
|
-
async function compileStyle(assetFolder, name, src) {
|
|
1028
|
+
async function compileStyle(assetFolder, name, src, options) {
|
|
1029
|
+
const { cwd } = options;
|
|
1016
1030
|
try {
|
|
1017
1031
|
const outfile = path$1.join("temp", `asset-${name}.css`);
|
|
1018
1032
|
const source = await fs.readFile(src, "utf-8");
|
|
1019
|
-
await compileSassString(outfile, source);
|
|
1033
|
+
await compileSassString(outfile, source, { cwd });
|
|
1020
1034
|
const content = await fs.readFile(outfile, "utf-8");
|
|
1021
1035
|
const fingerprint = createMarkdownRenderer.getFingerprint(content);
|
|
1022
1036
|
const integrity = getIntegrity(content);
|
|
@@ -1044,7 +1058,8 @@ function byPriority$1({ options: a }, { options: b }) {
|
|
|
1044
1058
|
function toSorted$1(values, comparator) {
|
|
1045
1059
|
return [...values].sort(comparator);
|
|
1046
1060
|
}
|
|
1047
|
-
function cssAssetProcessor(assetFolder, assets) {
|
|
1061
|
+
function cssAssetProcessor(assetFolder, assets, options) {
|
|
1062
|
+
const { cwd } = options;
|
|
1048
1063
|
return {
|
|
1049
1064
|
name: "css-asset-processor",
|
|
1050
1065
|
after: "assets",
|
|
@@ -1056,7 +1071,8 @@ function cssAssetProcessor(assetFolder, assets) {
|
|
|
1056
1071
|
const info = await compileStyle(
|
|
1057
1072
|
assetFolder,
|
|
1058
1073
|
asset.name,
|
|
1059
|
-
asset.src
|
|
1074
|
+
asset.src,
|
|
1075
|
+
{ cwd }
|
|
1060
1076
|
);
|
|
1061
1077
|
const attrs = serializeAttrs(asset.options.attributes);
|
|
1062
1078
|
const inject = { ...info, attrs: Array.from(attrs).join(" ") };
|
|
@@ -1648,7 +1664,7 @@ const cache$1 = /* @__PURE__ */ new Map();
|
|
|
1648
1664
|
function cacheKey(layout, extension) {
|
|
1649
1665
|
return [layout, extension].join("|");
|
|
1650
1666
|
}
|
|
1651
|
-
function findTemplate(from, src, format) {
|
|
1667
|
+
function findTemplate(folders, from, src, format) {
|
|
1652
1668
|
let layout;
|
|
1653
1669
|
if (typeof src === "string") {
|
|
1654
1670
|
layout = src;
|
|
@@ -1662,12 +1678,14 @@ function findTemplate(from, src, format) {
|
|
|
1662
1678
|
if (cached) {
|
|
1663
1679
|
return cached;
|
|
1664
1680
|
}
|
|
1681
|
+
folders = [...folders, templateDirectory];
|
|
1665
1682
|
const template = `${layout}.template.${format}`;
|
|
1666
|
-
const
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1683
|
+
const searchPaths = folders.map((it) => {
|
|
1684
|
+
return path.join(it, template);
|
|
1685
|
+
});
|
|
1686
|
+
const found = searchPaths.find((it) => fs$1.existsSync(it));
|
|
1687
|
+
if (!found) {
|
|
1688
|
+
throw new MissingTemplateError(from, template, format, folders);
|
|
1671
1689
|
}
|
|
1672
1690
|
cache$1.set(key, template);
|
|
1673
1691
|
return template;
|
|
@@ -1742,7 +1760,7 @@ async function compileExamples(options) {
|
|
|
1742
1760
|
}
|
|
1743
1761
|
}
|
|
1744
1762
|
async function compileStandalones(options) {
|
|
1745
|
-
const { fileInfo, tasks, renderTemplate, templateData } = options;
|
|
1763
|
+
const { fileInfo, tasks, renderTemplate, templateData, templateFolders } = options;
|
|
1746
1764
|
if (tasks.length === 0) {
|
|
1747
1765
|
return;
|
|
1748
1766
|
}
|
|
@@ -1750,7 +1768,11 @@ async function compileStandalones(options) {
|
|
|
1750
1768
|
const outputFolder = path.posix.join(options.outputFolder, fileInfo.path);
|
|
1751
1769
|
const cacheMiss = cache(cacheFolder, outputFolder);
|
|
1752
1770
|
const dirtyTasks = tasks.filter(cacheMiss);
|
|
1753
|
-
const standaloneTemplate = findTemplate(
|
|
1771
|
+
const standaloneTemplate = findTemplate(
|
|
1772
|
+
templateFolders,
|
|
1773
|
+
fileInfo,
|
|
1774
|
+
"example"
|
|
1775
|
+
);
|
|
1754
1776
|
for (const task of dirtyTasks) {
|
|
1755
1777
|
const outputFile = path.join(outputFolder, task.outputFile);
|
|
1756
1778
|
const content = await renderTemplate(standaloneTemplate, {
|
|
@@ -1766,7 +1788,7 @@ function createTemplateLoader(folders) {
|
|
|
1766
1788
|
}
|
|
1767
1789
|
async function render(doc, docs, nav, vendors, options) {
|
|
1768
1790
|
const { fileInfo } = doc;
|
|
1769
|
-
const { outputFolder, cacheFolder } = options;
|
|
1791
|
+
const { outputFolder, cacheFolder, templateFolders } = options;
|
|
1770
1792
|
if (!haveOutputFile(fileInfo)) {
|
|
1771
1793
|
return null;
|
|
1772
1794
|
}
|
|
@@ -1780,7 +1802,7 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
1780
1802
|
const njk = new nunjucks.Environment(loader, { autoescape: false });
|
|
1781
1803
|
const asyncRender = util.promisify(njk.render);
|
|
1782
1804
|
const renderTemplate = asyncRender.bind(njk);
|
|
1783
|
-
const template = findTemplate(doc.fileInfo, doc);
|
|
1805
|
+
const template = findTemplate(templateFolders, doc.fileInfo, doc);
|
|
1784
1806
|
const templateData = {
|
|
1785
1807
|
...options.templateData,
|
|
1786
1808
|
site: options.site,
|
|
@@ -1901,6 +1923,7 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
1901
1923
|
fileInfo,
|
|
1902
1924
|
cacheFolder,
|
|
1903
1925
|
outputFolder,
|
|
1926
|
+
templateFolders,
|
|
1904
1927
|
tasks: generatedStandalone,
|
|
1905
1928
|
renderTemplate,
|
|
1906
1929
|
templateData
|
|
@@ -2241,7 +2264,6 @@ async function stage(stage2, context, processors, { verbose } = { verbose: true
|
|
|
2241
2264
|
}
|
|
2242
2265
|
} catch (err) {
|
|
2243
2266
|
console.error(`When running processor "${processor.name}":`);
|
|
2244
|
-
console.error(err);
|
|
2245
2267
|
throw err;
|
|
2246
2268
|
}
|
|
2247
2269
|
}
|
|
@@ -2425,6 +2447,7 @@ class Generator {
|
|
|
2425
2447
|
return { pages };
|
|
2426
2448
|
}
|
|
2427
2449
|
async build(sourceFiles) {
|
|
2450
|
+
const cwd = process.cwd();
|
|
2428
2451
|
this.sourceFiles = sourceFiles;
|
|
2429
2452
|
const {
|
|
2430
2453
|
site,
|
|
@@ -2439,7 +2462,7 @@ class Generator {
|
|
|
2439
2462
|
const processors = [
|
|
2440
2463
|
fileReaderProcessor(sourceFiles),
|
|
2441
2464
|
vendorProcessor(assetFolder, this.vendor),
|
|
2442
|
-
cssAssetProcessor(assetFolder, this.styles),
|
|
2465
|
+
cssAssetProcessor(assetFolder, this.styles, { cwd }),
|
|
2443
2466
|
jsAssetProcessor(assetFolder, this.scripts),
|
|
2444
2467
|
staticResourcesProcessor(assetFolder, this.resources),
|
|
2445
2468
|
navigationProcessor(),
|
package/dist/style/core.css
CHANGED
|
@@ -179,7 +179,7 @@ pre code {
|
|
|
179
179
|
.docs-topnav__item {
|
|
180
180
|
display: inline-flex;
|
|
181
181
|
list-style-type: none;
|
|
182
|
-
padding: 1.1rem 0 0
|
|
182
|
+
padding: 1.1rem 0 0;
|
|
183
183
|
white-space: nowrap;
|
|
184
184
|
}
|
|
185
185
|
.docs-topnav__item.highlight {
|
|
@@ -832,10 +832,7 @@ h1 code {
|
|
|
832
832
|
/* Page header - inverted */
|
|
833
833
|
header .page-header {
|
|
834
834
|
background-color: #fff;
|
|
835
|
-
padding
|
|
836
|
-
padding-bottom: 0.5rem;
|
|
837
|
-
padding-left: 1.2rem;
|
|
838
|
-
padding-right: 1.2rem;
|
|
835
|
+
padding: 0.5rem 1.2rem;
|
|
839
836
|
border-bottom: 1px solid #ddddde;
|
|
840
837
|
flex-wrap: wrap;
|
|
841
838
|
}
|
package/dist/style/index.css
CHANGED
|
@@ -179,7 +179,7 @@ pre code {
|
|
|
179
179
|
.docs-topnav__item {
|
|
180
180
|
display: inline-flex;
|
|
181
181
|
list-style-type: none;
|
|
182
|
-
padding: 1.1rem 0 0
|
|
182
|
+
padding: 1.1rem 0 0;
|
|
183
183
|
white-space: nowrap;
|
|
184
184
|
}
|
|
185
185
|
.docs-topnav__item.highlight {
|
|
@@ -832,10 +832,7 @@ h1 code {
|
|
|
832
832
|
/* Page header - inverted */
|
|
833
833
|
header .page-header {
|
|
834
834
|
background-color: #fff;
|
|
835
|
-
padding
|
|
836
|
-
padding-bottom: 0.5rem;
|
|
837
|
-
padding-left: 1.2rem;
|
|
838
|
-
padding-right: 1.2rem;
|
|
835
|
+
padding: 0.5rem 1.2rem;
|
|
839
836
|
border-bottom: 1px solid #ddddde;
|
|
840
837
|
flex-wrap: wrap;
|
|
841
838
|
}
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -12754,51 +12754,82 @@ function generateCode(options) {
|
|
|
12754
12754
|
const selector = `#${slug}`;
|
|
12755
12755
|
const asset = `${slug}-${fingerprint}.js`;
|
|
12756
12756
|
const { descriptor, errors } = require$$0.parse(code, { filename });
|
|
12757
|
+
const scopeId = `data-v-${fingerprint}`;
|
|
12757
12758
|
if (errors.length) {
|
|
12758
12759
|
throw new Error(`Errors occured when trying to parse ${filename}.`);
|
|
12759
12760
|
}
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
12766
|
-
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
);
|
|
12770
|
-
|
|
12771
|
-
|
|
12761
|
+
const hasScoped = descriptor.styles.some((e) => e.scoped);
|
|
12762
|
+
const styleContent = descriptor.styles.map((stylePart) => {
|
|
12763
|
+
const compiledStyle = require$$0.compileStyle({
|
|
12764
|
+
filename: descriptor.filename,
|
|
12765
|
+
source: stylePart.content,
|
|
12766
|
+
isProd: false,
|
|
12767
|
+
id: scopeId,
|
|
12768
|
+
scoped: stylePart.scoped,
|
|
12769
|
+
trim: true
|
|
12770
|
+
});
|
|
12771
|
+
return compiledStyle.code;
|
|
12772
|
+
}).join("\n");
|
|
12772
12773
|
let sourcecode = `import { setup } from "${setupPath}";
|
|
12773
12774
|
`;
|
|
12774
|
-
|
|
12775
|
-
|
|
12776
|
-
|
|
12777
|
-
|
|
12778
|
-
|
|
12775
|
+
let bindings = void 0;
|
|
12776
|
+
if (descriptor.script || descriptor.scriptSetup) {
|
|
12777
|
+
const script = require$$0.compileScript(descriptor, {
|
|
12778
|
+
id: scopeId,
|
|
12779
|
+
isProd: false,
|
|
12780
|
+
sourceMap: false,
|
|
12781
|
+
inlineTemplate: false,
|
|
12782
|
+
genDefaultAs: "exampleComponent",
|
|
12783
|
+
templateOptions: {
|
|
12784
|
+
id: scopeId,
|
|
12785
|
+
filename,
|
|
12786
|
+
source: descriptor.template?.content,
|
|
12787
|
+
scoped: hasScoped,
|
|
12788
|
+
slotted: descriptor.slotted,
|
|
12789
|
+
compilerOptions: {
|
|
12790
|
+
comments: false,
|
|
12791
|
+
whitespace: "condense",
|
|
12792
|
+
scopeId: hasScoped ? scopeId : void 0,
|
|
12793
|
+
mode: "module"
|
|
12794
|
+
}
|
|
12795
|
+
}
|
|
12796
|
+
});
|
|
12797
|
+
bindings = script.bindings;
|
|
12798
|
+
sourcecode += script.content;
|
|
12799
|
+
sourcecode += "\n\n";
|
|
12779
12800
|
} else {
|
|
12780
12801
|
sourcecode += `const exampleComponent = {};
|
|
12802
|
+
|
|
12781
12803
|
`;
|
|
12782
12804
|
}
|
|
12783
12805
|
if (descriptor.template) {
|
|
12784
|
-
const
|
|
12785
|
-
id:
|
|
12806
|
+
const template = require$$0.compileTemplate({
|
|
12807
|
+
id: scopeId,
|
|
12786
12808
|
filename,
|
|
12787
12809
|
source: descriptor.template.content,
|
|
12810
|
+
scoped: hasScoped,
|
|
12811
|
+
slotted: descriptor.slotted,
|
|
12788
12812
|
preprocessLang: descriptor.template.lang,
|
|
12789
12813
|
compilerOptions: {
|
|
12814
|
+
bindingMetadata: bindings,
|
|
12790
12815
|
comments: false,
|
|
12791
|
-
whitespace: "
|
|
12816
|
+
whitespace: "condense",
|
|
12817
|
+
scopeId: hasScoped ? scopeId : void 0,
|
|
12818
|
+
mode: "module"
|
|
12792
12819
|
}
|
|
12793
12820
|
});
|
|
12794
|
-
sourcecode += `${
|
|
12821
|
+
sourcecode += `${template.code}
|
|
12795
12822
|
|
|
12796
12823
|
`;
|
|
12797
12824
|
sourcecode += `exampleComponent.render = render;
|
|
12798
|
-
|
|
12799
12825
|
`;
|
|
12800
12826
|
}
|
|
12801
|
-
|
|
12827
|
+
if (hasScoped) {
|
|
12828
|
+
sourcecode += `exampleComponent.__scopeId = "${scopeId}";
|
|
12829
|
+
`;
|
|
12830
|
+
}
|
|
12831
|
+
sourcecode += `
|
|
12832
|
+
setup({
|
|
12802
12833
|
rootComponent: exampleComponent,
|
|
12803
12834
|
selector: "${selector}"
|
|
12804
12835
|
});
|