Merge branch 'release/0.4.0'
Browse files- .CodeLumiaignore +5 -0
- .SourceSageignore +2 -1
- .gitignore +1 -1
- README.md +11 -3
- app.py +30 -19
- docs/page_front.md +6 -1
- modules/file_operations.py +24 -3
- modules/git_operations.py +18 -7
.CodeLumiaignore
CHANGED
@@ -173,3 +173,8 @@ LICENSE
|
|
173 |
*.sqlite
|
174 |
*.jpg
|
175 |
requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
173 |
*.sqlite
|
174 |
*.jpg
|
175 |
requirements.txt
|
176 |
+
LICENSE*
|
177 |
+
*.zip
|
178 |
+
environment.yml
|
179 |
+
*.svg
|
180 |
+
*.jpeg
|
.SourceSageignore
CHANGED
@@ -29,4 +29,5 @@ build
|
|
29 |
tmp
|
30 |
.CodeLumiaignore
|
31 |
.ipynb
|
32 |
-
*.ipynb
|
|
|
|
29 |
tmp
|
30 |
.CodeLumiaignore
|
31 |
.ipynb
|
32 |
+
*.ipynb
|
33 |
+
tmp
|
.gitignore
CHANGED
@@ -162,4 +162,4 @@ cython_debug/
|
|
162 |
SourceSageAssets
|
163 |
tmp
|
164 |
|
165 |
-
__CodeLumiai.md
|
|
|
162 |
SourceSageAssets
|
163 |
tmp
|
164 |
|
165 |
+
__CodeLumiai.md
|
README.md
CHANGED
@@ -18,7 +18,8 @@ license: mit
|
|
18 |
<h3 align="center">
|
19 |
~Learn to Code, Step by Step~
|
20 |
|
21 |
-
[](https://huggingface.co/spaces/MakiAi/CodeLumia)[](https://github.com/Sunwood-ai-labs/CodeLumia)[](https://github.com/Sunwood-ai-labs/CodeLumia)[](https://github.com/Sunwood-ai-labs/CodeLumia)[
|
|
|
22 |
|
23 |
|
24 |
</h3>
|
@@ -55,18 +56,25 @@ CodeLumiaを使用して、プロジェクトのドキュメンテーション
|
|
55 |
|
56 |
## 更新履歴
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
### [[2024/04/13] CodeLumia v0.3.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.3.0)
|
59 |
- アプリケーションの機能強化とドキュメントデザインの更新
|
60 |
- デモGIFの更新
|
61 |
- `.CodeLumiaignore`のフォーマット更新とリファクタリング
|
62 |
- READMEとSourceSageDocsの大幅な更新
|
63 |
- GIFファイルのGit LFSでの追跡と誤記修正
|
64 |
-
|
65 |
### [[2024/04/13] CodeLumia v0.2.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.2.0)
|
66 |
- コードのリファクタリングによる可読性と保守性の向上
|
67 |
- リポジトリのURLを入力してファイルツリーとコードを表示する機能追加
|
68 |
- ユーザーインターフェースの改善とドキュメンテーションの拡充
|
69 |
-
- CI/CDの設定とREADME
|
|
|
70 |
|
71 |
### [2024/04/12] CodeLumia v0.1.0
|
72 |
- 初回リリース
|
|
|
18 |
<h3 align="center">
|
19 |
~Learn to Code, Step by Step~
|
20 |
|
21 |
+
[](https://huggingface.co/spaces/MakiAi/CodeLumia)[](https://github.com/Sunwood-ai-labs/CodeLumia)[](https://github.com/Sunwood-ai-labs/CodeLumia)[](https://github.com/Sunwood-ai-labs/CodeLumia)[
|
22 |
+
](https://github.com/Sunwood-ai-labs/CodeLumia)
|
23 |
|
24 |
|
25 |
</h3>
|
|
|
56 |
|
57 |
## 更新履歴
|
58 |
|
59 |
+
### [[2024/04/15] CodeLumia v0.4.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.4.0)
|
60 |
+
- プレビュー機能の追加(ファイルツリー、マークダウン、プレーンテキスト)
|
61 |
+
- リポジトリのスキャンとマークダウンファイルの生成機能を強化
|
62 |
+
- ドキュメンテーションの改善とコードの可読性向上
|
63 |
+
- ファイル操作とGit操作のモジュールを改善
|
64 |
+
|
65 |
### [[2024/04/13] CodeLumia v0.3.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.3.0)
|
66 |
- アプリケーションの機能強化とドキュメントデザインの更新
|
67 |
- デモGIFの更新
|
68 |
- `.CodeLumiaignore`のフォーマット更新とリファクタリング
|
69 |
- READMEとSourceSageDocsの大幅な更新
|
70 |
- GIFファイルのGit LFSでの追跡と誤記修正
|
71 |
+
|
72 |
### [[2024/04/13] CodeLumia v0.2.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.2.0)
|
73 |
- コードのリファクタリングによる可読性と保守性の向上
|
74 |
- リポジトリのURLを入力してファイルツリーとコードを表示する機能追加
|
75 |
- ユーザーインターフェースの改善とドキュメンテーションの拡充
|
76 |
+
- CI/CDの設定とREADMEファイルの更新
|
77 |
+
-
|
78 |
|
79 |
### [2024/04/12] CodeLumia v0.1.0
|
80 |
- 初回リリース
|
app.py
CHANGED
@@ -25,32 +25,43 @@ st.markdown("---")
|
|
25 |
# リポジトリのURLを入力するテキストボックス
|
26 |
repo_url = st.text_input("リポジトリのURL:")
|
27 |
st.markdown("---")
|
28 |
-
st.markdown("[Full Text](#full-text)")
|
29 |
|
30 |
# .gitignoreのパターンを編集するサイドバー
|
31 |
st.sidebar.title(".CodeLumiaignore Patterns")
|
32 |
-
ignore_patterns = st.sidebar.text_area("Enter patterns (one per line):", value="\n".join(ignore_patterns), height=
|
|
|
33 |
# 探索の最大深度を入力するテキストボックス
|
34 |
-
max_depth = st.sidebar.number_input("探索の最大深度:", min_value=1, value=
|
35 |
|
|
|
|
|
|
|
36 |
|
37 |
-
if
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
|
42 |
-
|
|
|
|
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
|
49 |
-
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
st.markdown("# Full Text")
|
56 |
-
st.code(markdown_content)
|
|
|
25 |
# リポジトリのURLを入力するテキストボックス
|
26 |
repo_url = st.text_input("リポジトリのURL:")
|
27 |
st.markdown("---")
|
28 |
+
# st.markdown("[Full Text](#full-text)")
|
29 |
|
30 |
# .gitignoreのパターンを編集するサイドバー
|
31 |
st.sidebar.title(".CodeLumiaignore Patterns")
|
32 |
+
ignore_patterns = st.sidebar.text_area("Enter patterns (one per line):", value="\n".join(ignore_patterns), height=300).split("\n")
|
33 |
+
tmp_dir = st.sidebar.text_input('tmp_dir', '/tmp')
|
34 |
# 探索の最大深度を入力するテキストボックス
|
35 |
+
max_depth = st.sidebar.number_input("探索の最大深度:", min_value=1, value=1, step=1)
|
36 |
|
37 |
+
preview_markdown = st.sidebar.checkbox('preview markdown', value=False)
|
38 |
+
preview_plaintext = st.sidebar.checkbox('preview plaintext', value=False)
|
39 |
+
preview_tree = st.sidebar.checkbox('preview tree', value=True)
|
40 |
|
41 |
+
if st.button("CodeLumia Run ...", type="primary"):
|
42 |
+
if repo_url:
|
43 |
+
repo_name = repo_url.split("/")[-1].split(".")[0]
|
44 |
+
with st.status("Scaning repository...", expanded=True):
|
45 |
+
st.write("clone repository...")
|
46 |
+
repo_path = clone_repository(repo_url, repo_name, tmp_dir=tmp_dir)
|
47 |
+
st.write("get file tree...")
|
48 |
+
file_tree = get_file_tree(repo_path, ignore_patterns, max_depth)
|
49 |
+
st.write("create markdown content...")
|
50 |
+
markdown_content = create_markdown_content(repo_name, file_tree, repo_path, ignore_patterns, max_depth)
|
51 |
|
52 |
+
# マークダウンファイルを保存
|
53 |
+
save_markdown_file(repo_name, markdown_content)
|
54 |
+
if(preview_tree):
|
55 |
+
st.code(f"{file_tree}")
|
56 |
|
57 |
+
# Streamlitアプリケーションの構築
|
58 |
+
if(preview_markdown):
|
59 |
+
st.markdown(markdown_content, unsafe_allow_html=True)
|
60 |
|
61 |
+
# ダウンロードリンクの作成
|
62 |
+
st.markdown(f'<div align="center"><a href="data:text/markdown;base64,{base64.b64encode(markdown_content.encode("utf-8")).decode("utf-8")}" download="{repo_name}.md">Download Markdown File</a></div>', unsafe_allow_html=True)
|
63 |
|
64 |
+
st.markdown("---")
|
65 |
+
if(preview_plaintext):
|
66 |
+
st.markdown("# Full Text")
|
67 |
+
st.code(markdown_content)
|
|
|
|
docs/page_front.md
CHANGED
@@ -5,7 +5,12 @@
|
|
5 |
<h3 align="center">
|
6 |
~Learn to Code, Step by Step~
|
7 |
|
8 |
-
[](https://huggingface.co/spaces/OFA-Sys/OFA-Image_Caption)
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
</h3>
|
11 |
|
|
|
5 |
<h3 align="center">
|
6 |
~Learn to Code, Step by Step~
|
7 |
|
8 |
+
[](https://huggingface.co/spaces/OFA-Sys/OFA-Image_Caption)
|
9 |
+
[](https://github.com/Sunwood-ai-labs/CodeLumia)
|
10 |
+
[](https://github.com/Sunwood-ai-labs/CodeLumia)
|
11 |
+
[](https://github.com/Sunwood-ai-labs/CodeLumia)
|
12 |
+
[](https://github.com/Sunwood-ai-labs/CodeLumia)
|
13 |
+
[](https://github.com/Sunwood-ai-labs/CodeLumia)
|
14 |
|
15 |
</h3>
|
16 |
|
modules/file_operations.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import os
|
2 |
import fnmatch
|
3 |
|
@@ -7,12 +8,17 @@ def get_file_tree(repo_path, ignore_patterns, max_depth):
|
|
7 |
# .gitignoreに一致するディレクトリを無視
|
8 |
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
|
9 |
|
10 |
-
level = root.replace(repo_path, "").count(os.sep)
|
|
|
|
|
|
|
|
|
11 |
if level > max_depth:
|
12 |
continue
|
13 |
|
14 |
indent = " " * 4 * (level)
|
15 |
file_tree += f"{indent}{os.path.basename(root)}/\n"
|
|
|
16 |
subindent = " " * 4 * (level + 1)
|
17 |
for f in files:
|
18 |
# .gitignoreに一致するファイルを無視
|
@@ -26,7 +32,7 @@ def process_files(repo_path, ignore_patterns, max_depth):
|
|
26 |
# .gitignoreに一致するディレクトリを無視
|
27 |
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
|
28 |
|
29 |
-
level = root.replace(repo_path, "").count(os.sep)
|
30 |
if level > max_depth:
|
31 |
continue
|
32 |
|
@@ -37,4 +43,19 @@ def process_files(repo_path, ignore_patterns, max_depth):
|
|
37 |
with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
|
38 |
content = f.read()
|
39 |
file_contents.append((file_path.replace(f'{repo_path}/', ''), content))
|
40 |
-
return file_contents
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
import os
|
3 |
import fnmatch
|
4 |
|
|
|
8 |
# .gitignoreに一致するディレクトリを無視
|
9 |
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
|
10 |
|
11 |
+
level = root.replace(repo_path, "/").count(os.sep)
|
12 |
+
# print(f"------------------------- max_depth : {max_depth}")
|
13 |
+
# print(f"dirs1:{dirs}")
|
14 |
+
# print(f"level:{level}")
|
15 |
+
# print(f"files:{files}")
|
16 |
if level > max_depth:
|
17 |
continue
|
18 |
|
19 |
indent = " " * 4 * (level)
|
20 |
file_tree += f"{indent}{os.path.basename(root)}/\n"
|
21 |
+
|
22 |
subindent = " " * 4 * (level + 1)
|
23 |
for f in files:
|
24 |
# .gitignoreに一致するファイルを無視
|
|
|
32 |
# .gitignoreに一致するディレクトリを無視
|
33 |
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
|
34 |
|
35 |
+
level = root.replace(repo_path, "/").count(os.sep)
|
36 |
if level > max_depth:
|
37 |
continue
|
38 |
|
|
|
43 |
with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
|
44 |
content = f.read()
|
45 |
file_contents.append((file_path.replace(f'{repo_path}/', ''), content))
|
46 |
+
return file_contents
|
47 |
+
|
48 |
+
if __name__ == "__main__":
|
49 |
+
|
50 |
+
repo_path = "tmp/DeepSeek-Math"
|
51 |
+
# .gitignoreのパターンを読み込む
|
52 |
+
ignore_patterns = []
|
53 |
+
if os.path.exists(".CodeLumiaignore"):
|
54 |
+
with open(".CodeLumiaignore", "r") as f:
|
55 |
+
for line in f:
|
56 |
+
line = line.strip()
|
57 |
+
if line and not line.startswith("#"):
|
58 |
+
ignore_patterns.append(line)
|
59 |
+
max_depth = 1
|
60 |
+
file_tree = get_file_tree(repo_path, ignore_patterns, max_depth)
|
61 |
+
print(file_tree)
|
modules/git_operations.py
CHANGED
@@ -2,21 +2,32 @@ import os
|
|
2 |
import shutil
|
3 |
import time
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
6 |
# tmpフォルダを削除
|
7 |
-
# if os.path.exists(
|
8 |
-
# shutil.rmtree(
|
9 |
|
10 |
# tmpフォルダを作成
|
11 |
-
os.makedirs(
|
12 |
|
13 |
# リポジトリのクローン
|
14 |
-
repo_path =
|
15 |
if os.path.exists(repo_path):
|
16 |
shutil.rmtree(repo_path)
|
17 |
-
|
18 |
|
19 |
# 一時的な遅延を追加
|
20 |
time.sleep(1)
|
21 |
|
22 |
-
return repo_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import shutil
|
3 |
import time
|
4 |
|
5 |
+
import os
|
6 |
+
import shutil
|
7 |
+
from git import Repo
|
8 |
+
import time
|
9 |
+
|
10 |
+
def clone_repository(repo_url, repo_name, tmp_dir="./tmp"):
|
11 |
# tmpフォルダを削除
|
12 |
+
# if os.path.exists(tmp_dir):
|
13 |
+
# shutil.rmtree(tmp_dir)
|
14 |
|
15 |
# tmpフォルダを作成
|
16 |
+
os.makedirs(tmp_dir, exist_ok=True)
|
17 |
|
18 |
# リポジトリのクローン
|
19 |
+
repo_path = os.path.join(tmp_dir, repo_name)
|
20 |
if os.path.exists(repo_path):
|
21 |
shutil.rmtree(repo_path)
|
22 |
+
Repo.clone_from(repo_url, repo_path)
|
23 |
|
24 |
# 一時的な遅延を追加
|
25 |
time.sleep(1)
|
26 |
|
27 |
+
return repo_path
|
28 |
+
|
29 |
+
if __name__ == "__main__":
|
30 |
+
repo_url = "https://github.com/deepseek-ai/DeepSeek-Math"
|
31 |
+
repo_name = repo_url.split("/")[-1].split(".")[0]
|
32 |
+
tmp_dir = "./tmp" # 必要に応じてtmpディレクトリを指定
|
33 |
+
clone_repository(repo_url, repo_name, tmp_dir)
|