From 7c090ff8313d9cb1f2b70aedb93a8efb3016f447 Mon Sep 17 00:00:00 2001 From: Maxim Karpov Date: Mon, 9 Sep 2024 11:01:46 +0300 Subject: [PATCH] feat: add included option --- package-lock.json | 8 ++++---- package.json | 2 +- src/models.ts | 2 ++ src/resolvers/md2md.ts | 6 ++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 93375536..5ff75241 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "@diplodoc/mermaid-extension": "^1.2.1", "@diplodoc/openapi-extension": "^2.3.1", "@diplodoc/prettier-config": "^2.0.0", - "@diplodoc/transform": "^4.30.2", + "@diplodoc/transform": "^4.31.0", "@diplodoc/tsconfig": "^1.0.2", "@octokit/core": "4.2.4", "@types/async": "^3.2.15", @@ -2156,9 +2156,9 @@ } }, "node_modules/@diplodoc/transform": { - "version": "4.30.2", - "resolved": "https://registry.npmjs.org/@diplodoc/transform/-/transform-4.30.2.tgz", - "integrity": "sha512-bgEtOJHdlaUgrJPX7aWhEB7wzIDDTHbEDdlsfn8n0UYq8KYrHlnoydSan926269nKDluuMrnWT3z6AIDbFhvpQ==", + "version": "4.31.0", + "resolved": "https://registry.npmjs.org/@diplodoc/transform/-/transform-4.31.0.tgz", + "integrity": "sha512-SspM2Vqr2D1H4NDeqqIP2Bwpp7izTICKWlXGz7syGzzm2H8iIeaSR1a8Ck4S95jMuPmHy66TmB7niZDhK8tRag==", "dependencies": { "@diplodoc/cut-extension": "^0.2.5", "@diplodoc/tabs-extension": "^3.3.1", diff --git a/package.json b/package.json index 483e2b27..f43b66c8 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@diplodoc/mermaid-extension": "^1.2.1", "@diplodoc/openapi-extension": "^2.3.1", "@diplodoc/prettier-config": "^2.0.0", - "@diplodoc/transform": "^4.30.2", + "@diplodoc/transform": "^4.31.0", "@diplodoc/tsconfig": "^1.0.2", "@octokit/core": "4.2.4", "@types/async": "^3.2.15", diff --git a/src/models.ts b/src/models.ts index 902ea2b5..23756d70 100644 --- a/src/models.ts +++ b/src/models.ts @@ -66,6 +66,7 @@ interface YfmConfig { strict: boolean; ignoreStage: string; singlePage: boolean; + included: boolean; removeHiddenTocItems: boolean; vcs?: VCSConfiguration; connector?: VCSConnectorConfig; @@ -248,6 +249,7 @@ export interface PluginOptions { collectOfPlugins?: (input: string, options: PluginOptions) => string; changelogs?: ChangelogItem[]; extractChangelogs?: boolean; + included?: boolean; } export interface Plugin { diff --git a/src/resolvers/md2md.ts b/src/resolvers/md2md.ts index 180e0abb..42549360 100644 --- a/src/resolvers/md2md.ts +++ b/src/resolvers/md2md.ts @@ -13,7 +13,7 @@ import {enrichWithFrontMatter} from '../services/metadata'; export async function resolveMd2Md(options: ResolveMd2MdOptions): Promise { const {inputPath, outputPath, metadata: metadataOptions} = options; - const {input, output, changelogs: changelogsSetting} = ArgvService.getConfig(); + const {input, output, changelogs: changelogsSetting, included} = ArgvService.getConfig(); const resolvedInputPath = resolve(input, inputPath); const vars = getVarsPerFile(inputPath); @@ -36,6 +36,7 @@ export async function resolveMd2Md(options: ResolveMd2MdOptions): Promise vars: vars, log, copyFile, + included, }); writeFileSync(outputPath, result); @@ -83,7 +84,6 @@ function copyFile(targetPath: string, targetDestPath: string, options?: PluginOp if (options) { const sourceIncludeContent = readFileSync(targetPath, 'utf8'); const {result} = transformMd2Md(sourceIncludeContent, options); - writeFileSync(targetDestPath, result); } else { shell.cp(targetPath, targetDestPath); @@ -113,6 +113,7 @@ function transformMd2Md(input: string, options: PluginOptions) { collectOfPlugins, log: pluginLog, copyFile: pluginCopyFile, + included, } = options; let output = input; @@ -136,6 +137,7 @@ function transformMd2Md(input: string, options: PluginOptions) { collectOfPlugins, changelogs, extractChangelogs: Boolean(changelogsSetting), + included, }); }