Skip to content

Commit

Permalink
only grab files from main and app dir.
Browse files Browse the repository at this point in the history
  • Loading branch information
Krande committed Jan 11, 2024
1 parent c3410f4 commit 8a7d47f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/paradoc/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import os
import pathlib
import shutil
from itertools import chain
from typing import Callable, Dict

import pandas as pd

from paradoc.config import create_logger

from .common import (
MY_DEFAULT_HTML_CSS,
DocXFormat,
Expand Down Expand Up @@ -72,7 +72,7 @@ def __init__(
**kwargs,
):
self.source_dir = pathlib.Path().resolve().absolute() if source_dir is None else pathlib.Path(source_dir)
self.work_dir = pathlib.Path(work_dir) if work_dir is not None else pathlib.Path("")
self.work_dir = pathlib.Path(work_dir).resolve().absolute() if work_dir is not None else pathlib.Path("")
self.work_dir = self.work_dir.resolve().absolute()

self._main_prefix = main_prefix
Expand All @@ -98,7 +98,12 @@ def _setup(self, create_dirs, app_prefix, clean_build_dir):
os.makedirs(self.main_dir, exist_ok=True)
os.makedirs(self.app_dir, exist_ok=True)

for md_file_path in get_list_of_files(self.source_dir, ".md"):
main_dir_iter = get_list_of_files(self.main_dir, ".md")
app_dir_iter = get_list_of_files(self.app_dir, ".md")
# chain to single iterable
md_file_iter = chain(main_dir_iter, app_dir_iter)

for md_file_path in md_file_iter:
logger.info(f'Adding markdown file "{md_file_path}"')
is_appendix = True if app_prefix in md_file_path else False
md_file_path = pathlib.Path(md_file_path)
Expand Down Expand Up @@ -153,8 +158,8 @@ def compile(self, output_name, auto_open=False, metadata_file=None, export_forma
dest_file = (self.dist_dir / output_name).with_suffix(f".{export_format.value}").resolve().absolute()

print(f'Compiling OneDoc report to "{dest_file}"')
os.makedirs(self.build_dir, exist_ok=True)
os.makedirs(self.dist_dir, exist_ok=True)
self.build_dir.mkdir(exist_ok=True, parents=True)
self.dist_dir.mkdir(exist_ok=True, parents=True)

# Move all non-md files to temp dir because pandoc (tested on 2.19.2) struggles with external resource paths
for f in get_list_of_files(self.source_dir):
Expand Down

0 comments on commit 8a7d47f

Please sign in to comment.