@forsakringskassan/docs-generator 3.13.0 → 3.14.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/index.mjs CHANGED
@@ -8,17 +8,19 @@ 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, a as getFingerprint, h as hasTag, b as parseImport, d as findTag, e as getOutputFilePath, i as isDocumentPage, j as findDocument, k as getDocumentBody, n as normalizePath, l as htmlencode, m as filePath, c as createMarkdownRenderer, o as generateExample } from './create-markdown-renderer-DwLB6VT1.mjs';
11
+ import { g as generateId, f as formatCode, p as parseImport, a as getFingerprint, b as parseInfostring, h as hasTag, d as findTag, e as getOutputFilePath, i as isDocumentPage, j as findDocument, k as getDocumentBody, n as normalizePath, l as htmlencode, c as createMarkdownRenderer } from './create-markdown-renderer-BlUpDhJP.mjs';
12
12
  import { DocExcerpt } from '@microsoft/tsdoc';
13
13
  import fs from 'node:fs/promises';
14
+ import fs__default, { existsSync, readFileSync, copyFileSync } from 'node:fs';
15
+ import { version } from 'vue';
16
+ import { g as generateCode } from './vue3-DbJPWpmQ.mjs';
17
+ import { fileURLToPath } from 'node:url';
14
18
  import util, { promisify, styleText } from 'node:util';
15
19
  import { codeFrameColumns } from '@babel/code-frame';
16
20
  import { parse as parse$1 } from '@babel/parser';
17
21
  import traverseModule from '@babel/traverse';
18
22
  import { parse, compileScript as compileScript$1, compileTemplate } from 'vue/compiler-sfc';
19
23
  import { parse as parse$2 } from 'vue-docgen-api';
20
- import fs__default, { existsSync, readFileSync, copyFileSync } from 'node:fs';
21
- import { fileURLToPath } from 'node:url';
22
24
  import { compileAsync, NodePackageImporter } from 'sass';
23
25
  import { t as tsconfigPath } from './tsconfig-path-bG7G_cK8.mjs';
24
26
  import esbuild$1, { build } from 'esbuild';
@@ -50,8 +52,6 @@ import 'module';
50
52
  import 'fs/promises';
51
53
  import 'process';
52
54
  import 'v8';
53
- import 'vue';
54
- import './vue3-DbJPWpmQ.mjs';
55
55
 
