@ng-prism/plugin-jsdoc 22.6.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.
- package/README.md +18 -15
- package/dist/api-page/api-page.helpers.d.ts +79 -0
- package/dist/api-page/api-page.helpers.d.ts.map +1 -0
- package/dist/api-page/api-page.helpers.js +133 -0
- package/dist/api-page/api-page.model.d.ts +62 -0
- package/dist/api-page/api-page.model.d.ts.map +1 -0
- package/dist/api-page/api-page.model.js +122 -0
- package/dist/api-page/component-usage.d.ts +14 -0
- package/dist/api-page/component-usage.d.ts.map +1 -0
- package/dist/api-page/component-usage.js +120 -0
- package/dist/api-page/doc-links.d.ts +15 -0
- package/dist/api-page/doc-links.d.ts.map +1 -0
- package/dist/api-page/doc-links.js +45 -0
- package/dist/api-page/jsdoc-api-page.component.d.ts +98 -0
- package/dist/api-page/jsdoc-api-page.component.d.ts.map +1 -0
- package/dist/api-page/jsdoc-api-page.component.js +1458 -0
- package/dist/api-page/pipe-usage.d.ts +13 -0
- package/dist/api-page/pipe-usage.d.ts.map +1 -0
- package/dist/api-page/pipe-usage.js +35 -0
- package/dist/api-page/service-usage.d.ts +31 -0
- package/dist/api-page/service-usage.d.ts.map +1 -0
- package/dist/api-page/service-usage.js +66 -0
- package/dist/jsdoc-extractor.d.ts.map +1 -1
- package/dist/jsdoc-extractor.js +17 -10
- package/dist/jsdoc-panel.component.d.ts +8 -25
- package/dist/jsdoc-panel.component.d.ts.map +1 -1
- package/dist/jsdoc-panel.component.js +34 -474
- package/dist/jsdoc-plugin.browser.d.ts.map +1 -1
- package/dist/jsdoc-plugin.browser.js +2 -1
- package/dist/jsdoc-plugin.d.ts.map +1 -1
- package/dist/jsdoc-plugin.js +5 -1
- package/dist/service-page/api-page.model.d.ts +35 -0
- package/dist/service-page/api-page.model.d.ts.map +1 -0
- package/dist/service-page/api-page.model.js +54 -0
- package/dist/service-page/jsdoc-service-page.component.d.ts +82 -0
- package/dist/service-page/jsdoc-service-page.component.d.ts.map +1 -0
- package/dist/service-page/jsdoc-service-page.component.js +1178 -0
- package/dist/service-page/pipe-usage.d.ts +13 -0
- package/dist/service-page/pipe-usage.d.ts.map +1 -0
- package/dist/service-page/pipe-usage.js +35 -0
- package/dist/service-page/service-page.model.d.ts +78 -0
- package/dist/service-page/service-page.model.d.ts.map +1 -0
- package/dist/service-page/service-page.model.js +130 -0
- package/dist/service-page/service-usage.d.ts +28 -0
- package/dist/service-page/service-usage.d.ts.map +1 -0
- package/dist/service-page/service-usage.js +61 -0
- package/package.json +3 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { typeAnchor } from './api-page.helpers.js';
|
|
2
|
+
/** A `{@link}` tag: the target ends at a space, a bar or the brace, the text follows after a bar or after a space. */
|
|
3
|
+
const LINK_TAG = /\{@(?:link|linkcode|linkplain)\s+([^\s|}]+)\s*(?:\|\s*)?([^}]*)\}/g;
|
|
4
|
+
/** A Markdown code span: a run of backticks up to the next run of the same length. */
|
|
5
|
+
const CODE_SPAN = /(?<!`)(`+)(?!`)[\s\S]*?(?<!`)\1(?!`)/g;
|
|
6
|
+
const URL_TARGET = /^[a-z][a-z\d+.-]*:/i;
|
|
7
|
+
/** Marks the button of a link, so the page can find it in rendered `innerHTML` that Angular does not bind. */
|
|
8
|
+
export const TYPE_LINK_ATTRIBUTE = 'data-prism-type-link';
|
|
9
|
+
/**
|
|
10
|
+
* The TOC anchor of the type card a doc reference names: by id, then by name;
|
|
11
|
+
* `X.y` and `X#y` name `X`. A page holds two types of one name only under
|
|
12
|
+
* different ids, so an exact id is what tells them apart.
|
|
13
|
+
*/
|
|
14
|
+
export function typeLinkTarget(types, target) {
|
|
15
|
+
const named = (name) => (types.find((type) => type.id === name) ?? types.find((type) => type.name === name))?.id;
|
|
16
|
+
const id = named(target) ?? named(target.split(/[.#]/, 1)[0]);
|
|
17
|
+
return id === undefined ? undefined : typeAnchor(id);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Rewrites `{@link}`, `{@linkcode}` and `{@linkplain}` into what the Markdown renderer shows: a button to the type card
|
|
21
|
+
* `resolve` names, a Markdown link for a URL target, inline code (or the link text) otherwise. Code spans stay as written.
|
|
22
|
+
*/
|
|
23
|
+
export function resolveDocLinks(text, resolve) {
|
|
24
|
+
let result = '';
|
|
25
|
+
let end = 0;
|
|
26
|
+
for (const span of text.matchAll(CODE_SPAN)) {
|
|
27
|
+
result += rewriteLinks(text.slice(end, span.index), resolve) + span[0];
|
|
28
|
+
end = span.index + span[0].length;
|
|
29
|
+
}
|
|
30
|
+
return result + rewriteLinks(text.slice(end), resolve);
|
|
31
|
+
}
|
|
32
|
+
function rewriteLinks(text, resolve) {
|
|
33
|
+
return text.replace(LINK_TAG, (_tag, target, linkText) => {
|
|
34
|
+
const label = linkText.trim();
|
|
35
|
+
if (URL_TARGET.test(target))
|
|
36
|
+
return `[${label || target}](${target})`;
|
|
37
|
+
const anchor = resolve(target);
|
|
38
|
+
if (anchor === undefined)
|
|
39
|
+
return label || `\`${target}\``;
|
|
40
|
+
return `<button type="button" class="prism-jsdoc-api-page__ref" ${TYPE_LINK_ATTRIBUTE}="${escapeHtml(anchor)}">${escapeHtml(label || target)}</button>`;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function escapeHtml(text) {
|
|
44
|
+
return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
45
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
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 { documentsParams, splitReachedFrom, typeAnchor } from './api-page.helpers.js';
|
|
5
|
+
import type { ApiOutputRow, ApiPageModel } from './api-page.model.js';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
/**
|
|
8
|
+
* The API page of a component, a directive, a service or a pipe: what it is,
|
|
9
|
+
* how to bring it in, what it offers and the types its API reaches, with an
|
|
10
|
+
* "On this page" list next to it. It renders an `ApiPageModel`, so all four
|
|
11
|
+
* kinds share one look.
|
|
12
|
+
*
|
|
13
|
+
* The host is the scroll container (the panel stylesheet gives it `overflow:
|
|
14
|
+
* auto`), so every jump scrolls it, never the window or the shell around it.
|
|
15
|
+
*
|
|
16
|
+
* It also carries a render marker, the class name of what it shows:
|
|
17
|
+
* `data-prism-component-rendered` on a component or directive page,
|
|
18
|
+
* `data-prism-service-rendered` on a service page, `data-prism-pipe-rendered`
|
|
19
|
+
* on a pipe page. Exactly one of the three is set, the others are absent. Host
|
|
20
|
+
* bindings update in the same pass as the template, so the marker names a
|
|
21
|
+
* class only once its page is in the DOM, which is what an outside tool such
|
|
22
|
+
* as the showcase skill's screenshot script waits for.
|
|
23
|
+
*/
|
|
24
|
+
export declare class JsDocApiPageComponent {
|
|
25
|
+
readonly page: import("@angular/core").InputSignal<ApiPageModel>;
|
|
26
|
+
private readonly sanitizer;
|
|
27
|
+
private readonly host;
|
|
28
|
+
/** Kind and class name, not the page object: a manifest update during `serve` hands over a new page for the same class. */
|
|
29
|
+
protected readonly kind: import("@angular/core").Signal<import("./api-page.model.js").ApiPageKind>;
|
|
30
|
+
protected readonly className: import("@angular/core").Signal<string>;
|
|
31
|
+
protected readonly inputs: import("@angular/core").Signal<import("./api-page.model.js").ApiInputRow[]>;
|
|
32
|
+
protected readonly outputs: import("@angular/core").Signal<ApiOutputRow[]>;
|
|
33
|
+
protected readonly serviceProperties: import("@angular/core").Signal<ApiProperty[]>;
|
|
34
|
+
protected readonly pageMethods: import("@angular/core").Signal<ApiMethod[]>;
|
|
35
|
+
protected readonly transformSignatures: import("@angular/core").Signal<ApiMethod[]>;
|
|
36
|
+
protected readonly toc: import("@angular/core").Signal<import("./api-page.helpers.js").TocEntry[]>;
|
|
37
|
+
protected readonly renderedDescription: import("@angular/core").Signal<SafeHtml | null>;
|
|
38
|
+
protected readonly activeId: import("@angular/core").WritableSignal<string>;
|
|
39
|
+
protected readonly highlightedId: import("@angular/core").WritableSignal<string | null>;
|
|
40
|
+
protected readonly copied: import("@angular/core").WritableSignal<boolean>;
|
|
41
|
+
protected readonly segmentsOf: (key: import("@ng-prism/core/plugin").ApiTypeRef) => import("./api-page.helpers.js").TypeSegment[];
|
|
42
|
+
protected readonly declaredParamSegmentsOf: (key: import("@ng-prism/core/plugin").ApiParam) => import("./api-page.helpers.js").TypeSegment[];
|
|
43
|
+
protected readonly signatureOf: (key: import("@ng-prism/core/plugin").ApiSetupEntry) => import("./api-page.helpers.js").TypeSegment[];
|
|
44
|
+
protected readonly documentsParams: typeof documentsParams;
|
|
45
|
+
protected readonly splitReachedFrom: typeof splitReachedFrom;
|
|
46
|
+
protected readonly typeAnchor: typeof typeAnchor;
|
|
47
|
+
/**
|
|
48
|
+
* The rendered descriptions of the page being shown. A link resolves against
|
|
49
|
+
* that page's types, so the caches go with the page: this instance outlives
|
|
50
|
+
* a switch to another component, service or pipe, and the HTML of its
|
|
51
|
+
* texts must not outlive the page they were rendered for.
|
|
52
|
+
*/
|
|
53
|
+
private readonly rendered;
|
|
54
|
+
/**
|
|
55
|
+
* The entry the reader jumped to, until the jump is over: the smooth scroll
|
|
56
|
+
* passes other sections on its way, and one near the bottom of the page is
|
|
57
|
+
* never scrolled up to the activation line.
|
|
58
|
+
*/
|
|
59
|
+
private jumpTarget;
|
|
60
|
+
private spyFrame;
|
|
61
|
+
private jumpTimer?;
|
|
62
|
+
private highlightTimer?;
|
|
63
|
+
private copiedTimer?;
|
|
64
|
+
constructor();
|
|
65
|
+
/** Scroll to a section or a type card; a type card lights up briefly so the eye finds it. */
|
|
66
|
+
protected goTo(id: string): void;
|
|
67
|
+
protected copyUsage(): void;
|
|
68
|
+
protected isDeprecated(tags: ApiDocTags): boolean;
|
|
69
|
+
protected deprecatedMessage(tags: ApiDocTags): string | undefined;
|
|
70
|
+
protected renderBlock(text: string | undefined): SafeHtml | null;
|
|
71
|
+
protected renderInline(text: string): SafeHtml;
|
|
72
|
+
/** The TOC anchor of the type card a `@see` reference names, if it is on the page. */
|
|
73
|
+
protected seeTarget(reference: string): string | undefined;
|
|
74
|
+
protected parseExample(raw: string): ParsedExample;
|
|
75
|
+
/** An interface or object type says what may be left out; a class property has nothing to require. */
|
|
76
|
+
protected isRequired(property: ApiProperty, owner?: ApiTypeDoc): boolean;
|
|
77
|
+
protected hasDefaults(properties: ApiProperty[]): boolean;
|
|
78
|
+
/** The scanner reads an output's payload from the source; without it the column would be empty. */
|
|
79
|
+
protected hasPayloads(outputs: ApiOutputRow[]): boolean;
|
|
80
|
+
protected hasParams(methods: ApiMethod[]): boolean;
|
|
81
|
+
protected hasValues(type: ApiTypeDoc): boolean;
|
|
82
|
+
/** The links inside rendered descriptions are plain HTML, so one listener on the host catches them all. */
|
|
83
|
+
protected onHostClick(event: MouseEvent): void;
|
|
84
|
+
private withLinks;
|
|
85
|
+
private onScroll;
|
|
86
|
+
/**
|
|
87
|
+
* The jump is over: from here on the scroll position decides. The entry
|
|
88
|
+
* stays as it is until the next scroll moves the page, so a frame still
|
|
89
|
+
* pending from the jump is dropped rather than allowed to overrule it.
|
|
90
|
+
*/
|
|
91
|
+
private endJump;
|
|
92
|
+
private anchors;
|
|
93
|
+
private offsetOf;
|
|
94
|
+
private sectionInView;
|
|
95
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<JsDocApiPageComponent, never>;
|
|
96
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<JsDocApiPageComponent, "prism-jsdoc-api-page", never, { "page": { "alias": "page"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=jsdoc-api-page.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsdoc-api-page.component.d.ts","sourceRoot":"","sources":["../../src/api-page/jsdoc-api-page.component.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