diff --git a/foliant/preprocessors/showcommits.py b/foliant/preprocessors/showcommits.py index 70a0169..a6d2e6e 100644 --- a/foliant/preprocessors/showcommits.py +++ b/foliant/preprocessors/showcommits.py @@ -360,13 +360,19 @@ def process_file(self, markdown_file_path): with open(markdown_file_path, 'w', encoding='utf8') as markdown_file: markdown_file.write(processed_markdown_content) - def process_all_files(self): + def process_all_files(self, list_of_files: list, project_path: str): threads = [] - for markdown_file_path in self.working_dir.rglob('*.md'): - process_file_thread = threading.Thread(target=self.process_file, - args=[markdown_file_path]) - process_file_thread.start() - threads.append(process_file_thread) + for markdown_file_path in list_of_files: + if isinstance(markdown_file_path, str): + markdown_file_path = Path(markdown_file_path) + if project_path: + markdown_file_path = Path(self.working_dir / markdown_file_path.relative_to(Path(project_path / self.config['src_dir']))) + + if markdown_file_path.suffix.lower() == ".md": + process_file_thread = threading.Thread(target=self.process_file, + args=[markdown_file_path]) + process_file_thread.start() + threads.append(process_file_thread) for thread in threads: thread.join() @@ -392,6 +398,9 @@ def apply(self): f'User-specified path does not exist, trying to use the default one: {self.repo_path}') self.repo_web_url = self._get_repo_web_url() - self.process_all_files() + if self.context['only_partial']: + self.process_all_files(self.context['only_partial'], self.project_path) + else: + self.process_all_files(self.working_dir.rglob('*.md'), "") self.logger.info('Preprocessor applied')