Skip to content
Merged
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
11 changes: 10 additions & 1 deletion src/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Minimatch, IMinimatch } from 'minimatch';

import { Converter } from './converter/index';
import { Renderer } from './output/renderer';
import { Serializer } from './serialization';
import { ProjectReflection } from './models/index';
import { Logger, ConsoleLogger, CallbackLogger, PluginHost, writeFile } from './utils/index';

Expand Down Expand Up @@ -48,6 +49,11 @@ export class Application extends ChildableComponent<Application, AbstractCompone
*/
renderer: Renderer;

/**
* The serializer used to generate JSON output.
*/
serializer: Serializer;

/**
* The logger that should be used to output messages.
*/
Expand Down Expand Up @@ -92,6 +98,7 @@ export class Application extends ChildableComponent<Application, AbstractCompone

this.logger = new ConsoleLogger();
this.converter = this.addComponent<Converter>('converter', Converter);
this.serializer = this.addComponent<Serializer>('serializer', Serializer);
this.renderer = this.addComponent<Renderer>('renderer', Renderer);
this.plugins = this.addComponent('plugins', PluginHost);
this.options = this.addComponent('options', Options);
Expand Down Expand Up @@ -221,7 +228,9 @@ export class Application extends ChildableComponent<Application, AbstractCompone
}

out = Path.resolve(out);
writeFile(out, JSON.stringify(project.toObject(), null, '\t'), false);
const eventData = { outputDirectory: Path.dirname(out), outputFile: Path.basename(out) };
const ser = this.serializer.projectToObject(project, { begin: eventData, end: eventData });
writeFile(out, JSON.stringify(ser, null, '\t'), false);
this.logger.success('JSON written to %s', out);

return true;
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/ReflectionCategory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class ReflectionCategory {

/**
* Return a raw object representation of this reflection category.
* @deprecated Use serializers instead
*/
toObject(): any {
const result = {
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/ReflectionGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class ReflectionGroup {

/**
* Return a raw object representation of this reflection group.
* @deprecated Use serializers instead
*/
toObject(): any {
const result = {
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/comments/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export class Comment {

/**
* Return a raw object representation of this comment.
* @deprecated Use serializers instead
*/
toObject(): any {
const result: any = {};
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/comments/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class CommentTag {

/**
* Return a raw object representation of this tag.
* @deprecated Use serializers instead
*/
toObject(): any {
const result: any = {
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/reflections/abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ export abstract class Reflection {

/**
* Return a raw object representation of this reflection.
* @deprecated Use serializers instead
*/
toObject(): any {
const result: any = {
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/reflections/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class ContainerReflection extends Reflection {

/**
* Return a raw object representation of this reflection.
* @deprecated Use serializers instead
*/
toObject(): any {
const result = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/reflections/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export class DeclarationReflection extends ContainerReflection implements Defaul

/**
* Return a raw object representation of this reflection.
* @deprecated Use serializers instead
*/
toObject(): any {
let result = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/reflections/parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class ParameterReflection extends Reflection implements DefaultValueConta

/**
* Return a raw object representation of this reflection.
* @deprecated Use serializers instead
*/
toObject(): any {
const result = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/reflections/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export class ProjectReflection extends ContainerReflection {

/**
* Return a raw object representation of this reflection.
* @deprecated Use serializers instead
*/
toObject(): any {
const result = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/reflections/signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class SignatureReflection extends Reflection implements TypeContainer, Ty

/**
* Return a raw object representation of this reflection.
* @deprecated Use serializers instead
*/
toObject(): any {
const result = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/reflections/type-parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class TypeParameterReflection extends Reflection implements TypeContainer

/**
* Return a raw object representation of this reflection.
* @deprecated Use serializers instead
*/
toObject(): any {
const result = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/types/abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export abstract class Type {

/**
* Return a raw object representation of this type.
* @deprecated Use serializers instead
*/
toObject(): any {
let result: any = {};
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/types/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class ArrayType extends Type {

/**
* Return a raw object representation of this type.
* @deprecated Use serializers instead
*/
toObject(): any {
const result: any = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/types/intersection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class IntersectionType extends Type {

/**
* Return a raw object representation of this type.
* @deprecated Use serializers instead
*/
toObject(): any {
const result: any = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/types/intrinsic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class IntrinsicType extends Type {

/**
* Return a raw object representation of this type.
* @deprecated Use serializers instead
*/
toObject(): any {
const result: any = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/types/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class ReferenceType extends Type {

/**
* Return a raw object representation of this type.
* @deprecated Use serializers instead
*/
toObject(): any {
const result: any = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/types/reflection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class ReflectionType extends Type {

/**
* Return a raw object representation of this type.
* @deprecated Use serializers instead
*/
toObject(): any {
const result: any = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/types/string-literal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class StringLiteralType extends Type {

/**
* Return a raw object representation of this type.
* @deprecated Use serializers instead
*/
toObject(): any {
const result: any = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/types/tuple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class TupleType extends Type {

/**
* Return a raw object representation of this type.
* @deprecated Use serializers instead
*/
toObject(): any {
const result: any = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/types/type-parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class TypeParameterType extends Type {

/**
* Return a raw object representation of this type.
* @deprecated Use serializers instead
*/
toObject(): any {
const result: any = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/types/union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class UnionType extends Type {

/**
* Return a raw object representation of this type.
* @deprecated Use serializers instead
*/
toObject(): any {
const result: any = super.toObject();
Expand Down
1 change: 1 addition & 0 deletions src/lib/models/types/unknown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class UnknownType extends Type {

/**
* Return a raw object representation of this type.
* @deprecated Use serializers instead
*/
toObject(): any {
const result: any = super.toObject();
Expand Down
Loading