56
56
  function toArray$2(value) {
57
57
  return Array.isArray(value) ? value : [value];
@@ -230,6 +230,16 @@ function haveOutput(doc) {
230
230
  return Boolean(fileInfo.outputName);
231
231
  }
232
232
 
233
+ function hasPrettyError(value) {
234
+ if (!value) {
235
+ return false;
236
+ }
237
+ if (typeof value !== "object") {
238
+ return false;
239
+ }
240
+ return "prettyError" in value && typeof value.prettyError === "function";
241
+ }
242
+
233
243
  function interpolate(value, data) {
234
244
  return value.replaceAll(/\{\{([^{}]+)\}\}/g, (match, raw) => {
235
245
  const key = raw.trim();
@@ -630,6 +640,108 @@ function isDocumentPartial(doc) {
630
640
  return doc.kind === "partial";
631
641
  }
632
642
 
643
+ function getExampleName(filename) {
644
+ return path__default.parse(filename).name;
645
+ }
646
+
647
+ const vueMajor = Number(version.split(".", 2)[0]);
648
+ function vueGenerator() {
649
+ switch (vueMajor) {
650
+ case 2:
651
+ throw new Error(
652
+ "Vue 2 is no longer supported, upgrade to Vue 3 or downgrade docs-generator"
653
+ );
654
+ case 3:
655
+ return generateCode;
656
+ }
657
+ }
658
+ function generateExample(options) {
659
+ const { language, fileMatcher } = options;
660
+ if (language === "import") {
661
+ const parsed = parseImport(options.source);
662
+ const filename = fileMatcher(parsed.filename, "when importing example");
663
+ const language2 = parsed.extension;
664
+ const comments = parsed.comments;
665
+ const content = fs__default.readFileSync(filename, "utf8");
666
+ const example = generateExample({
667
+ ...options,
668
+ source: content,
669
+ language: language2,
670
+ filename
671
+ });
672
+ return { ...example, comments };
673
+ }
674
+ switch (language) {
675
+ case "vue":
676
+ return generateVueExample(options);
677
+ case "html":
678
+ return generateStaticExample(options);
679
+ default:
680
+ return generateStaticExample(options);
681
+ }
682
+ }
683
+ function generateVueExample(options) {
684
+ const { filename, source, parent, setupPath, tags } = options;
685
+ const fn = vueGenerator();
686
+ const slug = getExampleName(filename);
687
+ const fingerprint = getFingerprint(source);
688
+ const { markup, sourcecode, output } = fn({
689
+ filename,
690
+ slug,
691
+ fingerprint,
692
+ code: source,
693
+ setupPath
694
+ });
695
+ if (output) {
696
+ return {
697
+ source,
698
+ language: options.language,
699
+ comments: [],
700
+ tags,
701
+ markup,
702
+ output,
703
+ runtime: true,
704
+ task: {
705
+ outputFile: output,
706
+ sourcecode,
707
+ sourceFile: filename,
708
+ parent
709
+ }
710
+ };
711
+ }
712
+ return {
713
+ source: sourcecode,
714
+ language: "plaintext",
715
+ comments: [],
716
+ tags,
717
+ markup,
718
+ output: null,
719
+ runtime: true,
720
+ task: null
721
+ };
722
+ }
723
+ function generateStaticExample(options) {
724
+ const { filename, source, language, tags } = options;
725
+ const slug = getExampleName(filename);
726
+ const fingerprint = getFingerprint(source);
727
+ const asset = `${slug}-${fingerprint}.${language}`;
728
+ const runtimeLanguages = ["html"];
729
+ const runtime = runtimeLanguages.includes(language);
730
+ return {
731
+ source,
732
+ language: options.language,
733
+ comments: [],
734
+ tags,
735
+ markup: source,
736
+ output: runtime ? asset : null,
737
+ runtime,
738
+ task: null
739
+ };
740
+ }
741
+
742
+ const url = new URL("./worker--TrTGmqL.mjs", import.meta.url);
743
+ const filePath = fileURLToPath(url);
744
+
633
745
  const md$6 = MarkdownItCallable();
634
746
  md$6.renderer.rules.fence = (tokens, idx, _options, env) => {
635
747
  const { collected, exampleFileMatcher } = env;
@@ -4386,5 +4498,5 @@ class Generator {
4386
4498
  }
4387
4499
  }
4388
4500
 
4389
- export { Generator, apiExtractorProcessor, availableProcessors, cookieProcessor, defineSources, extractExamplesProcessor, extractMarkdownProcessor, frontMatterFileReader, htmlRedirectProcessor, isRelease, livereloadProcessor, manifestProcessor, matomoProcessor, motdProcessor, navigationFileReader, partialFileReader, playgroundProcessor, processorRuntimeName, redirectFileProcessor, searchProcessor, selectableVersionProcessor, sourceUrlProcessor, topnavProcessor, versionBannerProcessor, versionProcessor, vueFileReader };
4501
+ export { Generator, apiExtractorProcessor, availableProcessors, cookieProcessor, defineSources, extractExamplesProcessor, extractMarkdownProcessor, frontMatterFileReader, hasPrettyError, htmlRedirectProcessor, isRelease, livereloadProcessor, manifestProcessor, matomoProcessor, motdProcessor, navigationFileReader, partialFileReader, playgroundProcessor, processorRuntimeName, redirectFileProcessor, searchProcessor, selectableVersionProcessor, sourceUrlProcessor, topnavProcessor, versionBannerProcessor, versionProcessor, vueFileReader };
4390
4502
  //# sourceMappingURL=index.mjs.map