@forsakringskassan/docs-generator 1.24.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.
Files changed (36) hide show
  1. package/LICENSE.md +24 -0
  2. package/README.md +311 -0
  3. package/dist/compile-example.js +13406 -0
  4. package/dist/generator.d.ts +512 -0
  5. package/dist/generator.js +84168 -0
  6. package/dist/markdown.d.ts +243 -0
  7. package/dist/markdown.js +19369 -0
  8. package/dist/runtime.d.ts +1 -0
  9. package/dist/runtime.js +206572 -0
  10. package/dist/style/core.css +840 -0
  11. package/dist/style/index.css +927 -0
  12. package/dist/style/site.css +86 -0
  13. package/dist/tsdoc-metadata.json +11 -0
  14. package/package.json +68 -0
  15. package/templates/base.template.html +132 -0
  16. package/templates/component.template.html +28 -0
  17. package/templates/content-with-menu.template.html +15 -0
  18. package/templates/content-without-menu.template.html +10 -0
  19. package/templates/default.template.html +10 -0
  20. package/templates/example.template.html +70 -0
  21. package/templates/json.template.json +1 -0
  22. package/templates/macro/menu.html +39 -0
  23. package/templates/partials/footer.html +3 -0
  24. package/templates/partials/header.html +14 -0
  25. package/templates/partials/livereload.html +1 -0
  26. package/templates/partials/matomo.html +29 -0
  27. package/templates/partials/search-dialog.html +25 -0
  28. package/templates/partials/search-toolbar.html +9 -0
  29. package/templates/partials/selectable-version.html +28 -0
  30. package/templates/partials/spritesheet.html +44 -0
  31. package/templates/partials/theme-select.html +68 -0
  32. package/templates/partials/topnav.html +22 -0
  33. package/templates/partials/version-banner.html +14 -0
  34. package/templates/partials/version.html +3 -0
  35. package/templates/pattern.template.html +19 -0
  36. package/tsconfig-examples.json +9 -0
