license import { Package } from 'dgeni' ; import * as path from 'path' ; const basePackage = require ( 'dgeni-packages/base' ) ; const nunjucksPackage = require ( 'dgeni-packages/nunjucks' ) ; import { PROJECT_ROOT , DOCS_OUTPUT_PATH , TEMPLATES_PATH } from '../config' ; import { ConvertToJsonProcessor } from '../../processors/convertToJson' ; export const daffodilBasePackage = new Package ( 'daffodil-base' , [ basePackage , nunjucksPackage , ] ) . processor ( 'convertToJson' , function ( log , createDocMessage ) { return new ConvertToJsonProcessor ( log , createDocMessage ) ; } ) . factory ( 'packageInfo' , function ( ) { return require ( path . resolve ( PROJECT_ROOT , 'package.json' ) ) ; } ) . config ( function ( readFilesProcessor ) { readFilesProcessor . basePath = PROJECT_ROOT ; readFilesProcessor . fileReaders = [ ] ; readFilesProcessor . sourceFiles = [ ] ; } ) . config ( function ( writeFilesProcessor ) { writeFilesProcessor . outputFolder = DOCS_OUTPUT_PATH ; } ) . config ( function ( renderDocsProcessor , templateFinder , templateEngine ) { templateFinder . templateFolders = [ TEMPLATES_PATH ] ; templateFinder . templatePatterns = [ '${ doc.template }' , '${ doc.id }.${ doc.docType }.template.html' , '${ doc.id }.template.html' , '${ doc.docType }.template.html' , '${ doc.id }.${ doc.docType }.template.js' , '${ doc.id }.template.js' , '${ doc.docType }.template.js' , '${ doc.id }.${ doc.docType }.template.json' , '${ doc.id }.template.json' , '${ doc.docType }.template.json' , 'common.template.html' , ] ; templateEngine . config . tags = { variableStart : '{$' , variableEnd : '$}' } ; renderDocsProcessor . helpers . relativePath = function ( from , to ) { return path . relative ( from , to ) ; } ; } ) ;