{{prop.name}} |
Type: {{ prop.type }}
@@ -25,12 +25,12 @@ Properties
-
+
Methods
-
+
{{method.name}} |
Signature: {{ methodSignature(method) }}
diff --git a/libs/common-docs/src/lib/api-docs/api-doc-class/api-doc-class.component.ts b/libs/common-docs/src/lib/api-docs/api-doc-class/api-doc-class.component.ts
index 12eb0c76a9..f90a3a6141 100644
--- a/libs/common-docs/src/lib/api-docs/api-doc-class/api-doc-class.component.ts
+++ b/libs/common-docs/src/lib/api-docs/api-doc-class/api-doc-class.component.ts
@@ -20,7 +20,7 @@ import { ComponentApi } from '../../models/components-api.model';
})
export class NgApiDocClassComponent {
headerAnchor?: string;
- apiDocs: ClassDesc;
+ apiDocs?: ClassDesc;
private analytics: Analytics;
private docs: NgApiDoc;
@@ -30,7 +30,9 @@ export class NgApiDocClassComponent {
this.analytics = analytics;
this.headerAnchor = content.anchor;
- this.apiDocs = this.docs[content.title];
+ if (content?.title) {
+ this.apiDocs = this.docs[content.title];
+ }
}
methodSignature(method: MethodDesc): string {
@@ -38,6 +40,6 @@ export class NgApiDocClassComponent {
}
trackSourceClick(): void {
- this.analytics.trackEvent('Source File View', this.apiDocs.className);
+ this.analytics.trackEvent('Source File View', this.apiDocs?.className);
}
}
diff --git a/libs/common-docs/src/lib/api-docs/api-doc-config/api-doc-config.component.html b/libs/common-docs/src/lib/api-docs/api-doc-config/api-doc-config.component.html
index e213fe531c..cab5041ebb 100644
--- a/libs/common-docs/src/lib/api-docs/api-doc-config/api-doc-config.component.html
+++ b/libs/common-docs/src/lib/api-docs/api-doc-config/api-doc-config.component.html
@@ -1,16 +1,16 @@
-
+
-
+
Properties
-
+
{{ prop.name }} |
Type: {{ prop.type }}
@@ -25,12 +25,12 @@ Properties
-
+
Methods
-
+
{{ method.name }} |
diff --git a/libs/common-docs/src/lib/api-docs/api-doc-config/api-doc-config.component.ts b/libs/common-docs/src/lib/api-docs/api-doc-config/api-doc-config.component.ts
index 1249cf4707..cd2a2f0394 100644
--- a/libs/common-docs/src/lib/api-docs/api-doc-config/api-doc-config.component.ts
+++ b/libs/common-docs/src/lib/api-docs/api-doc-config/api-doc-config.component.ts
@@ -24,7 +24,7 @@ const CONFIG_SUFFIX_LENGTH = 'Config'.length;
templateUrl: './api-doc-config.component.html'
})
export class NgApiDocConfigComponent {
- apiDocs: ClassDesc;
+ apiDocs?: ClassDesc;
directiveName?: string;
headerAnchor?: string;
isShowMethods = false;
@@ -37,12 +37,14 @@ export class NgApiDocConfigComponent {
this.docs = docs;
this.headerAnchor = content.anchor;
- this.apiDocs = this.docs[content.title];
+ if (content?.title) {
+ this.apiDocs = this.docs[content.title];
+ }
this.isShowMethods = content.showMethods || this.isShowMethods;
this.directiveName = content.title?.slice(0, -CONFIG_SUFFIX_LENGTH);
}
trackSourceClick(): void {
- this.analytics.trackEvent('Source File View', this.apiDocs.className);
+ this.analytics.trackEvent('Source File View', this.apiDocs?.className);
}
}
diff --git a/libs/common-docs/src/lib/api-docs/api-doc/api-doc.component.html b/libs/common-docs/src/lib/api-docs/api-doc/api-doc.component.html
index eba57a1ca1..ee98693baa 100644
--- a/libs/common-docs/src/lib/api-docs/api-doc/api-doc.component.html
+++ b/libs/common-docs/src/lib/api-docs/api-doc/api-doc.component.html
@@ -1,32 +1,32 @@
-
+
Selector |
- {{ apiDocs.selector }} |
+ {{ apiDocs?.selector }} |
-
+
Exported as |
- {{ apiDocs.exportAs }} |
+ {{ apiDocs?.exportAs }} |
-
+
Inputs
-
+
{{ input.name }} |
Type: {{ input.type }}
@@ -36,7 +36,7 @@ Inputs
— initialized from {{ configServiceName }} service
-
+
|
@@ -45,15 +45,15 @@ Inputs
-
+
Outputs
-
+
{{ output.name }} |
- |
+ |
@@ -61,18 +61,18 @@ Outputs
-
+
Methods
-
+
{{ method.name }} |
Signature: {{ methodSignature(method) }}
Return type: {{ method.returnType }}
-
+
|
diff --git a/libs/common-docs/src/lib/api-docs/api-doc/api-doc.component.ts b/libs/common-docs/src/lib/api-docs/api-doc/api-doc.component.ts
index 0f18c85f92..8666fa969c 100644
--- a/libs/common-docs/src/lib/api-docs/api-doc/api-doc.component.ts
+++ b/libs/common-docs/src/lib/api-docs/api-doc/api-doc.component.ts
@@ -7,6 +7,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ComponentApi } from '../../models/components-api.model';
import { Analytics } from '../analytics/analytics';
import { ClassDesc, DirectiveDesc, InputDesc, MethodDesc, NgApiDoc, PropertyDesc, signature } from '../api-docs.model';
+import { DomSanitizer } from '@angular/platform-browser';
/**
* Displays the API docs of a directive.
@@ -23,8 +24,8 @@ import { ClassDesc, DirectiveDesc, InputDesc, MethodDesc, NgApiDoc, PropertyDesc
templateUrl: './api-doc.component.html'
})
export class NgApiDocComponent {
- apiDocs: DirectiveDesc;
- configServiceName: string;
+ apiDocs?: DirectiveDesc;
+ configServiceName?: string;
headerAnchor: string | undefined;
/**
@@ -32,24 +33,30 @@ export class NgApiDocComponent {
* service (if any)
*/
- private configProperties: { [propertyName: string]: PropertyDesc };
+ private configProperties?: { [propertyName: string]: PropertyDesc };
private analytics: Analytics;
private docs: NgApiDoc;
- constructor(analytics: Analytics, docs: NgApiDoc, content: ComponentApi) {
+ constructor(analytics: Analytics, docs: NgApiDoc, content: ComponentApi, private sanitizer: DomSanitizer) {
this.analytics = analytics;
// todo: inject docs
this.docs = docs;
-
this.headerAnchor = content.anchor;
- this.apiDocs = this.docs[content.title];
- this.configServiceName = `${content.title}Config`;
- const configApiDocs = this.docs[this.configServiceName];
- this.configProperties = {};
- if (configApiDocs) {
- this.apiDocs.inputs.forEach(
- (input: InputDesc) => (this.configProperties[input.name] = this.findInputConfigProperty(configApiDocs, input))
- );
+ if (content?.title) {
+ this.apiDocs = this.docs[content.title];
+ this.configServiceName = `${content.title}Config`;
+ const configApiDocs = this.docs[this.configServiceName];
+ this.configProperties = {};
+ if (configApiDocs) {
+ this.apiDocs?.inputs.forEach(
+ (input: InputDesc) => {
+ if (this.configProperties && this.configProperties[input.name]) {
+ this.configProperties[input.name] = this.findInputConfigProperty(configApiDocs, input);
+ }
+ }
+ );
+ }
+ this.checkSecurApiDocs();
}
}
@@ -58,7 +65,7 @@ export class NgApiDocComponent {
* property. If there is no matching config property, it reads it from the input.
*/
defaultInputValue(input: InputDesc): string | undefined {
- const configProperty = this.configProperties[input.name];
+ const configProperty = this.configProperties?.[input.name];
return configProperty ? configProperty.defaultValue : input.defaultValue;
}
@@ -67,7 +74,7 @@ export class NgApiDocComponent {
* Returns true if there is a config service property matching with the given directive input
*/
hasConfigProperty(input: InputDesc): boolean {
- return !!this.configProperties[input.name];
+ return !!this.configProperties?.[input.name];
}
methodSignature(method: MethodDesc): string {
@@ -75,10 +82,44 @@ export class NgApiDocComponent {
}
trackSourceClick(): void {
- this.analytics.trackEvent('Source File View', this.apiDocs.className);
+ this.analytics.trackEvent('Source File View', this.apiDocs?.className);
}
private findInputConfigProperty(configApiDocs: ClassDesc, input: InputDesc): PropertyDesc {
return configApiDocs.properties.filter((prop: PropertyDesc) => prop.name === input.name)[0];
}
+
+ checkSecurApiDocs(): void {
+ if (!this.apiDocs) {
+ return;
+ }
+
+ if (this.apiDocs?.description) {
+ this.apiDocs.descriptionSafeHtML = this.sanitizer.bypassSecurityTrustHtml(this.apiDocs.description);
+ }
+
+ if (this.apiDocs?.inputs?.length) {
+ this.apiDocs.inputs.map(input => {
+ if (input.description) {
+ input.descriptionSafeHtml = this.sanitizer.bypassSecurityTrustHtml(input.description);
+ }
+ });
+ }
+
+ if (this.apiDocs?.outputs?.length) {
+ this.apiDocs.outputs.map(output => {
+ if (output.description) {
+ output.descriptionSafeHtml = this.sanitizer.bypassSecurityTrustHtml(output.description);
+ }
+ });
+ }
+
+ if (this.apiDocs?.methods?.length) {
+ this.apiDocs.methods.map(method => {
+ if (method.description) {
+ method.descriptionSafeHtml = this.sanitizer.bypassSecurityTrustHtml(method.description);
+ }
+ });
+ }
+ }
}
diff --git a/libs/common-docs/src/lib/api-docs/api-docs.model.ts b/libs/common-docs/src/lib/api-docs/api-docs.model.ts
index 605ecb7ca8..8376b29016 100644
--- a/libs/common-docs/src/lib/api-docs/api-docs.model.ts
+++ b/libs/common-docs/src/lib/api-docs/api-docs.model.ts
@@ -2,10 +2,13 @@
* @author ng-team
* @copyright ng-bootstrap
*/
+import { SafeHtml } from '@angular/platform-browser';
+
export interface ClassDesc {
fileName: string;
className: string;
description: string;
+ descriptionSafeHtML?: SafeHtml;
properties: PropertyDesc[];
methods: MethodDesc[];
}
@@ -22,11 +25,13 @@ export interface PropertyDesc {
type: string;
description: string;
defaultValue?: string;
+ descriptionSafeHtml?: SafeHtml;
}
export interface MethodDesc {
name: string;
description: string;
+ descriptionSafeHtml?: SafeHtml;
args: ArgumentDesc[];
returnType: string;
}
diff --git a/libs/common-docs/src/lib/common/add-nav/add-nav.component.html b/libs/common-docs/src/lib/common/add-nav/add-nav.component.html
index ef288cdc91..967e7f6040 100644
--- a/libs/common-docs/src/lib/common/add-nav/add-nav.component.html
+++ b/libs/common-docs/src/lib/common/add-nav/add-nav.component.html
@@ -1,7 +1,7 @@
- | | | |