import { Processor , Document } from 'dgeni' ; export class ConvertToJsonProcessor implements Processor { name = 'convertToJson' ; $runBefore = [ 'writeFilesProcessor' ] ; docTypes = [ ] ; constructor ( public log , public createDocMessage ) { } $process ( docs ) { const docTypes = this . docTypes ; docs . forEach ( ( doc ) => { if ( docTypes . indexOf ( doc . docType ) !== - 1 ) { let contents = doc . renderedContent || '' ; let title = doc . title ; let tableOfContents = doc . tableOfContents ; if ( title === undefined ) { title = ( doc . vFile && doc . vFile . title ) ; } if ( title === undefined ) { title = doc . name ; } if ( title === undefined ) { title = '' ; this . log . warn ( this . createDocMessage ( 'Title property expected' , doc ) ) ; } doc . renderedContent = JSON . stringify ( { id : doc . path , title , contents , tableOfContents } , null , 2 ) ; } } ) ; } } ;