Skip to content

use: only_partial context #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions foliant/preprocessors/showcommits.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,13 @@ 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'):
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'])))
process_file_thread = threading.Thread(target=self.process_file,
args=[markdown_file_path])
process_file_thread.start()
Expand Down Expand Up @@ -392,6 +396,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')