@forsakringskassan/docs-generator 1.30.10 → 1.31.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.
@@ -124,7 +124,7 @@ function getLinkTitle(doc, key, explicitTitle) {
124
124
  return explicitTitle;
125
125
  }
126
126
  const { title, component } = doc.attributes;
127
- if (component && component.includes(key)) {
127
+ if (component && component.some((it) => it.name === key)) {
128
128
  return `<code>${key}</code>`;
129
129
  } else {
130
130
  return title ?? doc.name;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Component } from 'vue';
1
+ import { Component as Component_2 } from 'vue';
2
2
 
3
3
  /** @public */
4
4
  export declare type AttributeTable = Record<string, AttributeValue>;
@@ -26,6 +26,13 @@ export declare interface CompileOptions {
26
26
  attributes: AttributeTable;
27
27
  }
28
28
 
29
+ declare interface Component {
30
+ /** component name */
31
+ name: string;
32
+ /** optional hint (glob pattern) how to find the component */
33
+ source?: string;
34
+ }
35
+
29
36
  /**
30
37
  * Tiny wrapper to provide type completion for IDE.
31
38
  *
@@ -323,7 +330,7 @@ export declare interface NormalizedDocumentAttributes {
323
330
  layout?: string;
324
331
  status?: string;
325
332
  badge?: DocumentBadge;
326
- component?: string[];
333
+ component?: Component[];
327
334
  href?: string;
328
335
  /** normalized sortorder (defaults to Infinity) */
329
336
  sortorder: number;
@@ -432,7 +439,7 @@ export declare function searchProcessor(): Processor;
432
439
  export declare function selectableVersionProcessor(pkg: {
433
440
  name: string;
434
441
  version: string;
435
- }, container: string): Processor;
442
+ }, container: string, options?: ProcessorOptions): Processor;
436
443
 
437
444
  /**
438
445
  * Options passed from the example compiler to the `setup` function.
@@ -441,7 +448,7 @@ export declare function selectableVersionProcessor(pkg: {
441
448
  */
442
449
  export declare interface SetupOptions {
443
450
  /** The example component expected to be mounted by the application */
444
- rootComponent: Component;
451
+ rootComponent: Component_2;
445
452
  /** Where the example should be mounted */
446
453
  selector: string;
447
454
  }
@@ -462,6 +469,25 @@ export declare interface SourceFiles {
462
469
  transform?(doc: Document_2): Document_2;
463
470
  }
464
471
 
472
+ /**
473
+ * Processor that provide `componentSourceUrl` template function used for resolving
474
+ * component source urls.
475
+ *
476
+ * @public
477
+ */
478
+ export declare function sourceUrlProcessor(options: SourceUrlProcessorOptions): Processor;
479
+
480
+ /**
481
+ * Options for {@link sourceUrlProcessor}.
482
+ *
483
+ * @public
484
+ */
485
+ export declare interface SourceUrlProcessorOptions extends ProcessorOptions {
486
+ readonly urlFormat: string;
487
+ /** File extension used for finding component by name */
488
+ readonly componentFileExtension?: string;
489
+ }
490
+
465
491
  /* Excluded from this release type: TemplateBlockData */
466
492
 
