Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(parser): add Enumaration and Type parsers #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/model/class/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { OverviewNode } from './overview';
import { Type } from './type';
import { Param } from './param';

export type ClassKind = 'component' | 'class' | 'service' | 'directive' | 'interface' | 'ng-module' | 'HOC';
export type ClassKind = 'component' | 'class' | 'service' | 'directive' | 'interface' | 'ng-module' | 'HOC' | 'type' | 'enumeration';

export class Class {
/**
Expand Down
18 changes: 15 additions & 3 deletions src/typedoc.parser/typedoc.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export class TypedocParser {
this.findAllClasses(obj);

return this.classes
.filter((item: any) => this.isClass(item) || this.isInterface(item))
.filter((item: any) => item[CO.comment])
.filter((item: any) => this.isClass(item) || this.isInterface(item) || this.isEnumeration(item) || this.isType(item))
.filter((item: any) => item[CO.comment])
.map((item: any) => {
if (item[CO.decorators]) {
if (this.isComponent(item)) {
Expand All @@ -42,6 +42,10 @@ export class TypedocParser {
} else {
if (this.isInterface(item)) {
return this.parseClass(item, 'interface');
} else if (this.isEnumeration(item)) {
return this.parseClass(item, 'enumeration');
} else if (this.isType(item)) {
return this.parseClass(item, 'type');
} else {
return this.parseClass(item, 'class');
}
Expand All @@ -52,7 +56,7 @@ export class TypedocParser {
findAllClasses(obj: any) {
if (obj && obj[CO.children]) {
obj[CO.children].forEach((item: any) => {
if (this.isClass(item) || this.isInterface(item)) {
if (this.isClass(item) || this.isInterface(item) || this.isEnumeration(item) || this.isType(item)) {
this.classes.push(item);
} else {
this.findAllClasses(item);
Expand Down Expand Up @@ -85,6 +89,14 @@ export class TypedocParser {
return obj[CO.primKind] === 'Interface';
}

isEnumeration(obj: any) {
return obj[CO.primKind] === 'Enumeration';
}

isType(obj: any) {
return obj[CO.primKind] === 'Type alias';
}

isComponent(obj: any) {
return obj[CO.decorators][0][CO.name] === 'Component';
}
Expand Down