diff --git a/tools/dgeni/src/transforms/daffodil-api-package/configurator/output.ts b/tools/dgeni/src/transforms/daffodil-api-package/configurator/output.ts new file mode 100644 index 0000000000..eded9ab47f --- /dev/null +++ b/tools/dgeni/src/transforms/daffodil-api-package/configurator/output.ts @@ -0,0 +1,31 @@ +import { Package } from 'dgeni'; + +import { + DaffDocKind, + DAFF_DOC_KIND_PATH_SEGMENT_MAP, +} from '@daffodil/docs-utils'; + +import { GenerateApiListProcessor } from '../../../processors/generateApiList'; +import { Configurator } from '../../../utils/configurator.type'; + +export interface OutputPathsConfig { + kind: DaffDocKind; + outputPath: string; +} + +// TODO: combine with guide configurator +export const outputPathsConfigurator: Configurator = (config: OutputPathsConfig) => (pkg: Package) => pkg + .processor(new GenerateApiListProcessor()) + .config((generateApiList: GenerateApiListProcessor) => { + generateApiList.outputFolder = `${config.outputPath}/${DAFF_DOC_KIND_PATH_SEGMENT_MAP[config.kind]}`; + }) + .config((computePathsProcessor) => { + computePathsProcessor.pathTemplates.push({ + docTypes: ['package'], + getPath: (doc) => { + doc.moduleFolder = `${config.outputPath}/${DAFF_DOC_KIND_PATH_SEGMENT_MAP[config.kind]}/${doc.id}`; + return doc.moduleFolder; + }, + outputPathTemplate: '${moduleFolder}.json', + }); + }); diff --git a/tools/dgeni/src/transforms/daffodil-guides-package/helpers/configurator/input.ts b/tools/dgeni/src/transforms/daffodil-guides-package/helpers/configurator/input.ts new file mode 100644 index 0000000000..bbfcba2b53 --- /dev/null +++ b/tools/dgeni/src/transforms/daffodil-guides-package/helpers/configurator/input.ts @@ -0,0 +1,22 @@ +import { Package } from 'dgeni'; +import { Configurator } from 'tools/dgeni/src/utils/configurator.type'; + +import { + DaffDocKind, + DAFF_DOC_KIND_PATH_SEGMENT_MAP, +} from '@daffodil/docs-utils'; + +export interface InputPathsConfig { + kind: DaffDocKind; + inputPathBase: string; +} + +export const inputPathsConfigurator: Configurator = (config: InputPathsConfig) => (pkg: Package) => pkg + .config((readFilesProcessor) => { + readFilesProcessor.basePath = `${config.inputPathBase}/${DAFF_DOC_KIND_PATH_SEGMENT_MAP[config.kind]}`; + readFilesProcessor.sourceFiles = [ + { include: [ + '**/*.md', + ]}, + ]; + }); diff --git a/tools/dgeni/src/transforms/daffodil-guides-package/helpers/configurator/output.ts b/tools/dgeni/src/transforms/daffodil-guides-package/helpers/configurator/output.ts new file mode 100644 index 0000000000..985f36c100 --- /dev/null +++ b/tools/dgeni/src/transforms/daffodil-guides-package/helpers/configurator/output.ts @@ -0,0 +1,30 @@ +import { Package } from 'dgeni'; + +import { + DaffDocKind, + DAFF_DOC_KIND_PATH_SEGMENT_MAP, +} from '@daffodil/docs-utils'; + +import { Configurator } from '../../../../utils/configurator.type'; +import { GenerateGuideListProcessor } from '../../processors/generateGuideList'; + +export interface OutputPathsConfig { + kind: DaffDocKind; + outputPath: string; +} + +export const outputPathsConfigurator: Configurator = (config: OutputPathsConfig) => (pkg: Package) => pkg + .processor(new GenerateGuideListProcessor()) + .config((generateGuideList: GenerateGuideListProcessor) => { + generateGuideList.outputFolder = `${config.outputPath}/${DAFF_DOC_KIND_PATH_SEGMENT_MAP[config.kind]}`; + }) + .config((computePathsProcessor) => { + computePathsProcessor.pathTemplates.push({ + docTypes: ['guide'], + getPath: (doc) => { + doc.moduleFolder = `${config.outputPath}/${DAFF_DOC_KIND_PATH_SEGMENT_MAP[config.kind]}/${doc.id}`; + return `/${doc.moduleFolder}`; + }, + outputPathTemplate: '${moduleFolder}.json', + }); + }); diff --git a/tools/dgeni/src/transforms/daffodil-guides-package/helpers/configurator/path.ts b/tools/dgeni/src/transforms/daffodil-guides-package/helpers/configurator/path.ts new file mode 100644 index 0000000000..d8c4135fa1 --- /dev/null +++ b/tools/dgeni/src/transforms/daffodil-guides-package/helpers/configurator/path.ts @@ -0,0 +1,16 @@ +import { Package } from 'dgeni'; + +import { + InputPathsConfig, + inputPathsConfigurator, +} from './input'; +import { + OutputPathsConfig, + outputPathsConfigurator, +} from './output'; +import { Configurator } from '../../../../utils/configurator.type'; + +export type PathsConfig = InputPathsConfig & OutputPathsConfig; + +export const pathsConfigurator: Configurator = (config: PathsConfig) => (pkg: Package) => + outputPathsConfigurator(config)(inputPathsConfigurator(config)(pkg));