Update main.py
Browse files
main.py
CHANGED
@@ -38,13 +38,16 @@ class DirectoryStructureScanner:
|
|
38 |
return output
|
39 |
|
40 |
class MarkdownGenerator:
|
41 |
-
def __init__(self, target_path: str):
|
42 |
self.target_path = target_path
|
43 |
-
self.timestamp =
|
44 |
self.temp_dir = None
|
45 |
self.is_github = target_path.startswith(('http://', 'https://')) and 'github.com' in target_path
|
|
|
|
|
46 |
|
47 |
def generate_markdowns(self) -> Tuple[str, str, List[FileInfo]]:
|
|
|
48 |
try:
|
49 |
if self.is_github:
|
50 |
self.temp_dir = Path(tempfile.mkdtemp())
|
@@ -55,12 +58,15 @@ class MarkdownGenerator:
|
|
55 |
if not work_dir.exists():
|
56 |
raise ValueError(f"Directory not found: {work_dir}")
|
57 |
|
|
|
58 |
dir_scanner = DirectoryStructureScanner(work_dir)
|
59 |
tree_structure = dir_scanner.generate_tree()
|
60 |
|
61 |
-
|
|
|
62 |
files = file_scanner.scan_files()
|
63 |
|
|
|
64 |
structure_md = self._create_structure_markdown(tree_structure)
|
65 |
content_md = self._create_content_markdown(files)
|
66 |
|
|
|
38 |
return output
|
39 |
|
40 |
class MarkdownGenerator:
|
41 |
+
def __init__(self, target_path: str, target_extensions: Set[str] = None):
|
42 |
self.target_path = target_path
|
43 |
+
self.timestamp = Settings.get_timestamp()
|
44 |
self.temp_dir = None
|
45 |
self.is_github = target_path.startswith(('http://', 'https://')) and 'github.com' in target_path
|
46 |
+
# Settings.pyのデフォルト拡張子を使用
|
47 |
+
self.target_extensions = target_extensions or Settings.DEFAULT_EXTENSIONS
|
48 |
|
49 |
def generate_markdowns(self) -> Tuple[str, str, List[FileInfo]]:
|
50 |
+
"""リポジトリの内容とディレクトリ構造のMarkdownを生成"""
|
51 |
try:
|
52 |
if self.is_github:
|
53 |
self.temp_dir = Path(tempfile.mkdtemp())
|
|
|
58 |
if not work_dir.exists():
|
59 |
raise ValueError(f"Directory not found: {work_dir}")
|
60 |
|
61 |
+
# ディレクトリ構造のスキャン
|
62 |
dir_scanner = DirectoryStructureScanner(work_dir)
|
63 |
tree_structure = dir_scanner.generate_tree()
|
64 |
|
65 |
+
# ファイル内容のスキャン
|
66 |
+
file_scanner = FileScanner(work_dir, self.target_extensions)
|
67 |
files = file_scanner.scan_files()
|
68 |
|
69 |
+
# Markdown生成
|
70 |
structure_md = self._create_structure_markdown(tree_structure)
|
71 |
content_md = self._create_content_markdown(files)
|
72 |
|