Merge branch 'release/v0.1.0'
Browse files- .CodeLumiaignore +170 -0
- .SourceSageignore +30 -0
- .gitattributes +1 -0
- CodeLumia.md +66 -0
- Dockerfile +16 -0
- README.md +95 -2
- app.py +49 -4
- docker-compose.yml +9 -0
- docs/language_map.json +27 -0
- docs/page_front.md +12 -0
- modules/file_operations.py +32 -0
- modules/git_operations.py +22 -0
- modules/markdown_operations.py +37 -0
- requirements.txt +1 -0
.CodeLumiaignore
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
share/python-wheels/
|
24 |
+
*.egg-info/
|
25 |
+
.installed.cfg
|
26 |
+
*.egg
|
27 |
+
MANIFEST
|
28 |
+
|
29 |
+
# PyInstaller
|
30 |
+
# Usually these files are written by a python script from a template
|
31 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
32 |
+
*.manifest
|
33 |
+
*.spec
|
34 |
+
|
35 |
+
# Installer logs
|
36 |
+
pip-log.txt
|
37 |
+
pip-delete-this-directory.txt
|
38 |
+
|
39 |
+
# Unit test / coverage reports
|
40 |
+
htmlcov/
|
41 |
+
.tox/
|
42 |
+
.nox/
|
43 |
+
.coverage
|
44 |
+
.coverage.*
|
45 |
+
.cache
|
46 |
+
nosetests.xml
|
47 |
+
coverage.xml
|
48 |
+
*.cover
|
49 |
+
*.py,cover
|
50 |
+
.hypothesis/
|
51 |
+
.pytest_cache/
|
52 |
+
cover/
|
53 |
+
|
54 |
+
# Translations
|
55 |
+
*.mo
|
56 |
+
*.pot
|
57 |
+
|
58 |
+
# Django stuff:
|
59 |
+
*.log
|
60 |
+
local_settings.py
|
61 |
+
db.sqlite3
|
62 |
+
db.sqlite3-journal
|
63 |
+
|
64 |
+
# Flask stuff:
|
65 |
+
instance/
|
66 |
+
.webassets-cache
|
67 |
+
|
68 |
+
# Scrapy stuff:
|
69 |
+
.scrapy
|
70 |
+
|
71 |
+
# Sphinx documentation
|
72 |
+
docs/_build/
|
73 |
+
|
74 |
+
# PyBuilder
|
75 |
+
.pybuilder/
|
76 |
+
target/
|
77 |
+
|
78 |
+
# Jupyter Notebook
|
79 |
+
.ipynb_checkpoints
|
80 |
+
|
81 |
+
# IPython
|
82 |
+
profile_default/
|
83 |
+
ipython_config.py
|
84 |
+
|
85 |
+
# pyenv
|
86 |
+
# For a library or package, you might want to ignore these files since the code is
|
87 |
+
# intended to run in multiple environments; otherwise, check them in:
|
88 |
+
# .python-version
|
89 |
+
|
90 |
+
# pipenv
|
91 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
92 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
93 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
94 |
+
# install all needed dependencies.
|
95 |
+
#Pipfile.lock
|
96 |
+
|
97 |
+
# poetry
|
98 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
99 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
100 |
+
# commonly ignored for libraries.
|
101 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
102 |
+
#poetry.lock
|
103 |
+
|
104 |
+
# pdm
|
105 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
106 |
+
#pdm.lock
|
107 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
108 |
+
# in version control.
|
109 |
+
# https://pdm.fming.dev/#use-with-ide
|
110 |
+
.pdm.toml
|
111 |
+
|
112 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
113 |
+
__pypackages__/
|
114 |
+
|
115 |
+
# Celery stuff
|
116 |
+
celerybeat-schedule
|
117 |
+
celerybeat.pid
|
118 |
+
|
119 |
+
# SageMath parsed files
|
120 |
+
*.sage.py
|
121 |
+
|
122 |
+
# Environments
|
123 |
+
.env
|
124 |
+
.venv
|
125 |
+
env/
|
126 |
+
venv/
|
127 |
+
ENV/
|
128 |
+
env.bak/
|
129 |
+
venv.bak/
|
130 |
+
|
131 |
+
# Spyder project settings
|
132 |
+
.spyderproject
|
133 |
+
.spyproject
|
134 |
+
|
135 |
+
# Rope project settings
|
136 |
+
.ropeproject
|
137 |
+
|
138 |
+
# mkdocs documentation
|
139 |
+
/site
|
140 |
+
|
141 |
+
# mypy
|
142 |
+
.mypy_cache/
|
143 |
+
.dmypy.json
|
144 |
+
dmypy.json
|
145 |
+
|
146 |
+
# Pyre type checker
|
147 |
+
.pyre/
|
148 |
+
|
149 |
+
# pytype static type analyzer
|
150 |
+
.pytype/
|
151 |
+
|
152 |
+
# Cython debug symbols
|
153 |
+
cython_debug/
|
154 |
+
|
155 |
+
# PyCharm
|
156 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
157 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
158 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
159 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
160 |
+
#.idea/
|
161 |
+
|
162 |
+
SourceSageAssets
|
163 |
+
|
164 |
+
.git
|
165 |
+
.CodeLumiaignore
|
166 |
+
.gitattributes
|
167 |
+
.gitignore
|
168 |
+
LICENSE
|
169 |
+
.github
|
170 |
+
*.png
|
.SourceSageignore
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.git
|
2 |
+
__pycache__
|
3 |
+
LICENSE
|
4 |
+
output.md
|
5 |
+
assets
|
6 |
+
Style-Bert-VITS2
|
7 |
+
output
|
8 |
+
streamlit
|
9 |
+
SourceSage.md
|
10 |
+
data
|
11 |
+
.gitignore
|
12 |
+
.SourceSageignore
|
13 |
+
*.png
|
14 |
+
Changelog
|
15 |
+
SourceSageAssets
|
16 |
+
SourceSageAssetsDemo
|
17 |
+
__pycache__
|
18 |
+
.pyc
|
19 |
+
**/__pycache__/**
|
20 |
+
modules\__pycache__
|
21 |
+
.svg
|
22 |
+
sourcesage.egg-info
|
23 |
+
.pytest_cache
|
24 |
+
dist
|
25 |
+
build
|
26 |
+
|
27 |
+
.gitattributes
|
28 |
+
.CodeLumiaignore
|
29 |
+
tmp
|
30 |
+
.CodeLumiaignore
|
.gitattributes
CHANGED
@@ -1 +1,2 @@
|
|
1 |
*.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
1 |
*.png filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
CodeLumia.md
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# << CodeLumia>>
|
2 |
+
## CodeLumia File Tree
|
3 |
+
|
4 |
+
```
|
5 |
+
CodeLumia/
|
6 |
+
app.py
|
7 |
+
README.md
|
8 |
+
docs/
|
9 |
+
SourceSageDocs.md
|
10 |
+
|
11 |
+
```
|
12 |
+
|
13 |
+
## app.py
|
14 |
+
|
15 |
+
```python
|
16 |
+
# sample code
|
17 |
+
|
18 |
+
import streamlit as st
|
19 |
+
|
20 |
+
x = st.slider('Select a value')
|
21 |
+
st.write(x, 'squared is', x * x)
|
22 |
+
```
|
23 |
+
|
24 |
+
## README.md
|
25 |
+
|
26 |
+
```markdown
|
27 |
+
---
|
28 |
+
title: CodeLumia
|
29 |
+
emoji: 📚
|
30 |
+
colorFrom: purple
|
31 |
+
colorTo: blue
|
32 |
+
sdk: streamlit
|
33 |
+
sdk_version: 1.33.0
|
34 |
+
app_file: app.py
|
35 |
+
pinned: false
|
36 |
+
license: mit
|
37 |
+
---
|
38 |
+
|
39 |
+
|
40 |
+
<p align="center">
|
41 |
+
<img src="https://media.githubusercontent.com/media/Sunwood-ai-labs/CodeLumia/main/docs/CodeLumia_icon.png" width="50%">
|
42 |
+
<br>
|
43 |
+
<h1 align="center">CodeLumia</h1>
|
44 |
+
<h3 align="center">
|
45 |
+
~Learn to Code, Step by Step~
|
46 |
+
|
47 |
+
[](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)
|
48 |
+
|
49 |
+
</h3>
|
50 |
+
|
51 |
+
</p>
|
52 |
+
|
53 |
+
|
54 |
+
```
|
55 |
+
|
56 |
+
## docs/SourceSageDocs.md
|
57 |
+
|
58 |
+
```markdown
|
59 |
+
# SourceSageDocs
|
60 |
+
|
61 |
+
```bash
|
62 |
+
|
63 |
+
sourcesage --repository CodeLumia --owner Sunwood-ai-labs
|
64 |
+
```
|
65 |
+
```
|
66 |
+
|
Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.12-slim
|
2 |
+
|
3 |
+
WORKDIR /app
|
4 |
+
|
5 |
+
RUN apt-get update && \
|
6 |
+
apt-get install -y git && \
|
7 |
+
rm -rf /var/lib/apt/lists/*
|
8 |
+
|
9 |
+
COPY requirements.txt .
|
10 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
11 |
+
|
12 |
+
COPY . .
|
13 |
+
|
14 |
+
EXPOSE 8501
|
15 |
+
|
16 |
+
CMD ["streamlit", "run", "app.py"]
|
README.md
CHANGED
@@ -3,8 +3,8 @@ title: CodeLumia
|
|
3 |
emoji: 📚
|
4 |
colorFrom: purple
|
5 |
colorTo: blue
|
6 |
-
sdk:
|
7 |
-
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
@@ -24,3 +24,96 @@ license: mit
|
|
24 |
|
25 |
</p>
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
emoji: 📚
|
4 |
colorFrom: purple
|
5 |
colorTo: blue
|
6 |
+
sdk: docker
|
7 |
+
app_port: 8501
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
|
|
24 |
|
25 |
</p>
|
26 |
|
27 |
+
|
28 |
+
## 🚀 はじめに
|
29 |
+
|
30 |
+
|
31 |
+
CodeLumiaへようこそ!CodeLumiaは、GitHubリポジトリのソースコードを分析し、包括的なマークダウン形式のドキュメントを自動生成するツールです。プロジェクトの構造、依存関係、設定などを簡単に理解できるようになります。
|
32 |
+
|
33 |
+
CodeLumiaは、開発者がコードベースをすばやく把握し、プロジェクトに効率的に貢献できるようにすることを目的としています。新しいチームメンバーのオンボーディングを容易にし、コードの保守性を向上させます。
|
34 |
+
|
35 |
+
>[!TIP]
|
36 |
+
>このリポジトリは[SourceSage](https://github.com/Sunwood-ai-labs/SourceSage)を活用しており、リリースノートやREADME、コミットメッセージの9割は[SourceSage](https://github.com/Sunwood-ai-labs/SourceSage) + [claude.ai](https://claude.ai/)で生成しています。
|
37 |
+
|
38 |
+
### 主な特徴:
|
39 |
+
|
40 |
+
- GitHubリポジトリの自動分析
|
41 |
+
- マークダウン形式のドキュメント生成
|
42 |
+
- ファイルとディレクトリの無視パターンのカスタマイズ
|
43 |
+
- わかりやすいStreamlitユーザーインターフェース
|
44 |
+
|
45 |
+
CodeLumiaを使用して、プロジェクトのドキュメンテーションを強化し、チームのコラボレーションを促進しましょう。ぜひお試しください!
|
46 |
+
|
47 |
+
|
48 |
+
## デモアプリ
|
49 |
+
|
50 |
+
[](https://huggingface.co/spaces/OFA-Sys/OFA-Image_Caption)
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
### 前提条件
|
55 |
+
|
56 |
+
- Docker
|
57 |
+
- Docker Compose
|
58 |
+
|
59 |
+
### インストール
|
60 |
+
|
61 |
+
1. リポジトリをクローンします:
|
62 |
+
```bash
|
63 |
+
git clone https://github.com/Sunwood-ai-labs/CodeLumia.git
|
64 |
+
cd CodeLumia
|
65 |
+
```
|
66 |
+
|
67 |
+
2. Dockerコンテナをビルドして実行します:
|
68 |
+
```bash
|
69 |
+
docker-compose up --build
|
70 |
+
```
|
71 |
+
|
72 |
+
3. ブラウザで `http://localhost:8501` にアクセスしてアプリケーションを開きます。
|
73 |
+
|
74 |
+
## 📖 使い方
|
75 |
+
|
76 |
+
1. 分析したいGitHubリポジトリのURLをテキスト入力フィールドに入力します。
|
77 |
+
2. アプリケーションがリポジトリをクローンし、ファイルを処理して、マークダウンのドキュメントファイルを生成します。
|
78 |
+
3. 生成されたドキュメントがStreamlitアプリに表示されます。
|
79 |
+
4. "Download Markdown File"リンクをクリックして、マークダウンファイルをダウンロードできます。
|
80 |
+
|
81 |
+
>[!TIP]
|
82 |
+
>Full Textのところからクリップボードにコピーすることもできます
|
83 |
+
|
84 |
+
|
85 |
+
## 🔧 設定
|
86 |
+
|
87 |
+
- `.CodeLumiaignore`ファイルには、ドキュメント生成プロセス中に無視する特定のファイルとディレクトリのパターンが含まれています。これらのパターンは、Streamlitアプリのサイドバーで編集できます。
|
88 |
+
|
89 |
+
## 📂 プロジェクト構造
|
90 |
+
|
91 |
+
```
|
92 |
+
CodeLumia/
|
93 |
+
├─ .github/
|
94 |
+
│ └─ workflows/
|
95 |
+
│ └─ run.yaml
|
96 |
+
├─ docs/
|
97 |
+
│ ├─ language_map.json
|
98 |
+
│ ├─ page_front.md
|
99 |
+
│ └─ SourceSageDocs.md
|
100 |
+
├─ modules/
|
101 |
+
│ ├─ file_operations.py
|
102 |
+
│ ├─ git_operations.py
|
103 |
+
│ └─ markdown_operations.py
|
104 |
+
├─ app.py
|
105 |
+
├─ CodeLumia.md
|
106 |
+
├─ docker-compose.yml
|
107 |
+
├─ Dockerfile
|
108 |
+
├─ README.md
|
109 |
+
└─ requirements.txt
|
110 |
+
```
|
111 |
+
|
112 |
+
## 🤝 コントリビューション
|
113 |
+
|
114 |
+
コントリビューションは大歓迎です!問題を見つけたり、改善のための提案がある場合は、issueを開くかプルリクエストを送ってください。
|
115 |
+
|
116 |
+
## 📄 ライセンス
|
117 |
+
|
118 |
+
このプロジェクトは[MITライセンス](LICENSE)の下で公開されています。
|
119 |
+
```
|
app.py
CHANGED
@@ -1,6 +1,51 @@
|
|
1 |
-
#
|
2 |
-
|
3 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
st.
|
|
|
|
1 |
+
# main.py
|
2 |
+
import os
|
3 |
import streamlit as st
|
4 |
+
import base64
|
5 |
+
from modules.git_operations import clone_repository
|
6 |
+
from modules.file_operations import get_file_tree, process_files
|
7 |
+
from modules.markdown_operations import create_markdown_content, save_markdown_file
|
8 |
+
|
9 |
+
# .gitignoreのパターンを読み込む
|
10 |
+
ignore_patterns = []
|
11 |
+
if os.path.exists(".CodeLumiaignore"):
|
12 |
+
with open(".CodeLumiaignore", "r") as f:
|
13 |
+
for line in f:
|
14 |
+
line = line.strip()
|
15 |
+
if line and not line.startswith("#"):
|
16 |
+
ignore_patterns.append(line)
|
17 |
+
|
18 |
+
# docs\page_front.mdファイルの内容を読み込む
|
19 |
+
if os.path.exists("docs/page_front.md"):
|
20 |
+
with open("docs/page_front.md", "r", encoding="utf-8") as f:
|
21 |
+
page_front_content = f.read()
|
22 |
+
st.markdown(page_front_content, unsafe_allow_html=True)
|
23 |
+
|
24 |
+
st.markdown("---")
|
25 |
+
# リポジトリのURLを入力するテキストボックス
|
26 |
+
repo_url = st.text_input("リポジトリのURL:")
|
27 |
+
st.markdown("---")
|
28 |
+
|
29 |
+
# .gitignoreのパターンを編集するサイドバー
|
30 |
+
st.sidebar.title(".gitignore Patterns")
|
31 |
+
ignore_patterns = st.sidebar.text_area("Enter patterns (one per line):", value="\n".join(ignore_patterns), height=600).split("\n")
|
32 |
+
|
33 |
+
if repo_url:
|
34 |
+
repo_name = repo_url.split("/")[-1].split(".")[0]
|
35 |
+
repo_path = clone_repository(repo_url, repo_name)
|
36 |
+
|
37 |
+
file_tree = get_file_tree(repo_path, ignore_patterns)
|
38 |
+
markdown_content = create_markdown_content(repo_name, file_tree, repo_path, ignore_patterns)
|
39 |
+
|
40 |
+
# マークダウンファイルを保存
|
41 |
+
save_markdown_file(repo_name, markdown_content)
|
42 |
+
|
43 |
+
# Streamlitアプリケーションの構築
|
44 |
+
st.markdown(markdown_content, unsafe_allow_html=True)
|
45 |
+
|
46 |
+
# ダウンロードリンクの作成
|
47 |
+
st.markdown(f'<a href="data:text/markdown;base64,{base64.b64encode(markdown_content.encode("utf-8")).decode("utf-8")}" download="{repo_name}.md">Download Markdown File</a>', unsafe_allow_html=True)
|
48 |
|
49 |
+
st.markdown("---")
|
50 |
+
st.markdown("# Full Text")
|
51 |
+
st.code(markdown_content)
|
docker-compose.yml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3'
|
2 |
+
|
3 |
+
services:
|
4 |
+
app:
|
5 |
+
build: .
|
6 |
+
ports:
|
7 |
+
- "8501:8501"
|
8 |
+
volumes:
|
9 |
+
- .:/app
|
docs/language_map.json
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
".py": "python",
|
3 |
+
".js": "javascript",
|
4 |
+
".java": "java",
|
5 |
+
".c": "c",
|
6 |
+
".cpp": "cpp",
|
7 |
+
".cs": "csharp",
|
8 |
+
".go": "go",
|
9 |
+
".php": "php",
|
10 |
+
".rb": "ruby",
|
11 |
+
".rs": "rust",
|
12 |
+
".ts": "typescript",
|
13 |
+
".html": "html",
|
14 |
+
".css": "css",
|
15 |
+
".json": "json",
|
16 |
+
".xml": "xml",
|
17 |
+
".yml": "yaml",
|
18 |
+
".yaml": "yaml",
|
19 |
+
".md": "markdown",
|
20 |
+
".txt": "plaintext",
|
21 |
+
".sh": "bash",
|
22 |
+
".sql": "sql",
|
23 |
+
"Dockerfile": "dockerfile",
|
24 |
+
".dockerfile": "dockerfile",
|
25 |
+
"docker-compose.yml": "yaml",
|
26 |
+
"docker-compose.yaml": "yaml"
|
27 |
+
}
|
docs/page_front.md
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p align="center">
|
2 |
+
<img src="https://media.githubusercontent.com/media/Sunwood-ai-labs/CodeLumia/main/docs/CodeLumia_icon.png" width="40%">
|
3 |
+
<br>
|
4 |
+
<h1 align="center">CodeLumia</h1>
|
5 |
+
<h3 align="center">
|
6 |
+
~Learn to Code, Step by Step~
|
7 |
+
|
8 |
+
[](https://huggingface.co/spaces/OFA-Sys/OFA-Image_Caption)[](https://github.com/Sunwood-ai-labs/CodeLumia)[](https://github.com/Sunwood-ai-labs/CodeLumia)[](https://github.com/Sunwood-ai-labs/CodeLumia)
|
9 |
+
|
10 |
+
</h3>
|
11 |
+
|
12 |
+
</p>
|
modules/file_operations.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import fnmatch
|
3 |
+
|
4 |
+
def get_file_tree(repo_path, ignore_patterns):
|
5 |
+
file_tree = ""
|
6 |
+
for root, dirs, files in os.walk(repo_path):
|
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 |
+
indent = " " * 4 * (level)
|
12 |
+
file_tree += f"{indent}{os.path.basename(root)}/\n"
|
13 |
+
subindent = " " * 4 * (level + 1)
|
14 |
+
for f in files:
|
15 |
+
# .gitignoreに一致するファイルを無視
|
16 |
+
if not any(fnmatch.fnmatch(f, pattern) for pattern in ignore_patterns):
|
17 |
+
file_tree += f"{subindent}{f}\n"
|
18 |
+
return file_tree
|
19 |
+
|
20 |
+
def process_files(repo_path, ignore_patterns):
|
21 |
+
file_contents = []
|
22 |
+
for root, dirs, files in os.walk(repo_path):
|
23 |
+
# .gitignoreに一致するディレクトリを無視
|
24 |
+
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
|
25 |
+
for file in files:
|
26 |
+
# .gitignoreに一致するファイルを無視
|
27 |
+
if not any(fnmatch.fnmatch(file, pattern) for pattern in ignore_patterns):
|
28 |
+
file_path = os.path.join(root, file)
|
29 |
+
with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
|
30 |
+
content = f.read()
|
31 |
+
file_contents.append((file_path.replace(f'{repo_path}/', ''), content))
|
32 |
+
return file_contents
|
modules/git_operations.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import shutil
|
3 |
+
import time
|
4 |
+
|
5 |
+
def clone_repository(repo_url, repo_name):
|
6 |
+
# tmpフォルダを削除
|
7 |
+
if os.path.exists("tmp"):
|
8 |
+
shutil.rmtree("tmp")
|
9 |
+
|
10 |
+
# tmpフォルダを作成
|
11 |
+
os.makedirs("tmp")
|
12 |
+
|
13 |
+
# リポジトリのクローン
|
14 |
+
repo_path = f"tmp/{repo_name}"
|
15 |
+
if os.path.exists(repo_path):
|
16 |
+
shutil.rmtree(repo_path)
|
17 |
+
os.system(f"git clone {repo_url} {repo_path}")
|
18 |
+
|
19 |
+
# 一時的な遅延を追加
|
20 |
+
time.sleep(1)
|
21 |
+
|
22 |
+
return repo_path
|
modules/markdown_operations.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
from modules.file_operations import get_file_tree, process_files
|
3 |
+
import os
|
4 |
+
|
5 |
+
def create_markdown_content(repo_name, file_tree, repo_path, ignore_patterns):
|
6 |
+
markdown_content = f"# << {repo_name}>> \n## {repo_name} File Tree\n\n```\n{file_tree}\n```\n\n"
|
7 |
+
|
8 |
+
# 拡張子と言語のマッピングを読み込む
|
9 |
+
with open("docs/language_map.json", "r") as f:
|
10 |
+
language_map = json.load(f)
|
11 |
+
|
12 |
+
file_contents = process_files(repo_path, ignore_patterns)
|
13 |
+
for file_path, content in file_contents:
|
14 |
+
_, file_extension = os.path.splitext(file_path)
|
15 |
+
language = language_map.get(file_extension, "")
|
16 |
+
# コードブロック内のコードブロックの範囲の全行の先頭に2つのスペースを入れる
|
17 |
+
lines = content.split("\n")
|
18 |
+
modified_lines = []
|
19 |
+
inside_code_block = False
|
20 |
+
for line in lines:
|
21 |
+
if line.startswith("```"):
|
22 |
+
inside_code_block = not inside_code_block
|
23 |
+
modified_lines.append("\t" + line)
|
24 |
+
else:
|
25 |
+
if inside_code_block:
|
26 |
+
modified_lines.append("\t" + line)
|
27 |
+
else:
|
28 |
+
modified_lines.append(line)
|
29 |
+
content = "\n".join(modified_lines)
|
30 |
+
# コードブロックの中のバッククォートをエスケープ
|
31 |
+
markdown_content += f"## {file_path}\n\n```{language}\n{content}\n```\n\n"
|
32 |
+
|
33 |
+
return markdown_content
|
34 |
+
|
35 |
+
def save_markdown_file(repo_name, markdown_content):
|
36 |
+
with open(f"{repo_name}.md", "w", encoding="utf-8") as f:
|
37 |
+
f.write(markdown_content)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
streamlit
|