Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
feat: add support for standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
bohoffi committed Dec 28, 2022
1 parent 069b81d commit 59033bf
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libs/ngx-doc-gen/src/common/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ export function getPipeName(classDoc: CategorizedClassDoc): string | undefined {
return undefined;
}

export function isStandalone(classDoc: CategorizedClassDoc): boolean {
if (classDoc.directiveMetadata) {
const standalone = classDoc.directiveMetadata.get('standalone');
return standalone != null && `${standalone}` !== 'false';
}
return false;
}

export function hasMemberDecorator(
doc: MemberDoc,
decoratorName: string
Expand Down
1 change: 1 addition & 0 deletions libs/ngx-doc-gen/src/common/dgeni-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface CategorizedClassDoc
CategorizedClassLikeDoc {
isDirective: boolean;
isPipe: boolean;
isStandalone: boolean;
isService: boolean;
isNgModule: boolean;
isTestHarness: boolean;
Expand Down
12 changes: 12 additions & 0 deletions libs/ngx-doc-gen/src/common/directive-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ArrayLiteralExpression,
BooleanLiteral,
CallExpression,
getDecorators,
isCallExpression,
Expand Down Expand Up @@ -87,6 +88,17 @@ export function getDirectiveMetadata(
(prop.initializer as StringLiteral).text
);
}

// Support BooleanLiteral assignments
if (
prop.initializer.kind === SyntaxKind.TrueKeyword ||
prop.initializer.kind === SyntaxKind.FalseKeyword
) {
resultMetadata.set(
prop.name.getText(),
prop.initializer.kind === SyntaxKind.TrueKeyword
);
}
}
);

Expand Down
3 changes: 3 additions & 0 deletions libs/ngx-doc-gen/src/processors/categorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
isNgModule,
isPipe,
getPipeName,
isStandalone,
} from '../common/decorators';
import {
CategorizedClassLikeDoc,
Expand Down Expand Up @@ -161,9 +162,11 @@ export class Categorizer implements Processor {
classDoc.isDirective = true;
classDoc.directiveExportAs = classDoc.directiveMetadata.get('exportAs');
classDoc.directiveSelectors = getDirectiveSelectors(classDoc);
classDoc.isStandalone = isStandalone(classDoc);
} else if (isPipe(classDoc) && classDoc.directiveMetadata) {
classDoc.isPipe = true;
classDoc.pipeName = getPipeName(classDoc);
classDoc.isStandalone = isStandalone(classDoc);
} else if (isService(classDoc)) {
classDoc.isService = true;
} else if (isNgModule(classDoc)) {
Expand Down
5 changes: 5 additions & 0 deletions libs/ngx-doc-gen/src/templates/class.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
<span class="docs-api-class-selector-label">Name:</span>
<span class="docs-api-class-selector-name">{$ class.pipeName $}</span>
</p>
{%- endif -%} {%- if class.isStandalone -%}
<p class="docs-api-directive-selectors">
<span class="docs-api-class-selector-label">Standalone:</span>
<span class="docs-api-class-selector-name">{$ class.isStandalone $}</span>
</p>
{%- endif -%} {%- if class.directiveExportAs -%}
<span class="docs-api-class-export-label">Exported as:</span>
<span class="docs-api-class-export-name">{$ class.directiveExportAs $}</span>
Expand Down

0 comments on commit 59033bf

Please sign in to comment.