@ng-prism/plugin-jsdoc 22.5.0 → 22.7.0-beta.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 (46) hide show
  1. package/README.md +18 -15
  2. package/dist/api-page/api-page.helpers.d.ts +79 -0
  3. package/dist/api-page/api-page.helpers.d.ts.map +1 -0
  4. package/dist/api-page/api-page.helpers.js +133 -0
  5. package/dist/api-page/api-page.model.d.ts +62 -0
  6. package/dist/api-page/api-page.model.d.ts.map +1 -0
  7. package/dist/api-page/api-page.model.js +122 -0
  8. package/dist/api-page/component-usage.d.ts +14 -0
  9. package/dist/api-page/component-usage.d.ts.map +1 -0
  10. package/dist/api-page/component-usage.js +120 -0
  11. package/dist/api-page/doc-links.d.ts +15 -0
  12. package/dist/api-page/doc-links.d.ts.map +1 -0
  13. package/dist/api-page/doc-links.js +45 -0
  14. package/dist/api-page/jsdoc-api-page.component.d.ts +98 -0
  15. package/dist/api-page/jsdoc-api-page.component.d.ts.map +1 -0
  16. package/dist/api-page/jsdoc-api-page.component.js +1458 -0
  17. package/dist/api-page/pipe-usage.d.ts +13 -0
  18. package/dist/api-page/pipe-usage.d.ts.map +1 -0
  19. package/dist/api-page/pipe-usage.js +35 -0
  20. package/dist/api-page/service-usage.d.ts +31 -0
  21. package/dist/api-page/service-usage.d.ts.map +1 -0
  22. package/dist/api-page/service-usage.js +66 -0
  23. package/dist/jsdoc-extractor.d.ts.map +1 -1
  24. package/dist/jsdoc-extractor.js +17 -10
  25. package/dist/jsdoc-panel.component.d.ts +8 -25
  26. package/dist/jsdoc-panel.component.d.ts.map +1 -1
  27. package/dist/jsdoc-panel.component.js +34 -474
  28. package/dist/jsdoc-plugin.browser.js +2 -2
  29. package/dist/jsdoc-plugin.d.ts.map +1 -1
  30. package/dist/jsdoc-plugin.js +4 -1
  31. package/dist/service-page/api-page.model.d.ts +35 -0
  32. package/dist/service-page/api-page.model.d.ts.map +1 -0
  33. package/dist/service-page/api-page.model.js +54 -0
  34. package/dist/service-page/jsdoc-service-page.component.d.ts +82 -0
  35. package/dist/service-page/jsdoc-service-page.component.d.ts.map +1 -0
  36. package/dist/service-page/jsdoc-service-page.component.js +1178 -0
  37. package/dist/service-page/pipe-usage.d.ts +13 -0
  38. package/dist/service-page/pipe-usage.d.ts.map +1 -0
  39. package/dist/service-page/pipe-usage.js +35 -0
  40. package/dist/service-page/service-page.model.d.ts +78 -0
  41. package/dist/service-page/service-page.model.d.ts.map +1 -0
  42. package/dist/service-page/service-page.model.js +130 -0
  43. package/dist/service-page/service-usage.d.ts +28 -0
  44. package/dist/service-page/service-usage.d.ts.map +1 -0
  45. package/dist/service-page/service-usage.js +61 -0
  46. package/package.json +3 -2
@@ -7,8 +7,8 @@ export function jsDocPlugin() {
7
7
  label: 'API',
8
8
  icon: 'file-text',
9
9
  loadComponent: () => import('./jsdoc-panel.component.js').then((m) => m.JsDocPanelComponent),
10
- position: 'bottom',
11
- placement: 'view'
10
+ placement: 'view',
11
+ appliesTo: ['component', 'service', 'pipe']
12
12
  }