467
493
  /**
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  var fs = require('node:fs/promises');
4
4
  var path = require('node:path');
5
5
  var vendor = require('./vendor-DD1glhBC.js');
6
- var createMarkdownRenderer = require('./create-markdown-renderer-BarACCRE.js');
6
+ var createMarkdownRenderer = require('./create-markdown-renderer-CjwHt5p0.js');
7
7
  var require$$1 = require('crypto');
8
8
  require('node:crypto');
9
9
  var vueDocgenApi = require('vue-docgen-api');
@@ -211,6 +211,20 @@ function getComponentAlias(attrs) {
211
211
  return [];
212
212
  }
213
213
  }
214
+ function getComponent(attrs) {
215
+ if (!attrs.component) {
216
+ return void 0;
217
+ }
218
+ return toArray$3(attrs.component).map((it) => {
219
+ if (typeof it === "string") {
220
+ return {
221
+ name: it
222
+ };
223
+ } else {
224
+ return it;
225
+ }
226
+ });
227
+ }
214
228
  function parseFile$1(filePath, basePath, content) {
215
229
  const relative = basePath ? path.relative(basePath, createMarkdownRenderer.normalizePath(filePath)) : createMarkdownRenderer.normalizePath(filePath);
216
230
  const parsed = path.parse(relative);
@@ -232,7 +246,7 @@ function parseFile$1(filePath, basePath, content) {
232
246
  layout: attributes.layout,
233
247
  status: attributes.status,
234
248
  badge: getBadge(attributes),
235
- component: attributes.component ? toArray$3(attributes.component) : void 0,
249
+ component: getComponent(attributes),
236
250
  sortorder: attributes.sortorder ?? Infinity
237
251
  },
238
252
  body: blocks.body,
@@ -1670,6 +1684,7 @@ async function serve(options) {
1670
1684
  const key = await keypress();
1671
1685
  switch (key) {
1672
1686
  case "":
1687
+ /* ctrl-c */
1673
1688
  case "q":
1674
1689
  console.log("Shutting down gracefully");
1675
1690
  server.close();
@@ -2085,11 +2100,15 @@ function themeSelectProcessor() {
2085
2100
  };
2086
2101
  }
2087
2102
 
