diff --git a/README.md b/README.md index 5df68e8..31cc935 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,16 @@ $ foliant src backup --config alternative_config.yml Also you may specify the root directory of your Foliant project by using the `--path` option. If not specified, current directory will be used. +## Partial build + +To use the partial build features (added in foliant 1.0.14), add `partial_build.yml` file, with the following structure: + +```yml +project_name: + - src/file_1.md + - src/dir/file_2.md +``` + ## RepoLink Preprocessor This preprocessor allows to add into each Markdown source a hyperlink to the related file in Git repository. Applying of the preprocessor to subprojects allows to get links to separate repositories from different pages of a single site (e.g. generated with MkDocs). diff --git a/changelog.md b/changelog.md index 93b3e8f..79c8aee 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +# 1.0.17 + +- Added the ability to transfer a list of files via `partial_build.yml`. + # 1.0.16 - Added a preprocessor for merging the includes maps diff --git a/foliant/config/from.py b/foliant/config/from.py index 8cf5436..109368f 100644 --- a/foliant/config/from.py +++ b/foliant/config/from.py @@ -11,7 +11,7 @@ ``https://github.com/foliant-docs/docs.git#master``. ''' -from yaml import add_constructor, load, Loader, BaseLoader +from yaml import add_constructor, load, Loader, BaseLoader, safe_load from shutil import copytree, move, rmtree from os import chdir, getcwd from pathlib import Path @@ -255,6 +255,19 @@ def _build_subproject(self, subproject_cached_dir_path: Path) -> str: break source_cwd = getcwd() + partial_build = [] + _partial_build_config = Path(source_cwd + "/partial_build.yml") + if _partial_build_config.exists(): + with open(_partial_build_config, 'r', encoding='utf-8') as file: + yaml_data = safe_load(file) + dir_name = subproject_cached_dir_path.name + if dir_name in yaml_data: + partial_build = yaml_data[dir_name] + else: + self.logger.debug(f'Subproject partial build list not found: {_partial_build_config}') + + self.logger.debug(f'Subproject partial build list: {partial_build}') + chdir(subproject_cached_dir_path) subproject_debug_mode = True if self.logger.getEffectiveLevel() == DEBUG else False @@ -269,6 +282,7 @@ def _build_subproject(self, subproject_cached_dir_path: Path) -> str: logs_dir=logs_dir_path, quiet=self.quiet, keep_tmp=True, + only_partial=','.join(partial_build), debug=subproject_debug_mode )