Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Maki committed Apr 15, 2024
2 parents ac3b287 + 31942e1 commit 38cff14
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 35 deletions.
5 changes: 5 additions & 0 deletions .CodeLumiaignore
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,8 @@ LICENSE
*.sqlite
*.jpg
requirements.txt
LICENSE*
*.zip
environment.yml
*.svg
*.jpeg
3 changes: 2 additions & 1 deletion .SourceSageignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ build
tmp
.CodeLumiaignore
.ipynb
*.ipynb
*.ipynb
tmp
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ cython_debug/
SourceSageAssets
tmp

__CodeLumiai.md
__CodeLumiai.md
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ license: mit
<h3 align="center">
~Learn to Code, Step by Step~

[![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/MakiAi/CodeLumia)[![](https://img.shields.io/github/stars/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![](https://img.shields.io/github/last-commit/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![](https://img.shields.io/github/languages/top/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![GitHub Release](https://img.shields.io/github/v/release/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)
[![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/MakiAi/CodeLumia)[![](https://img.shields.io/github/stars/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![](https://img.shields.io/github/last-commit/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![](https://img.shields.io/github/languages/top/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![GitHub Release](https://img.shields.io/github/v/release/Sunwood-ai-labs/CodeLumia?sort=date&color=red)
](https://github.com/Sunwood-ai-labs/CodeLumia)


</h3>
Expand Down Expand Up @@ -55,18 +56,25 @@ CodeLumiaを使用して、プロジェクトのドキュメンテーション

## 更新履歴

### [[2024/04/15] CodeLumia v0.4.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.4.0)
- プレビュー機能の追加(ファイルツリー、マークダウン、プレーンテキスト)
- リポジトリのスキャンとマークダウンファイルの生成機能を強化
- ドキュメンテーションの改善とコードの可読性向上
- ファイル操作とGit操作のモジュールを改善

### [[2024/04/13] CodeLumia v0.3.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.3.0)
- アプリケーションの機能強化とドキュメントデザインの更新
- デモGIFの更新
- `.CodeLumiaignore`のフォーマット更新とリファクタリング
- READMEとSourceSageDocsの大幅な更新
- GIFファイルのGit LFSでの追跡と誤記修正
-

### [[2024/04/13] CodeLumia v0.2.0](https://github.com/Sunwood-ai-labs/CodeLumia/releases/tag/v0.2.0)
- コードのリファクタリングによる可読性と保守性の向上
- リポジトリのURLを入力してファイルツリーとコードを表示する機能追加
- ユーザーインターフェースの改善とドキュメンテーションの拡充
- CI/CDの設定とREADMEファイルの更新---
- CI/CDの設定とREADMEファイルの更新
-

### [2024/04/12] CodeLumia v0.1.0
- 初回リリース
Expand Down
49 changes: 30 additions & 19 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,43 @@
# リポジトリのURLを入力するテキストボックス
repo_url = st.text_input("リポジトリのURL:")
st.markdown("---")
st.markdown("[Full Text](#full-text)")
# st.markdown("[Full Text](#full-text)")

# .gitignoreのパターンを編集するサイドバー
st.sidebar.title(".CodeLumiaignore Patterns")
ignore_patterns = st.sidebar.text_area("Enter patterns (one per line):", value="\n".join(ignore_patterns), height=600).split("\n")
ignore_patterns = st.sidebar.text_area("Enter patterns (one per line):", value="\n".join(ignore_patterns), height=300).split("\n")
tmp_dir = st.sidebar.text_input('tmp_dir', '/tmp')
# 探索の最大深度を入力するテキストボックス
max_depth = st.sidebar.number_input("探索の最大深度:", min_value=1, value=2, step=1)
max_depth = st.sidebar.number_input("探索の最大深度:", min_value=1, value=1, step=1)

preview_markdown = st.sidebar.checkbox('preview markdown', value=False)
preview_plaintext = st.sidebar.checkbox('preview plaintext', value=False)
preview_tree = st.sidebar.checkbox('preview tree', value=True)

if repo_url:
repo_name = repo_url.split("/")[-1].split(".")[0]
repo_path = clone_repository(repo_url, repo_name)
if st.button("CodeLumia Run ...", type="primary"):
if repo_url:
repo_name = repo_url.split("/")[-1].split(".")[0]
with st.status("Scaning repository...", expanded=True):
st.write("clone repository...")
repo_path = clone_repository(repo_url, repo_name, tmp_dir=tmp_dir)
st.write("get file tree...")
file_tree = get_file_tree(repo_path, ignore_patterns, max_depth)
st.write("create markdown content...")
markdown_content = create_markdown_content(repo_name, file_tree, repo_path, ignore_patterns, max_depth)

file_tree = get_file_tree(repo_path, ignore_patterns, max_depth)
markdown_content = create_markdown_content(repo_name, file_tree, repo_path, ignore_patterns, max_depth)
# マークダウンファイルを保存
save_markdown_file(repo_name, markdown_content)
if(preview_tree):
st.code(f"{file_tree}")

# マークダウンファイルを保存
output_name = "/tmp/__CodeLumiai"
save_markdown_file(output_name, markdown_content)
# Streamlitアプリケーションの構築
if(preview_markdown):
st.markdown(markdown_content, unsafe_allow_html=True)

# Streamlitアプリケーションの構築
st.markdown(markdown_content, unsafe_allow_html=True)
# ダウンロードリンクの作成
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)

# ダウンロードリンクの作成
st.markdown(f'<a href="data:text/markdown;base64,{base64.b64encode(markdown_content.encode("utf-8")).decode("utf-8")}" download="{output_name}.md">Download Markdown File</a>', unsafe_allow_html=True)

st.markdown("---")
st.markdown("# Full Text")
st.code(markdown_content)
st.markdown("---")
if(preview_plaintext):
st.markdown("# Full Text")
st.code(markdown_content)
7 changes: 6 additions & 1 deletion docs/page_front.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
<h3 align="center">
~Learn to Code, Step by Step~

[![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/OFA-Sys/OFA-Image_Caption)[![](https://img.shields.io/github/stars/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![](https://img.shields.io/github/last-commit/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)[![](https://img.shields.io/github/languages/top/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)
[![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/OFA-Sys/OFA-Image_Caption)
[![](https://img.shields.io/github/stars/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)
[![](https://img.shields.io/github/last-commit/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)
[![](https://img.shields.io/github/languages/top/Sunwood-ai-labs/CodeLumia)](https://github.com/Sunwood-ai-labs/CodeLumia)
[![GitHub Release](https://img.shields.io/github/v/release/Sunwood-ai-labs/CodeLumia?sort=date&color=red)](https://github.com/Sunwood-ai-labs/CodeLumia)
[![GitHub Tag](https://img.shields.io/github/v/tag/Sunwood-ai-labs/CodeLumia?color=orange)](https://github.com/Sunwood-ai-labs/CodeLumia)

</h3>

Expand Down
27 changes: 24 additions & 3 deletions modules/file_operations.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import os
import fnmatch

Expand All @@ -7,12 +8,17 @@ def get_file_tree(repo_path, ignore_patterns, max_depth):
# .gitignoreに一致するディレクトリを無視
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]

level = root.replace(repo_path, "").count(os.sep)
level = root.replace(repo_path, "/").count(os.sep)
# print(f"------------------------- max_depth : {max_depth}")
# print(f"dirs1:{dirs}")
# print(f"level:{level}")
# print(f"files:{files}")
if level > max_depth:
continue

indent = " " * 4 * (level)
file_tree += f"{indent}{os.path.basename(root)}/\n"

subindent = " " * 4 * (level + 1)
for f in files:
# .gitignoreに一致するファイルを無視
Expand All @@ -26,7 +32,7 @@ def process_files(repo_path, ignore_patterns, max_depth):
# .gitignoreに一致するディレクトリを無視
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]

level = root.replace(repo_path, "").count(os.sep)
level = root.replace(repo_path, "/").count(os.sep)
if level > max_depth:
continue

Expand All @@ -37,4 +43,19 @@ def process_files(repo_path, ignore_patterns, max_depth):
with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
content = f.read()
file_contents.append((file_path.replace(f'{repo_path}/', ''), content))
return file_contents
return file_contents

if __name__ == "__main__":

repo_path = "tmp/DeepSeek-Math"
# .gitignoreのパターンを読み込む
ignore_patterns = []
if os.path.exists(".CodeLumiaignore"):
with open(".CodeLumiaignore", "r") as f:
for line in f:
line = line.strip()
if line and not line.startswith("#"):
ignore_patterns.append(line)
max_depth = 1
file_tree = get_file_tree(repo_path, ignore_patterns, max_depth)
print(file_tree)
25 changes: 18 additions & 7 deletions modules/git_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,32 @@
import shutil
import time

def clone_repository(repo_url, repo_name):
import os
import shutil
from git import Repo
import time

def clone_repository(repo_url, repo_name, tmp_dir="./tmp"):
# tmpフォルダを削除
# if os.path.exists("/tmp"):
# shutil.rmtree("/tmp")
# if os.path.exists(tmp_dir):
# shutil.rmtree(tmp_dir)

# tmpフォルダを作成
os.makedirs("/tmp", exist_ok=True)
os.makedirs(tmp_dir, exist_ok=True)

# リポジトリのクローン
repo_path = f"/tmp/{repo_name}"
repo_path = os.path.join(tmp_dir, repo_name)
if os.path.exists(repo_path):
shutil.rmtree(repo_path)
os.system(f"git clone {repo_url} {repo_path}")
Repo.clone_from(repo_url, repo_path)

# 一時的な遅延を追加
time.sleep(1)

return repo_path
return repo_path

if __name__ == "__main__":
repo_url = "https://github.com/deepseek-ai/DeepSeek-Math"
repo_name = repo_url.split("/")[-1].split(".")[0]
tmp_dir = "./tmp" # 必要に応じてtmpディレクトリを指定
clone_repository(repo_url, repo_name, tmp_dir)

0 comments on commit 38cff14

Please sign in to comment.