13
13
  ]
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"jsdoc-plugin.d.ts","sourceRoot":"","sources":["../src/jsdoc-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,wBAAgB,WAAW,IAAI,aAAa,CAyB3C"}
1
+ {"version":3,"file":"jsdoc-plugin.d.ts","sourceRoot":"","sources":["../src/jsdoc-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,wBAAgB,WAAW,IAAI,aAAa,CA4B3C"}
@@ -2,6 +2,8 @@ import { extractJsDocData } from './jsdoc-extractor.js';
2
2
  export function jsDocPlugin() {
3
3
  return {
4
4
  name: '@ng-prism/plugin-jsdoc',
5
+ // The API page reads `ScannedComponent.api`, which the scan only reads for a plugin that asks for it.
6
+ componentApi: true,
5
7
  async onComponentScanned(component) {
6
8
  const jsdoc = extractJsDocData(component.filePath, component.className, component.baseClasses);
7
9
  if (!jsdoc)
@@ -20,7 +22,8 @@ export function jsDocPlugin() {
20
22
  label: 'API',
21
23
  icon: 'file-text',
22
24
  loadComponent: () => import('./jsdoc-panel.component.js').then((m) => m.JsDocPanelComponent),
23
- position: 'bottom'
25
+ placement: 'view',
26
+ appliesTo: ['component', 'service', 'pipe']
24
27
  }
25
28
  ]
26
29
  };
@@ -0,0 +1,35 @@
1
+ import type { ApiMethod, ApiProperty, ApiSetupEntry, ApiTypeDoc, ScannedPipe, ScannedService } from '@ng-prism/core/plugin';
2
+ /** A chip under the description, `Since: 1.2.0` or a bare `Pure`; the deprecation is a badge of its own. */
3
+ export interface ApiPageChip {
4
+ label: string;
5
+ value?: string;
6
+ deprecated?: true;
7
+ }
8
+ /**
9
+ * What the API page shows, for a service or a pipe. The page renders this
10
+ * alone, so a pipe page and a service page share one look; the sections a
11
+ * kind does not have are left out.
12
+ *
13
+ * The entries are the scanned objects themselves, not copies: the page caches
14
+ * what it derives from them by object.
15
+ */
16
+ export interface ApiPageModel {
17
+ kind: 'service' | 'pipe';
18
+ className: string;
19
+ description?: string;
20
+ chips: ApiPageChip[];
21
+ see: string[];
22
+ usage: string;
23
+ setup: ApiSetupEntry[];
24
+ examples: string[];
25
+ /** Services only. */
26
+ properties?: ApiProperty[];
27
+ /** Services: the public methods. */
28
+ methods?: ApiMethod[];
29
+ /** Pipes: one entry per transform signature. */
30
+ transform?: ApiMethod[];
31
+ types: ApiTypeDoc[];
32
+ }
33
+ export declare function servicePage(service: ScannedService): ApiPageModel;
34
+ export declare function pipePage(pipe: ScannedPipe): ApiPageModel;
35
+ //# sourceMappingURL=api-page.model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-page.model.d.ts","sourceRoot":"","sources":["../../src/service-page/api-page.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAIxI,4GAA4G;AAC5G,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,IAAI,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,qBAAqB;IACrB,UAAU,CAAC,EAAE,WAAW,EAAE,CAAC;IAC3B,oCAAoC;IACpC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,gDAAgD;IAChD,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC;IACxB,KAAK,EAAE,UAAU,EAAE,CAAC;CACvB;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,YAAY,CAqBjE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,CAsBxD"}
@@ -0,0 +1,54 @@
1
+ import { generatePipeUsage } from './pipe-usage.js';
2
+ import { generateServiceUsage } from './service-usage.js';
3
+ export function servicePage(service) {
4
+ const { className, importPath, provision, api } = service;
5
+ return {
6
+ kind: 'service',
7
+ className,
8
+ description: api.description,
9
+ chips: [
10
+ ...deprecationChip(api.tags),
11
+ ...valueChip('Since', api.tags.since),
12
+ { label: 'Provided in', value: provision === 'auto' ? 'root/automatically' : 'providers' },
13
+ ...valueChip('Entry point', importPath)
14
+ ],
15
+ see: api.tags.see ?? [],
16
+ usage: generateServiceUsage(service),
17
+ setup: api.setup,
18
+ examples: api.tags.example ?? [],
19
+ properties: api.properties,
20
+ methods: api.methods,
21
+ types: api.types
22
+ };
23
+ }
24
+ export function pipePage(pipe) {
25
+ const { className, importPath, pipeName, pure, api } = pipe;
26
+ return {
27
+ kind: 'pipe',
28
+ className,
29
+ description: api.description,
30
+ chips: [
31
+ ...deprecationChip(api.tags),
32
+ { label: 'Pipe', value: pipeName },
33
+ // Unreadable purity is no reason to guess: the chip goes.
34
+ ...(pure === undefined ? [] : [{ label: pure ? 'Pure' : 'Impure' }]),
35
+ ...valueChip('Since', api.tags.since),
36
+ ...valueChip('Entry point', importPath)
37
+ ],
38
+ see: api.tags.see ?? [],
39
+ usage: generatePipeUsage(pipe),
40
+ setup: api.setup,
41
+ examples: api.tags.example ?? [],
42
+ transform: api.transform,
43
+ types: api.types
44
+ };
45
+ }
46
+ /** The deprecation leads the chips, with its message when the tag has one. */
47
+ function deprecationChip({ deprecated }) {
48
+ if (!deprecated)
49
+ return [];
50
+ return [{ label: 'Deprecated', ...(typeof deprecated === 'string' ? { value: deprecated } : {}), deprecated: true }];
51
+ }
52
+ function valueChip(label, value) {
53
+ return value ? [{ label, value }] : [];
54
+ }
@@ -0,0 +1,82 @@
1
+ import { SafeHtml } from '@angular/platform-browser';
2
+ import type { ApiDocTags, ApiMethod, ApiProperty, ApiTypeDoc } from '@ng-prism/core/plugin';
3
+ import { type ParsedExample } from '../markdown.js';
4
+ import type { ApiPageModel } from './api-page.model.js';
5
+ import { documentsParams, splitReachedFrom, typeAnchor } from './service-page.model.js';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * The API page of a service or a pipe: what it is, how to bring it in, what it
9
+ * offers and the types its API reaches, with an "On this page" list next to
10
+ * it. It renders an `ApiPageModel`, so both kinds share one look.
11
+ *
12
+ * The host is the scroll container (the panel stylesheet gives it `overflow:
13
+ * auto`), so every jump scrolls it, never the window or the shell around it.
14
+ *
15
+ * It also carries a render marker, the class name of what it shows:
16
+ * `data-prism-service-rendered` on a service page, `data-prism-pipe-rendered`
17
+ * on a pipe page, the other one absent. Host bindings update in the same pass
18
+ * as the template, so the marker names a class only once its page is in the
19
+ * DOM, which is what an outside tool such as the showcase skill's screenshot
20
+ * script waits for.
21
+ */
22
+ export declare class JsDocServicePageComponent {
23
+ readonly page: import("@angular/core").InputSignal<ApiPageModel>;
24
+ private readonly sanitizer;
25
+ private readonly host;
26
+ /** Kind and class name, not the page object: a manifest update during `serve` hands over a new page for the same class. */
27
+ protected readonly kind: import("@angular/core").Signal<"service" | "pipe">;
28
+ protected readonly className: import("@angular/core").Signal<string>;
29
+ protected readonly serviceProperties: import("@angular/core").Signal<ApiProperty[]>;
30
+ protected readonly serviceMethods: import("@angular/core").Signal<ApiMethod[]>;
31
+ protected readonly transformSignatures: import("@angular/core").Signal<ApiMethod[]>;
32
+ protected readonly toc: import("@angular/core").Signal<import("./service-page.model.js").TocEntry[]>;
33
+ protected readonly renderedDescription: import("@angular/core").Signal<SafeHtml | null>;
34
+ protected readonly activeId: import("@angular/core").WritableSignal<string>;
35
+ protected readonly highlightedId: import("@angular/core").WritableSignal<string | null>;
36
+ protected readonly copied: import("@angular/core").WritableSignal<boolean>;
37
+ protected readonly segmentsOf: (key: import("@ng-prism/core/plugin").ApiTypeRef) => import("./service-page.model.js").TypeSegment[];
38
+ protected readonly declaredParamSegmentsOf: (key: import("@ng-prism/core/plugin").ApiParam) => import("./service-page.model.js").TypeSegment[];
39
+ protected readonly signatureOf: (key: import("@ng-prism/core/plugin").ApiSetupEntry) => import("./service-page.model.js").TypeSegment[];
40
+ protected readonly documentsParams: typeof documentsParams;
41
+ protected readonly splitReachedFrom: typeof splitReachedFrom;
42
+ protected readonly typeAnchor: typeof typeAnchor;
43
+ private readonly blockHtml;
44
+ private readonly inlineHtml;
45
+ /**
46
+ * The entry the reader jumped to, until the jump is over: the smooth scroll
47
+ * passes other sections on its way, and one near the bottom of the page is
48
+ * never scrolled up to the activation line.
49
+ */
50
+ private jumpTarget;
51
+ private spyFrame;
52
+ private jumpTimer?;
53
+ private highlightTimer?;
54
+ private copiedTimer?;
55
+ constructor();
56
+ /** Scroll to a section or a type card; a type card lights up briefly so the eye finds it. */
57
+ protected goTo(id: string): void;
58
+ protected copyUsage(): void;
59
+ protected isDeprecated(tags: ApiDocTags): boolean;
60
+ protected deprecatedMessage(tags: ApiDocTags): string | undefined;
61
+ protected renderBlock(text: string | undefined): SafeHtml | null;
62
+ protected renderInline(text: string): SafeHtml;
63
+ protected parseExample(raw: string): ParsedExample;
64
+ /** An interface or object type says what may be left out; a class property has nothing to require. */
65
+ protected isRequired(property: ApiProperty, owner?: ApiTypeDoc): boolean;
66
+ protected hasDefaults(properties: ApiProperty[]): boolean;
67
+ protected hasParams(methods: ApiMethod[]): boolean;
68
+ protected hasValues(type: ApiTypeDoc): boolean;
69
+ private onScroll;
70
+ /**
71
+ * The jump is over: from here on the scroll position decides. The entry
72
+ * stays as it is until the next scroll moves the page, so a frame still
73
+ * pending from the jump is dropped rather than allowed to overrule it.
74
+ */
75
+ private endJump;
76
+ private anchors;
77
+ private offsetOf;
78
+ private sectionInView;
79
+ static ɵfac: i0.ɵɵFactoryDeclaration<JsDocServicePageComponent, never>;
80
+ static ɵcmp: i0.ɵɵComponentDeclaration<JsDocServicePageComponent, "prism-jsdoc-service-page", never, { "page": { "alias": "page"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
81
+ }
82
+ //# sourceMappingURL=jsdoc-service-page.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsdoc-service-page.component.d.ts","sourceRoot":"","sources":["../../src/service-page/jsdoc-service-page.component.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,EAAE,KAAK,aAAa,EAA2D,M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