import { Processor , DocCollection } from 'dgeni' ; /**
 * Extracts the title of a content file.
 * This processor assumes that the first line of the
 * content includes the title.
 */ export class ExtractContentTitleProcessor implements Processor { $runAfter = [ 'renderDocsProcessor' ] ; $runBefore = [ 'convertToJsonProcessor' ] ; $process ( docs ) { docs . forEach ( doc => { if ( doc . docType === 'content' ) { try { const firstLine = doc . content . split ( '\n' ) [ 0 ] ; const title = firstLine . replace ( /#/g , '' ) . trim ( ) ; doc . title = title ; } catch ( ex ) { } } } ) ; } } export function extractContentTitleProcessor ( ) { return new ExtractContentTitleProcessor ( ) ; }