@@ -0,0 +1,512 @@
1
+ import { Component } from 'vue';
2
+
3
+ /** @public */
4
+ export declare type AttributeTable = Record<string, AttributeValue>;
5
+
6
+ /** @public */
7
+ export declare type AttributeValue = string | number | boolean | null | {
8
+ [key: string]: AttributeValue;
9
+ };
10
+
11
+ /**
12
+ * @public
13
+ */
14
+ export declare interface CompileOptions {
15
+ /**
16
+ * Automatically inject this asset in the html template.
17
+ *
18
+ * - `head` - the asset is injected in `<head>`
19
+ * - `body` - the asset is injected in `<body>`
20
+ * - `none` (default) - the asset is not injected.
21
+ */
22
+ appendTo: "none" | "head" | "body";
23
+ /**
24
+ * Extra attributes to include in the `<link>` or `<script>` tag.
25
+ */
26
+ attributes: AttributeTable;
27
+ }
28
+
29
+ /**
30
+ * @public
31
+ */
32
+ declare interface Document_2 {
33
+ /** unique identifier for this document */
34
+ id: string;
35
+ /** human-readable pseudo-identifier for this document (consider it unique but there is no contraint enforcing this) */
36
+ name: string;
37
+ /** alternative names this document can be referenced by */
38
+ alias: string[];
39
+ /** true if document should be visible in menu and similar sources */
40
+ visible: boolean;
41
+ attributes: NormalizedDocumentAttributes;
42
+ body: string;
43
+ /** Document outline (i.e. the heading structure) */
44
+ outline: DocumentOutline;
45
+ /** format of body */
46
+ format: "markdown" | "html" | "json";
47
+ tags: string[];
48
+ template: string;
49
+ fileInfo: FileInfo;
50
+ }
51
+ export { Document_2 as Document }
52
+
53
+ /**
54
+ * @public
55
+ */
56
+ export declare type DocumentBadge = "success" | "error" | "info";
57
+
58
+ /**
59
+ * Represents a document outline (i.e. the heading structure).
60
+ *
61
+ * @public
62
+ */
63
+ export declare type DocumentOutline = DocumentOutlineEntry[];
64
+
65
+ /**
66
+ * Represents a single heading (and its subheadings) in a document outline.
67
+ *
68
+ * @public
69
+ */
70
+ export declare interface DocumentOutlineEntry {
71
+ /** Heading title */
72
+ title: string;
73
+ /** Heading rank, e.g. `##` (h2) is rank 2 */
74
+ rank: number;
75
+ /** Heading anchor (id or name attribute) */
76
+ anchor: string;
77
+ /** Subheadings */
78
+ subheadings: DocumentOutline;
79
+ }
80
+
81
+ /**
82
+ * @public
83
+ */
84
+ export declare interface FileInfo {
85
+ /** path relative to configured base */
86
+ path: string;
87
+ /** filename without extension */
88
+ name: string;
89
+ /** path relative to project root */
90
+ fullPath: string;
91
+ /** output filename or `false` to disable writing result to a file */
92
+ outputName: string | false;
93
+ }
94
+
95
+ /**
96
+ * Read and parse a file from disk to a doc-generator document.
97
+ *
98
+ * @public
99
+ */
100
+ declare type FileReader_2 = (filePath: string, basePath?: string) => Promise<Document_2[]>;
101
+ export { FileReader_2 as FileReader }
102
+
103
+ /**
104
+ * Read a Markdown file with Front Matter.
105
+ *
106
+ * @public
107
+ */
108
+ export declare function frontMatterFileReader(filePath: string, basePath?: string): Promise<Document_2[]>;
109
+
110
+ /**
111
+ * @public
112
+ */
113
+ declare class Generator_2 {
114
+ private site;
115
+ private outputFolder;
116
+ private cacheFolder;
117
+ private assetFolder;
118
+ private exampleFolders;
119
+ private templateFolders;
120
+ private processors;
121
+ private vendor;
122
+ private setupPath;
123
+ private scripts;
124
+ private styles;
125
+ private resources;
126
+ private sourceFiles;
127
+ constructor(options: GeneratorOptions);
128
+ compileScript(name: string, src: string | string[], options?: Partial<CompileOptions>): void;
129
+ compileStyle(name: string, src: string, options?: Partial<CompileOptions>): void;
130
+ /**
131
+ * @param dst - Destination directory relative to asset folder.
132
+ * @param src - File or directory to copy.
133
+ */
134
+ copyResource(dst: string, src: string): void;
135
+ build(sourceFiles: SourceFiles[]): Promise<string[]>;
136
+ /**
137
+ * Start a development server hosting the generated documentation.
138
+ */
139
+ serve(): Promise<void>;
140
+ private _prepareFolders;
141
+ }
142
+ export { Generator_2 as Generator }
143
+
144
+ /**
145
+ * @public
146
+ */
147
+ export declare interface GeneratorOptions {
148
+ /** Site options */
149
+ site: GeneratorSiteOptions;
150
+ outputFolder: string;
151
+ cacheFolder: string;
152
+ /** List of folders to search when locating examples (searched recursively) */
153
+ exampleFolders: string[];
154
+ /** List of folders to search when locating templates. */
155
+ templateFolders?: string[];
156
+ /** List of extra processors to run */
157
+ processors?: Processor[];
158
+ /** List of vendor assets to compile */
159
+ vendor?: VendorDefinition[];
160
+ /** Path to file with exported `setup` function, responsible for mounting of component.
161
+ * `function setup(options: { rootComponent: string, selector: string }): void`
162
+ */
163
+ setupPath: string;
164
+ }
165
+
166
+ /**
167
+ * @public
168
+ */
169
+ export declare interface GeneratorSiteOptions {
170
+ /** Site name */
171
+ name: string;
172
+ /** Site languange (BCP-47, e.g. `en` or `sv`), default `en` */
173
+ lang?: string;
174
+ }
175
+
176
+ /**
177
+ * @public
178
+ */
179
+ export declare function livereloadProcessor(options: ProcessorOptions): Processor;
180
+
181
+ /**
182
+ * @public
183
+ */
184
+ export declare interface MatomoOptions {
185
+ /** Matomo Site ID */
186
+ siteId: string;
187
+ /** Matomo API URL */
188
+ apiUrl: string;
189
+ /** Matomo Tracker URL */
190
+ trackerUrl: string;
191
+ /** Site hostname (analytics will be disabled if the hostname of the running
192
+ * site does not match one of the configured hostnames) */
193
+ hostname?: string | string[];
194
+ }
195
+
196
+ /**
197
+ * @public
198
+ */
199
+ export declare function matomoProcessor(options: MatomoOptions & ProcessorOptions): Processor;
200
+
201
+ /**
202
+ * Read a JSON file with arbitrary navigation entries.
203
+ *
204
+ * @public
205
+ */
206
+ export declare function navigationFileReader(filePath: string, basePath?: string): Promise<Document_2[]>;
207
+
208
+ /**
209
+ * @public
210
+ */
211
+ export declare interface NavigationLeaf {
212
+ readonly title: string;
213
+ readonly path: string;
214
+ readonly sortorder: number;
215
+ readonly id: string;
216
+ readonly external: boolean;
217
+ }
218
+
219
+ /**
220
+ * @public
221
+ */
222
+ export declare type NavigationNode = NavigationLeaf | NavigationSection;
223
+
224
+ /**
225
+ * @public
226
+ */
227
+ export declare interface NavigationSection {
228
+ readonly key: string;
229
+ readonly title: string;
230
+ readonly path: string;
231
+ readonly sortorder: number;
232
+ readonly children: NavigationNode[];
233
+ }
234
+
235
+ /**
236
+ * @public
237
+ */
238
+ export declare interface NormalizedDocumentAttributes {
239
+ title?: string;
240
+ layout?: string;
241
+ status?: string;
242
+ badge?: DocumentBadge;
243
+ component?: string[];
244
+ href?: string;
245
+ /** normalized sortorder (defaults to Infinity) */
246
+ sortorder: number;
247
+ }
248
+
249
+ /**
250
+ * @public
251
+ */
252
+ export declare type Processor = ProcessorDescriptor<"before"> | ProcessorDescriptor<"stage"> | ProcessorDescriptor<"after">;
253
+
254
+ /**
255
+ * @public
256
+ */
257
+ export declare interface ProcessorContext {
258
+ readonly docs: Document_2[];
259
+ readonly vendors: VendorAsset[];
260
+ readonly topnav: NavigationSection;
261
+ readonly sidenav: NavigationSection;
262
+ readonly resources: ResourceTask[];
263
+ addDocument(document: Document_2 | Document_2[]): void;
264
+ addVendorAsset(asset: VendorAsset | VendorAsset[]): void;
265
+ /**
266
+ * Add a new resource asset to be copied.
267
+ *
268
+ * @param dst - Destination directory relative to asset folder.
269
+ * @param src - File or directory to copy.
270
+ */
271
+ addResource(dst: string, src: string): void;
272
+ /**
273
+ * Add a new block to be rendered in the template.
274
+ *
275
+ * @param container - The template container to add the block to. The
276
+ * container must exist in the template or nothing will be rendered.
277
+ * @param id - A unique identifier for this block.
278
+ * @param renderer - Describes how to render the block content.
279
+ */
280
+ addTemplateBlock(container: string, id: string, renderer: TemplateBlockRenderer): void;
281
+ /* Excluded from this release type: getAllTemplateBlocks */
282
+ setTopNavigation(root: NavigationSection): void;
283
+ setSideNavigation(root: NavigationSection): void;
284
+ getAllTemplateData(): Record<string, unknown>;
285
+ getTemplateData<K extends keyof TemplateData>(key: K): TemplateData[K] | undefined;
286
+ getTemplateData(key: string): unknown;
287
+ setTemplateData<K extends keyof TemplateData>(key: string, value: TemplateData[K]): void;
288
+ setTemplateData(key: string, value: unknown): void;
289
+ log<TArgs extends unknown[]>(...args: TArgs): void;
290
+ }
291
+
292
+ /**
293
+ * @public
294
+ */
295
+ export declare type ProcessorDescriptor<K extends "before" | "stage" | "after"> = ProcessorHook<K> & ProcessorHandler;
296
+
297
+ /**
298
+ * @public
299
+ */
300
+ export declare interface ProcessorHandler {
301
+ before?: ProcessorStage;
302
+ stage?: ProcessorStage;
303
+ after?: ProcessorStage;
304
+ name: string;
305
+ enabled?: boolean;
306
+ handler(context: ProcessorContext): void | string[] | Promise<void> | Promise<string[]>;
307
+ }
308
+
309
+ /**
310
+ * @public
311
+ */
312
+ export declare type ProcessorHook<K extends "before" | "stage" | "after"> = {
313
+ [k in K]: ProcessorStage;
314
+ };
315
+
316
+ /**
317
+ * @public
318
+ */
319
+ export declare interface ProcessorOptions {
320
+ /** Enable/disable processor. Default: `true` */
321
+ enabled?: boolean;
322
+ }
323
+
324
+ /**
325
+ * @public
326
+ */
327
+ export declare type ProcessorStage = "generate-docs" | "generate-nav" | "assets" | "render";
328
+
329
+ /**
330
+ * Represents a resource to be copied from `from` to `to`.
331
+ *
332
+ * @public
333
+ */
334
+ export declare interface ResourceTask {
335
+ from: string;
336
+ to: string;
337
+ }
338
+
339
+ /**
340
+ * @public
341
+ */
342
+ export declare function searchProcessor(): Processor;
343
+
344
+ /**
345
+ * Make it possible to change version.
346
+ *
347
+ * @public
348
+ */
349
+ export declare function selectableVersionProcessor(pkg: {
350
+ name: string;
351
+ version: string;
352
+ }, container: string): Processor;
353
+
354
+ /**
355
+ * Options passed from the example compiler to the `setup` function.
356
+ *
357
+ * @public
358
+ */
359
+ export declare interface SetupOptions {
360
+ /** The example component expected to be mounted by the application */
361
+ rootComponent: Component;
362
+ /** Where the example should be mounted */
363
+ selector: string;
364
+ }
365
+
366
+ /**
367
+ * @public
368
+ */
369
+ export declare interface SourceFiles {
370
+ include: string | string[];
371
+ exclude?: string | string[];
372
+ basePath?: string;
373
+ fileReader: FileReader_2;
374
+ /**
375
+ * Transform document before further processing.
376
+ *
377
+ * Typical use-case is modifying attributes, name or aliases.
378
+ */
379
+ transform?(doc: Document_2): Document_2;
380
+ }
381
+
382
+ /* Excluded from this release type: TemplateBlockData */
383
+
384
+ /**
385
+ * Template block renderer.
386
+ *
387
+ * - If you pass a filename the filename will be rendered with the templating engine.
388
+ * - If you pass a function the returned markup will be injected into the rendered template.
389
+ *
390
+ * @public
391
+ */
392
+ export declare type TemplateBlockRenderer = {
393
+ filename: string;
394
+ data?: Record<string, unknown>;
395
+ } | {
396
+ render(): string;
397
+ };
398
+
399
+ /**
400
+ * @public
401
+ */
402
+ export declare interface TemplateData {
403
+ }
404
+
405
+ /**
406
+ * Injects a theme selector into the toolbar.
407
+ *
408
+ * @public
409
+ */
410
+ export declare function themeSelectProcessor(): Processor;
411
+
412
+ /**
413
+ * Represents a compiled vendor asset.
414
+ *
415
+ * @public
416
+ */
417
+ export declare interface VendorAsset {
418
+ package: string;
419
+ /** Filename of the asset */
420
+ filename: string;
421
+ /** Public path to the asset (including filename) */
422
+ publicPath: string;
423
+ /** Subresource integrity */
424
+ integrity: string;
425
+ /** size of asset in bytes */
426
+ size: number;
427
+ }
428
+
429
+ /**
430
+ * @public
431
+ */
432
+ export declare type VendorDefinition = string | VendorDefinitionDescriptor;
433
+
434
+ /**
435
+ * Describes a vendor assets to be bundled and globally available on the site.
436
+ *
437
+ * @public
438
+ */
439
+ export declare interface VendorDefinitionDescriptor {
440
+ /**
441
+ * Importabe package name or path.
442
+ */
443
+ package: string;
444
+ /**
445
+ * If set, the package will be available on `window` under the given
446
+ * name. Requires the `export` property to be set to have any effect.
447
+ */
448
+ global?: string;
449
+ /**
450
+ * If set this bundle will be exposed for usage with `require(..)` and if
451
+ * `global` is defined on the `window` object.
452
+ *
453
+ * When set to "named" the named exports will be exposed.
454
+ * When set to "default" the default export will be exposed.
455
+ */
456
+ expose?: "named" | "default";
457
+ /**
458
+ * Optional list of additional subpaths to export from the package.
459
+ *
460
+ * E.g.:
461
+ *
462
+ * ```json
463
+ * {
464
+ * "package": "moment",
465
+ * "expose": "default",
466
+ * "subpaths": [
467
+ * "moment/locale/sv"
468
+ * ]
469
+ * }
470
+ * ```
471
+ */
472
+ subpaths?: string[];
473
+ /**
474
+ * Optional alias for package name or path.
475
+ * When an alias is given the package can be imported using the given alias as well as the original package name.
476
+ * For instance, when using the following configuration "vue" can be imported and resolved as "vue/dist/esm.bundle.js".
477
+ * ```json
478
+ * {
479
+ * "package": "vue",
480
+ * "alias": "vue/dist/esm.bundle.js",
481
+ * }
482
+ * ```
483
+ */
484
+ alias?: string;
485
+ }
486
+
487
+ /**
488
+ * Display a banner with message when path dosen't start with /latest.
489
+ * @param message - Message to display in banner, may contain html-template.
490
+ *
491
+ * @public
492
+ */
493
+ export declare function versionBannerProcessor(message: string, container: string): Processor;
494
+
495
+ /**
496
+ * Injects the package name and version into the document.
497
+ *
498
+ * @public
499
+ */
500
+ export declare function versionProcessor(pkg: {
501
+ name: string;
502
+ version: string;
503
+ }, container: string): Processor;
504
+
505
+ /**
506
+ * Generate API documentation from a Vue SFC.
507
+ *
508
+ * @public
509
+ */
510
+ export declare function vueFileReader(filePath: string): Promise<Document_2[]>;
511
+
512
+ export { }