2088
- function selectableVersionProcessor(pkg, container) {
2103
+ function selectableVersionProcessor(pkg, container, options) {
2104
+ const { enabled = true } = options ?? {};
2089
2105
  return {
2090
2106
  name: "selectable-version-processor",
2091
2107
  after: "generate-docs",
2092
2108
  handler(context) {
2109
+ if (!enabled) {
2110
+ return;
2111
+ }
2093
2112
  context.addTemplateBlock(container, "version", {
2094
2113
  filename: "partials/selectable-version.html",
2095
2114
  data: { pkg }
@@ -2219,6 +2238,29 @@ function versionProcessor(pkg, container, options) {
2219
2238
  };
2220
2239
  }
2221
2240
 
2241
+ function sourceUrlProcessor(options) {
2242
+ const {
2243
+ enabled = true,
2244
+ urlFormat,
2245
+ componentFileExtension = "vue"
2246
+ } = options;
2247
+ function componentSourceUrl(component) {
2248
+ const filename = component.source ?? `${component.name}.${componentFileExtension}`;
2249
+ const path = getExampleImport(["./"], filename);
2250
+ return interpolate(urlFormat, { path });
2251
+ }
2252
+ return {
2253
+ after: "generate-docs",
2254
+ name: "source-url-processor",
2255
+ async handler(context) {
2256
+ if (!enabled) {
2257
+ return;
2258
+ }
2259
+ context.setTemplateData("componentSourceUrl", componentSourceUrl);
2260
+ }
2261
+ };
2262
+ }
2263
+
2222
2264
  function generateIndex(entries) {
2223
2265
  const index = {
2224
2266
  terms: [],
@@ -2243,9 +2285,9 @@ function generateIndex(entries) {
2243
2285
  function extractTerms(doc) {
2244
2286
  const { title, component } = doc.attributes;
2245
2287
  if (title && component) {
2246
- return component.map((it) => `${title} (${it})`);
2288
+ return component.map((it) => `${title} (${it.name})`);
2247
2289
  } else if (component) {
2248
- return component;
2290
+ return component.map((it) => it.name);
2249
2291
  } else if (title) {
2250
2292
  return [title];
2251
2293
  } else {
@@ -2317,6 +2359,7 @@ exports.motdProcessor = motdProcessor;
2317
2359
  exports.navigationFileReader = navigationFileReader;
2318
2360
  exports.searchProcessor = searchProcessor;
2319
2361
  exports.selectableVersionProcessor = selectableVersionProcessor;
2362
+ exports.sourceUrlProcessor = sourceUrlProcessor;
2320
2363
  exports.themeSelectProcessor = themeSelectProcessor;
2321
2364
  exports.topnavProcessor = topnavProcessor;
2322
2365
  exports.versionBannerProcessor = versionBannerProcessor;
@@ -1,3 +1,10 @@
1
+ declare interface Component {
2
+ /** component name */
3
+ name: string;
4
+ /** optional hint (glob pattern) how to find the component */
5
+ source?: string;
6
+ }
7
+
1
8
  /**
2
9
  * @public
3
10
  */
@@ -200,7 +207,7 @@ export declare interface NormalizedDocumentAttributes {
200
207
  layout?: string;
201
208
  status?: string;
202
209
  badge?: DocumentBadge;
203
- component?: string[];
210
+ component?: Component[];
204
211
  href?: string;
205
212
  /** normalized sortorder (defaults to Infinity) */
206
213
  sortorder: number;
package/dist/markdown.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var createMarkdownRenderer = require('./create-markdown-renderer-BarACCRE.js');
3
+ var createMarkdownRenderer = require('./create-markdown-renderer-CjwHt5p0.js');
4
4
  require('./vendor-DD1glhBC.js');
5
5
  require('node:url');
6
6
  require('node:path');
package/dist/runtime.js CHANGED
@@ -6138,6 +6138,7 @@ var init_linear2 = __esm({
6138
6138
  break;
6139
6139
  case 1:
6140
6140
  this._point = 2;
6141
+ // falls through
6141
6142
  default:
6142
6143
  this._context.lineTo(x3, y3);
6143
6144
  break;
@@ -6318,6 +6319,7 @@ var init_bump = __esm({
6318
6319
  }
6319
6320
  case 1:
6320
6321
  this._point = 2;
6322
+ // falls through
6321
6323
  default: {
6322
6324
  if (this._x) this._context.bezierCurveTo(this._x0 = (this._x0 + x3) / 2, this._y0, this._x0, y3, x3, y3);
6323
6325
  else this._context.bezierCurveTo(this._x0, this._y0 = (this._y0 + y3) / 2, x3, this._y0, x3, y3);
@@ -6372,6 +6374,7 @@ var init_basis2 = __esm({
6372
6374
  switch (this._point) {
6373
6375
  case 3:
6374
6376
  point2(this, this._x1, this._y1);
6377
+ // falls through
6375
6378
  case 2:
6376
6379
  this._context.lineTo(this._x1, this._y1);
6377
6380
  break;
@@ -6392,6 +6395,7 @@ var init_basis2 = __esm({
6392
6395
  case 2:
6393
6396
  this._point = 3;
6394
6397
  this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6);
6398
+ // falls through
6395
6399
  default:
6396
6400
  point2(this, x3, y3);
6397
6401
  break;
@@ -6510,6 +6514,7 @@ var init_basisOpen = __esm({
6510
6514
  break;
6511
6515
  case 3:
6512
6516
  this._point = 4;
6517
+ // falls through
6513
6518
  default:
6514
6519
  point2(this, x3, y3);
6515
6520
  break;
@@ -6622,6 +6627,7 @@ var init_cardinal = __esm({
6622
6627
  break;
6623
6628
  case 2:
6624
6629
  this._point = 3;
6630
+ // falls through
6625
6631
  default:
6626
6632
  point3(this, x3, y3);
6627
6633
  break;
@@ -6753,6 +6759,7 @@ var init_cardinalOpen = __esm({
6753
6759
  break;
6754
6760
  case 3:
6755
6761
  this._point = 4;
6762
+ // falls through
6756
6763
  default:
6757
6764
  point3(this, x3, y3);
6758
6765
  break;
@@ -6836,6 +6843,7 @@ var init_catmullRom = __esm({
6836
6843
  break;
6837
6844
  case 2:
6838
6845
  this._point = 3;
6846
+ // falls through
6839
6847
  default:
6840
6848
  point4(this, x3, y3);
6841
6849
  break;
@@ -6981,6 +6989,7 @@ var init_catmullRomOpen = __esm({
6981
6989
  break;
6982
6990
  case 3:
6983
6991
  this._point = 4;
6992
+ // falls through
6984
6993
  default:
6985
6994
  point4(this, x3, y3);
6986
6995
  break;
@@ -7230,6 +7239,7 @@ var init_step = __esm({
7230
7239
  break;
7231
7240
  case 1:
7232
7241
  this._point = 2;
7242
+ // falls through
7233
7243
  default: {
7234
7244
  if (this._t <= 0) {
7235
7245
  this._context.lineTo(this._x, y3);
@@ -11022,12 +11032,14 @@ function slice2(begin, end2) {
11022
11032
  }
11023
11033
  function token(type3) {
11024
11034
  switch (type3) {
11035
+ // \0 \t \n \r \s whitespace token
11025
11036
  case 0:
11026
11037
  case 9:
11027
11038
  case 10:
11028
11039
  case 13:
11029
11040
  case 32:
11030
11041
  return 5;
11042
+ // ! + , / > @ ~ isolate token
11031
11043
  case 33:
11032
11044
  case 43:
11033
11045
  case 44:
@@ -11035,17 +11047,21 @@ function token(type3) {
11035
11047
  case 62:
11036
11048
  case 64:
11037
11049
  case 126:
11050
+ // ; { } breakpoint token
11038
11051
  case 59:
11039
11052
  case 123:
11040
11053
  case 125:
11041
11054
  return 4;
11055
+ // : accompanied token
11042
11056
  case 58:
11043
11057
  return 3;
11058
+ // " ' ( [ opening delimit token
11044
11059
  case 34:
11045
11060
  case 39:
11046
11061
  case 40:
11047
11062
  case 91:
11048
11063
  return 2;
11064
+ // ) ] closing delimit token
11049
11065
  case 41:
11050
11066
  case 93:
11051
11067
  return 1;
@@ -11078,17 +11094,21 @@ function escaping(index3, count) {
11078
11094
  function delimiter(type3) {
11079
11095
  while (next2())
11080
11096
  switch (character) {
11097
+ // ] ) " '
11081
11098
  case type3:
11082
11099
  return position;
11100
+ // " '
11083
11101
  case 34:
11084
11102
  case 39:
11085
11103
  if (type3 !== 34 && type3 !== 39)
11086
11104
  delimiter(character);
11087
11105
  break;
11106
+ // (
11088
11107
  case 40:
11089
11108
  if (type3 === 41)
11090
11109
  delimiter(type3);
11091
11110
  break;
11111
+ // \
11092
11112
  case 92:
11093
11113
  next2();
11094
11114
  break;
@@ -11143,26 +11163,31 @@ function parse(value2, root3, parent, rule, rules, rulesets, pseudo, points, dec
11143
11163
  var characters2 = type3;
11144
11164
  while (scanning)
11145
11165
  switch (previous2 = character2, character2 = next2()) {
11166
+ // (
11146
11167
  case 40:
11147
11168
  if (previous2 != 108 && charat(characters2, length2 - 1) == 58) {
11148
11169
  if (indexof(characters2 += replace(delimit(character2), "&", "&\f"), "&\f") != -1)
11149
11170
  ampersand = -1;
11150
11171
  break;
11151
11172
  }
11173
+ // " ' [
11152
11174
  case 34:
11153
11175
  case 39:
11154
11176
  case 91:
11155
11177
  characters2 += delimit(character2);
11156
11178
  break;
11179
+ // \t \n \r \s
11157
11180
  case 9:
11158
11181
  case 10:
11159
11182
  case 13:
11160
11183
  case 32:
11161
11184
  characters2 += whitespace(previous2);
11162
11185
  break;
11186
+ // \
11163
11187
  case 92:
11164
11188
  characters2 += escaping(caret() - 1, 7);
11165
11189
  continue;
11190
+ // /
11166
11191
  case 47:
11167
11192
  switch (peek()) {
11168
11193
  case 42:
@@ -11173,22 +11198,28 @@ function parse(value2, root3, parent, rule, rules, rulesets, pseudo, points, dec
11173
11198
  characters2 += "/";
11174
11199
  }
11175
11200
  break;
11201
+ // {
11176
11202
  case 123 * variable:
11177
11203
  points[index3++] = strlen(characters2) * ampersand;
11204
+ // } ; \0
11178
11205
  case 125 * variable:
11179
11206
  case 59:
11180
11207
  case 0:
11181
11208
  switch (character2) {
11209
+ // \0 }
11182
11210
  case 0:
11183
11211
  case 125:
11184
11212
  scanning = 0;
11213
+ // ;
11185
11214
  case 59 + offset:
11186
11215
  if (ampersand == -1) characters2 = replace(characters2, /\f/g, "");
11187
11216
  if (property2 > 0 && strlen(characters2) - length2)
11188
11217
  append2(property2 > 32 ? declaration(characters2 + ";", rule, parent, length2 - 1, declarations) : declaration(replace(characters2, " ", "") + ";", rule, parent, length2 - 2, declarations), declarations);
11189
11218
  break;
11219
+ // @ ;
11190
11220
  case 59:
11191
11221
  characters2 += ";";
11222
+ // { rule/at-rule
11192
11223
  default:
11193
11224
  append2(reference = ruleset(characters2, root3, parent, index3, offset, rules, points, type3, props = [], children2 = [], length2, rulesets), rulesets);
11194
11225
  if (character2 === 123)
@@ -11196,6 +11227,7 @@ function parse(value2, root3, parent, rule, rules, rulesets, pseudo, points, dec
11196
11227
  parse(characters2, root3, reference, reference, props, rulesets, length2, points, children2);
11197
11228
  else
11198
11229
  switch (atrule === 99 && charat(characters2, 3) === 110 ? 100 : atrule) {
11230
+ // d l m s
11199
11231
  case 100:
11200
11232
  case 108:
11201
11233
  case 109:
@@ -11208,6 +11240,7 @@ function parse(value2, root3, parent, rule, rules, rulesets, pseudo, points, dec
11208
11240
  }
11209
11241
  index3 = offset = property2 = 0, variable = ampersand = 1, type3 = characters2 = "", length2 = pseudo;
11210
11242
  break;
11243
+ // :
11211
11244
  case 58:
11212
11245
  length2 = 1 + strlen(characters2), property2 = previous2;
11213
11246
  default:
@@ -11218,17 +11251,21 @@ function parse(value2, root3, parent, rule, rules, rulesets, pseudo, points, dec
11218
11251
  continue;
11219
11252
  }
11220
11253
  switch (characters2 += from(character2), character2 * variable) {
11254
+ // &
11221
11255
  case 38:
11222
11256
  ampersand = offset > 0 ? 1 : (characters2 += "\f", -1);
11223
11257
  break;
11258
+ // ,
11224
11259
  case 44:
11225
11260
  points[index3++] = (strlen(characters2) - 1) * ampersand, ampersand = 1;
11226
11261
  break;
11262
+ // @
11227
11263
  case 64:
11228
11264
  if (peek() === 45)
11229
11265
  characters2 += delimit(next2());
11230
11266
  atrule = peek(), offset = length2 = strlen(type3 = characters2 += identifier(caret())), character2++;
11231
11267
  break;
11268
+ // -
11232
11269
  case 45:
11233
11270
  if (previous2 === 45 && strlen(characters2) == 2)
11234
11271
  variable = 0;
@@ -22180,6 +22217,7 @@ var init_katex = __esm({
22180
22217
  case "mspace":
22181
22218
  case "mtext":
22182
22219
  break;
22220
+ // Do nothing yet.
22183
22221
  case "mo": {
22184
22222
  var child = node3.children[0];
22185
22223
  if (node3.children.length === 1 && child instanceof mathMLTree.TextNode) {
@@ -172765,6 +172803,7 @@ var require_cytoscape_cjs = __commonJS({
172765
172803
  warn("Do not assign mappings to elements without corresponding data (i.e. ele `" + ele.id() + "` has no mapping for property `" + prop.name + "` with data field `" + prop.field + "`); try a `[" + prop.field + "]` selector to limit scope to elements with `" + prop.field + "` defined");
172766
172804
  };
172767
172805
  switch (prop.mapped) {
172806
+ // flatten the property if mapped
172768
172807
  case types.mapData: {
172769
172808
  var fields = prop.field.split(".");
172770
172809
  var fieldVal = _p.data;
@@ -172825,6 +172864,7 @@ var require_cytoscape_cjs = __commonJS({
172825
172864
  prop = flatProp;
172826
172865
  break;
172827
172866
  }
172867
+ // direct mapping
172828
172868
  case types.data: {
172829
172869
  var _fields = prop.field.split(".");
172830
172870
  var _fieldVal = _p.data;
@@ -172862,6 +172902,7 @@ var require_cytoscape_cjs = __commonJS({
172862
172902
  }
172863
172903
  case void 0:
172864
172904
  break;
172905
+ // just set the property
172865
172906
  default:
172866
172907
  return false;
172867
172908
  }
@@ -202230,6 +202271,8 @@ var require_semver = __commonJS({
202230
202271
  this.inc("patch", identifier2, identifierBase);
202231
202272
  this.inc("pre", identifier2, identifierBase);
202232
202273
  break;
202274
+ // If the input is a non-prerelease version, this acts the same as
202275
+ // prepatch.
202233
202276
  case "prerelease":
202234
202277
  if (this.prerelease.length === 0) {
202235
202278
  this.inc("patch", identifier2, identifierBase);
@@ -202257,6 +202300,8 @@ var require_semver = __commonJS({
202257
202300
  }
202258
202301
  this.prerelease = [];
202259
202302
  break;
202303
+ // This probably shouldn't be used publicly.
202304
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
202260
202305
  case "pre": {
202261
202306
  const base = Number(identifierBase) ? 1 : 0;
202262
202307
  if (!identifier2 && identifierBase === false) {
@@ -203300,6 +203345,7 @@ var require_min_version = __commonJS({
203300
203345
  compver.prerelease.push(0);
203301
203346
  }
203302
203347
  compver.raw = compver.format();
203348
+ /* fallthrough */
203303
203349
  case "":
203304
203350
  case ">=":
203305
203351
  if (!setMin || gt(compver, setMin)) {
@@ -203309,6 +203355,7 @@ var require_min_version = __commonJS({
203309
203355
  case "<":
203310
203356
  case "<=":
203311
203357
  break;
203358
+ /* istanbul ignore next */
203312
203359
  default:
203313
203360
  throw new Error(`Unexpected operation: ${comparator.operator}`);
203314
203361
  }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.47.5"
8
+ "packageVersion": "7.47.6"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/docs-generator",
3
- "version": "1.30.10",
3
+ "version": "1.31.0",
4
4
  "description": "Documentation generator",
5
5
  "keywords": [
6
6
  "documentation"
@@ -8,7 +8,12 @@
8
8
  <dt>Komponent</dt>
9
9
  <dd>
10
10
  {% for component in doc.attributes.component %}
11
- <code>{{ component }}</code>{% if not loop.last %}, {% endif %} {% endfor %}
11
+ <code>
12
+ {% if componentSourceUrl and componentSourceUrl(component) %}
13
+ <a href="{{ componentSourceUrl(component) }}">{{ component.name }}</a>
14
+ {% else %} {{ component.name }} {% endif %}
15
+ </code>
16
+ {% if not loop.last %}, {% endif %} {% endfor %}
12
17
  </dd>
13
18
  {% endif %}
14
19