[style] テーマ設定を明るい基調に変更
Browse files.streamlit/config.tomlにテーマ設定を追加し、ベースを"light"に設定しました。
[feat] CodeLumiaプロジェクトに新規ファイルとディレクトリを追加
CodeLumia関連の複数の新規ファイルとディレクトリ(docker-compose.yml, Dockerfile, language_map.jsonなど)を追加しました。これにより、プロジェクトの機能が拡張され、より多くの設定と操作が可能になります。
[docs] README.mdの内容を更新し、新しいセクションを追加
プロジェクトの説明、インストール手順、使い方などを含む新しいセクションをREADME.mdに追加しました。これにより、ユーザーがプロジェクトを理解しやすくなります。
[refactor] app.pyのリファクタリングと機能拡張
app.pyを大幅にリファクタリングし、リポジトリのクローン、ファイルの処理、マークダウンコンテンツの生成などの新機能を追加しました。また、.gitignoreのパターンを動的に読み込む機能も実装しました。
[perf] Dockerfileでユーザーをrootに設定
Dockerfile内でユーザーをrootに設定することで、コンテナ内での権限問題を解決し、パフォーマンスを向上させました。
- .CodeLumiaignore +2 -1
- .streamlit/config.toml +2 -0
- CodeLumia.md +459 -6
- Dockerfile +1 -0
- NotebookForgeBeta.md +0 -0
.CodeLumiaignore
CHANGED
|
@@ -167,4 +167,5 @@ SourceSageAssets
|
|
| 167 |
.gitignore
|
| 168 |
LICENSE
|
| 169 |
.github
|
| 170 |
-
*.png
|
|
|
|
|
|
| 167 |
.gitignore
|
| 168 |
LICENSE
|
| 169 |
.github
|
| 170 |
+
*.png
|
| 171 |
+
*.jpg
|
.streamlit/config.toml
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[theme]
|
| 2 |
+
base="light"
|
CodeLumia.md
CHANGED
|
@@ -3,22 +3,221 @@
|
|
| 3 |
|
| 4 |
```
|
| 5 |
CodeLumia/
|
|
|
|
| 6 |
app.py
|
|
|
|
|
|
|
|
|
|
| 7 |
README.md
|
|
|
|
| 8 |
docs/
|
|
|
|
|
|
|
| 9 |
SourceSageDocs.md
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
```
|
| 12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
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
```
|
| 5 |
CodeLumia/
|
| 6 |
+
.SourceSageignore
|
| 7 |
app.py
|
| 8 |
+
CodeLumia.md
|
| 9 |
+
docker-compose.yml
|
| 10 |
+
Dockerfile
|
| 11 |
README.md
|
| 12 |
+
requirements.txt
|
| 13 |
docs/
|
| 14 |
+
language_map.json
|
| 15 |
+
page_front.md
|
| 16 |
SourceSageDocs.md
|
| 17 |
+
modules/
|
| 18 |
+
file_operations.py
|
| 19 |
+
git_operations.py
|
| 20 |
+
markdown_operations.py
|
| 21 |
|
| 22 |
```
|
| 23 |
|
| 24 |
+
## .SourceSageignore
|
| 25 |
+
|
| 26 |
+
```
|
| 27 |
+
.git
|
| 28 |
+
__pycache__
|
| 29 |
+
LICENSE
|
| 30 |
+
output.md
|
| 31 |
+
assets
|
| 32 |
+
Style-Bert-VITS2
|
| 33 |
+
output
|
| 34 |
+
streamlit
|
| 35 |
+
SourceSage.md
|
| 36 |
+
data
|
| 37 |
+
.gitignore
|
| 38 |
+
.SourceSageignore
|
| 39 |
+
*.png
|
| 40 |
+
Changelog
|
| 41 |
+
SourceSageAssets
|
| 42 |
+
SourceSageAssetsDemo
|
| 43 |
+
__pycache__
|
| 44 |
+
.pyc
|
| 45 |
+
**/__pycache__/**
|
| 46 |
+
modules\__pycache__
|
| 47 |
+
.svg
|
| 48 |
+
sourcesage.egg-info
|
| 49 |
+
.pytest_cache
|
| 50 |
+
dist
|
| 51 |
+
build
|
| 52 |
+
|
| 53 |
+
.gitattributes
|
| 54 |
+
.CodeLumiaignore
|
| 55 |
+
tmp
|
| 56 |
+
.CodeLumiaignore
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
## app.py
|
| 60 |
|
| 61 |
```python
|
| 62 |
+
# main.py
|
| 63 |
+
import os
|
| 64 |
import streamlit as st
|
| 65 |
+
import base64
|
| 66 |
+
from modules.git_operations import clone_repository
|
| 67 |
+
from modules.file_operations import get_file_tree, process_files
|
| 68 |
+
from modules.markdown_operations import create_markdown_content, save_markdown_file
|
| 69 |
+
|
| 70 |
+
# .gitignoreのパターンを読み込む
|
| 71 |
+
ignore_patterns = []
|
| 72 |
+
if os.path.exists(".CodeLumiaignore"):
|
| 73 |
+
with open(".CodeLumiaignore", "r") as f:
|
| 74 |
+
for line in f:
|
| 75 |
+
line = line.strip()
|
| 76 |
+
if line and not line.startswith("#"):
|
| 77 |
+
ignore_patterns.append(line)
|
| 78 |
+
|
| 79 |
+
# docs\page_front.mdファイルの内容を読み込む
|
| 80 |
+
if os.path.exists("docs/page_front.md"):
|
| 81 |
+
with open("docs/page_front.md", "r", encoding="utf-8") as f:
|
| 82 |
+
page_front_content = f.read()
|
| 83 |
+
st.markdown(page_front_content, unsafe_allow_html=True)
|
| 84 |
+
|
| 85 |
+
st.markdown("---")
|
| 86 |
+
# リポジトリのURLを入力するテキストボックス
|
| 87 |
+
repo_url = st.text_input("リポジトリのURL:")
|
| 88 |
+
st.markdown("---")
|
| 89 |
+
|
| 90 |
+
# .gitignoreのパターンを編集するサイドバー
|
| 91 |
+
st.sidebar.title(".gitignore Patterns")
|
| 92 |
+
ignore_patterns = st.sidebar.text_area("Enter patterns (one per line):", value="\n".join(ignore_patterns), height=600).split("\n")
|
| 93 |
+
|
| 94 |
+
if repo_url:
|
| 95 |
+
repo_name = repo_url.split("/")[-1].split(".")[0]
|
| 96 |
+
repo_path = clone_repository(repo_url, repo_name)
|
| 97 |
+
|
| 98 |
+
file_tree = get_file_tree(repo_path, ignore_patterns)
|
| 99 |
+
markdown_content = create_markdown_content(repo_name, file_tree, repo_path, ignore_patterns)
|
| 100 |
+
|
| 101 |
+
# マークダウンファイルを保存
|
| 102 |
+
save_markdown_file(repo_name, markdown_content)
|
| 103 |
+
|
| 104 |
+
# Streamlitアプリケーションの構築
|
| 105 |
+
st.markdown(markdown_content, unsafe_allow_html=True)
|
| 106 |
+
|
| 107 |
+
# ダウンロードリンクの作成
|
| 108 |
+
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)
|
| 109 |
+
|
| 110 |
+
st.markdown("---")
|
| 111 |
+
st.markdown("# Full Text")
|
| 112 |
+
st.code(markdown_content)
|
| 113 |
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
## CodeLumia.md
|
| 117 |
+
|
| 118 |
+
```markdown
|
| 119 |
+
# << CodeLumia>>
|
| 120 |
+
## CodeLumia File Tree
|
| 121 |
+
|
| 122 |
+
```
|
| 123 |
+
CodeLumia/
|
| 124 |
+
app.py
|
| 125 |
+
README.md
|
| 126 |
+
docs/
|
| 127 |
+
SourceSageDocs.md
|
| 128 |
+
|
| 129 |
+
```
|
| 130 |
+
|
| 131 |
+
## app.py
|
| 132 |
+
|
| 133 |
+
```python
|
| 134 |
+
# sample code
|
| 135 |
+
|
| 136 |
+
import streamlit as st
|
| 137 |
+
|
| 138 |
+
x = st.slider('Select a value')
|
| 139 |
+
st.write(x, 'squared is', x * x)
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
## README.md
|
| 143 |
+
|
| 144 |
+
```markdown
|
| 145 |
+
---
|
| 146 |
+
title: CodeLumia
|
| 147 |
+
emoji: 📚
|
| 148 |
+
colorFrom: purple
|
| 149 |
+
colorTo: blue
|
| 150 |
+
sdk: streamlit
|
| 151 |
+
sdk_version: 1.33.0
|
| 152 |
+
app_file: app.py
|
| 153 |
+
pinned: false
|
| 154 |
+
license: mit
|
| 155 |
+
---
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
<p align="center">
|
| 159 |
+
<img src="https://media.githubusercontent.com/media/Sunwood-ai-labs/CodeLumia/main/docs/CodeLumia_icon.png" width="50%">
|
| 160 |
+
<br>
|
| 161 |
+
<h1 align="center">CodeLumia</h1>
|
| 162 |
+
<h3 align="center">
|
| 163 |
+
~Learn to Code, Step by Step~
|
| 164 |
+
|
| 165 |
+
[](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)
|
| 166 |
+
|
| 167 |
+
</h3>
|
| 168 |
+
|
| 169 |
+
</p>
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
```
|
| 173 |
+
|
| 174 |
+
## docs/SourceSageDocs.md
|
| 175 |
+
|
| 176 |
+
```markdown
|
| 177 |
+
# SourceSageDocs
|
| 178 |
+
|
| 179 |
+
```bash
|
| 180 |
+
|
| 181 |
+
sourcesage --repository CodeLumia --owner Sunwood-ai-labs
|
| 182 |
+
```
|
| 183 |
+
```
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
```
|
| 187 |
+
|
| 188 |
+
## docker-compose.yml
|
| 189 |
+
|
| 190 |
+
```yaml
|
| 191 |
+
version: '3'
|
| 192 |
+
|
| 193 |
+
services:
|
| 194 |
+
app:
|
| 195 |
+
build: .
|
| 196 |
+
ports:
|
| 197 |
+
- "8501:8501"
|
| 198 |
+
volumes:
|
| 199 |
+
- .:/app
|
| 200 |
+
```
|
| 201 |
+
|
| 202 |
+
## Dockerfile
|
| 203 |
+
|
| 204 |
+
```
|
| 205 |
+
FROM python:3.12-slim
|
| 206 |
+
|
| 207 |
+
WORKDIR /app
|
| 208 |
+
|
| 209 |
+
RUN apt-get update && \
|
| 210 |
+
apt-get install -y git && \
|
| 211 |
+
rm -rf /var/lib/apt/lists/*
|
| 212 |
+
|
| 213 |
+
COPY requirements.txt .
|
| 214 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 215 |
+
|
| 216 |
+
COPY . .
|
| 217 |
+
|
| 218 |
+
EXPOSE 8501
|
| 219 |
+
|
| 220 |
+
CMD ["streamlit", "run", "app.py"]
|
| 221 |
```
|
| 222 |
|
| 223 |
## README.md
|
|
|
|
| 228 |
emoji: 📚
|
| 229 |
colorFrom: purple
|
| 230 |
colorTo: blue
|
| 231 |
+
sdk: docker
|
| 232 |
+
app_port: 8501
|
| 233 |
app_file: app.py
|
| 234 |
pinned: false
|
| 235 |
license: mit
|
|
|
|
| 250 |
</p>
|
| 251 |
|
| 252 |
|
| 253 |
+
## 🚀 はじめに
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
CodeLumiaへようこそ!CodeLumiaは、GitHubリポジトリのソースコードを分析し、包括的なマークダウン形式のドキュメントを自動生成するツールです。プロジェクトの構造、依存関係、設定などを簡単に理解できるようになります。
|
| 257 |
+
|
| 258 |
+
CodeLumiaは、開発者がコードベースをすばやく把握し、プロジェクトに効率的に貢献できるようにすることを目的としています。新しいチームメンバーのオンボーディングを容易にし、コードの保守性を向上させます。
|
| 259 |
+
|
| 260 |
+
>[!TIP]
|
| 261 |
+
>このリポジトリは[SourceSage](https://github.com/Sunwood-ai-labs/SourceSage)を活用しており、リリースノートやREADME、コミットメッセージの9割は[SourceSage](https://github.com/Sunwood-ai-labs/SourceSage) + [claude.ai](https://claude.ai/)で生成しています。
|
| 262 |
+
|
| 263 |
+
### 主な特徴:
|
| 264 |
+
|
| 265 |
+
- GitHubリポジトリの自動分析
|
| 266 |
+
- マークダウン形式のドキュメント生成
|
| 267 |
+
- ファイルとディレクトリの無視パターンのカスタマイズ
|
| 268 |
+
- わかりやすいStreamlitユーザーインターフェース
|
| 269 |
+
|
| 270 |
+
CodeLumiaを使用して、プロジェクトのドキュメンテーションを強化し、チームのコラボレーションを促進しましょう。ぜひお試しください!
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
## デモアプリ
|
| 274 |
+
|
| 275 |
+
[](https://huggingface.co/spaces/OFA-Sys/OFA-Image_Caption)
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
### 前提条件
|
| 280 |
+
|
| 281 |
+
- Docker
|
| 282 |
+
- Docker Compose
|
| 283 |
+
|
| 284 |
+
### インストール
|
| 285 |
+
|
| 286 |
+
1. リポジトリをクローンします:
|
| 287 |
+
```bash
|
| 288 |
+
git clone https://github.com/Sunwood-ai-labs/CodeLumia.git
|
| 289 |
+
cd CodeLumia
|
| 290 |
+
```
|
| 291 |
+
|
| 292 |
+
2. Dockerコンテナをビルドして実行します:
|
| 293 |
+
```bash
|
| 294 |
+
docker-compose up --build
|
| 295 |
+
```
|
| 296 |
+
|
| 297 |
+
3. ブラウザで `http://localhost:8501` にアクセスしてアプリケーションを開きます。
|
| 298 |
+
|
| 299 |
+
## 📖 使い方
|
| 300 |
+
|
| 301 |
+
1. 分析したいGitHubリポジトリのURLをテキスト入力フィールドに入力します。
|
| 302 |
+
2. アプリケーションがリポジトリをクローンし、ファイルを処理して、マークダウンのドキュメントファイルを生成します。
|
| 303 |
+
3. 生成されたドキュメントがStreamlitアプリに表示されます。
|
| 304 |
+
4. "Download Markdown File"リンクをクリックして、マークダウンファイルをダウンロードできます。
|
| 305 |
+
|
| 306 |
+
>[!TIP]
|
| 307 |
+
>Full Textのところからクリップボードにコピーすることもできます
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
## 🔧 設定
|
| 311 |
+
|
| 312 |
+
- `.CodeLumiaignore`ファイルには、ドキュメント生成プロセス中に無視する特定のファイルとディレクトリのパターンが含まれています。これらのパターンは、Streamlitアプリのサイドバーで編集できます。
|
| 313 |
+
|
| 314 |
+
## 📂 プロジェクト構造
|
| 315 |
+
|
| 316 |
+
```
|
| 317 |
+
CodeLumia/
|
| 318 |
+
├─ .github/
|
| 319 |
+
│ └─ workflows/
|
| 320 |
+
│ └─ run.yaml
|
| 321 |
+
├─ docs/
|
| 322 |
+
│ ├─ language_map.json
|
| 323 |
+
│ ├─ page_front.md
|
| 324 |
+
│ └─ SourceSageDocs.md
|
| 325 |
+
├─ modules/
|
| 326 |
+
│ ├─ file_operations.py
|
| 327 |
+
│ ├─ git_operations.py
|
| 328 |
+
│ └─ markdown_operations.py
|
| 329 |
+
├─ app.py
|
| 330 |
+
├─ CodeLumia.md
|
| 331 |
+
├─ docker-compose.yml
|
| 332 |
+
├─ Dockerfile
|
| 333 |
+
├─ README.md
|
| 334 |
+
└─ requirements.txt
|
| 335 |
+
```
|
| 336 |
+
|
| 337 |
+
## 🤝 コントリビューション
|
| 338 |
+
|
| 339 |
+
コントリビューションは大歓迎です!問題を見つけたり、改善のための提案がある場合は、issueを開くかプルリクエストを送ってください。
|
| 340 |
+
|
| 341 |
+
## 📄 ライセンス
|
| 342 |
+
|
| 343 |
+
このプロジェクトは[MITライセンス](LICENSE)の下で公開されています。
|
| 344 |
+
```
|
| 345 |
+
```
|
| 346 |
+
|
| 347 |
+
## requirements.txt
|
| 348 |
+
|
| 349 |
+
```plaintext
|
| 350 |
+
streamlit
|
| 351 |
+
```
|
| 352 |
+
|
| 353 |
+
## docs/language_map.json
|
| 354 |
+
|
| 355 |
+
```json
|
| 356 |
+
{
|
| 357 |
+
".py": "python",
|
| 358 |
+
".js": "javascript",
|
| 359 |
+
".java": "java",
|
| 360 |
+
".c": "c",
|
| 361 |
+
".cpp": "cpp",
|
| 362 |
+
".cs": "csharp",
|
| 363 |
+
".go": "go",
|
| 364 |
+
".php": "php",
|
| 365 |
+
".rb": "ruby",
|
| 366 |
+
".rs": "rust",
|
| 367 |
+
".ts": "typescript",
|
| 368 |
+
".html": "html",
|
| 369 |
+
".css": "css",
|
| 370 |
+
".json": "json",
|
| 371 |
+
".xml": "xml",
|
| 372 |
+
".yml": "yaml",
|
| 373 |
+
".yaml": "yaml",
|
| 374 |
+
".md": "markdown",
|
| 375 |
+
".txt": "plaintext",
|
| 376 |
+
".sh": "bash",
|
| 377 |
+
".sql": "sql",
|
| 378 |
+
"Dockerfile": "dockerfile",
|
| 379 |
+
".dockerfile": "dockerfile",
|
| 380 |
+
"docker-compose.yml": "yaml",
|
| 381 |
+
"docker-compose.yaml": "yaml"
|
| 382 |
+
}
|
| 383 |
+
```
|
| 384 |
+
|
| 385 |
+
## docs/page_front.md
|
| 386 |
+
|
| 387 |
+
```markdown
|
| 388 |
+
<p align="center">
|
| 389 |
+
<img src="https://media.githubusercontent.com/media/Sunwood-ai-labs/CodeLumia/main/docs/CodeLumia_icon.png" width="40%">
|
| 390 |
+
<br>
|
| 391 |
+
<h1 align="center">CodeLumia</h1>
|
| 392 |
+
<h3 align="center">
|
| 393 |
+
~Learn to Code, Step by Step~
|
| 394 |
+
|
| 395 |
+
[](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)
|
| 396 |
+
|
| 397 |
+
</h3>
|
| 398 |
+
|
| 399 |
+
</p>
|
| 400 |
+
|
| 401 |
```
|
| 402 |
|
| 403 |
## docs/SourceSageDocs.md
|
|
|
|
| 411 |
```
|
| 412 |
```
|
| 413 |
|
| 414 |
+
## modules/file_operations.py
|
| 415 |
+
|
| 416 |
+
```python
|
| 417 |
+
import os
|
| 418 |
+
import fnmatch
|
| 419 |
+
|
| 420 |
+
def get_file_tree(repo_path, ignore_patterns):
|
| 421 |
+
file_tree = ""
|
| 422 |
+
for root, dirs, files in os.walk(repo_path):
|
| 423 |
+
# .gitignoreに一致するディレクトリを無視
|
| 424 |
+
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
|
| 425 |
+
|
| 426 |
+
level = root.replace(repo_path, "").count(os.sep)
|
| 427 |
+
indent = " " * 4 * (level)
|
| 428 |
+
file_tree += f"{indent}{os.path.basename(root)}/\n"
|
| 429 |
+
subindent = " " * 4 * (level + 1)
|
| 430 |
+
for f in files:
|
| 431 |
+
# .gitignoreに一致するファイルを無視
|
| 432 |
+
if not any(fnmatch.fnmatch(f, pattern) for pattern in ignore_patterns):
|
| 433 |
+
file_tree += f"{subindent}{f}\n"
|
| 434 |
+
return file_tree
|
| 435 |
+
|
| 436 |
+
def process_files(repo_path, ignore_patterns):
|
| 437 |
+
file_contents = []
|
| 438 |
+
for root, dirs, files in os.walk(repo_path):
|
| 439 |
+
# .gitignoreに一致するディレクトリを無視
|
| 440 |
+
dirs[:] = [d for d in dirs if not any(fnmatch.fnmatch(d, pattern) for pattern in ignore_patterns)]
|
| 441 |
+
for file in files:
|
| 442 |
+
# .gitignoreに一致するファイルを無視
|
| 443 |
+
if not any(fnmatch.fnmatch(file, pattern) for pattern in ignore_patterns):
|
| 444 |
+
file_path = os.path.join(root, file)
|
| 445 |
+
with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
|
| 446 |
+
content = f.read()
|
| 447 |
+
file_contents.append((file_path.replace(f'{repo_path}/', ''), content))
|
| 448 |
+
return file_contents
|
| 449 |
+
```
|
| 450 |
+
|
| 451 |
+
## modules/git_operations.py
|
| 452 |
+
|
| 453 |
+
```python
|
| 454 |
+
import os
|
| 455 |
+
import shutil
|
| 456 |
+
import time
|
| 457 |
+
|
| 458 |
+
def clone_repository(repo_url, repo_name):
|
| 459 |
+
# tmpフォルダを削除
|
| 460 |
+
if os.path.exists("tmp"):
|
| 461 |
+
shutil.rmtree("tmp")
|
| 462 |
+
|
| 463 |
+
# tmpフォルダを作成
|
| 464 |
+
os.makedirs("tmp")
|
| 465 |
+
|
| 466 |
+
# リポジトリのクローン
|
| 467 |
+
repo_path = f"tmp/{repo_name}"
|
| 468 |
+
if os.path.exists(repo_path):
|
| 469 |
+
shutil.rmtree(repo_path)
|
| 470 |
+
os.system(f"git clone {repo_url} {repo_path}")
|
| 471 |
+
|
| 472 |
+
# 一時的な遅延を追加
|
| 473 |
+
time.sleep(1)
|
| 474 |
+
|
| 475 |
+
return repo_path
|
| 476 |
+
```
|
| 477 |
+
|
| 478 |
+
## modules/markdown_operations.py
|
| 479 |
+
|
| 480 |
+
```python
|
| 481 |
+
import json
|
| 482 |
+
from modules.file_operations import get_file_tree, process_files
|
| 483 |
+
import os
|
| 484 |
+
|
| 485 |
+
def create_markdown_content(repo_name, file_tree, repo_path, ignore_patterns):
|
| 486 |
+
markdown_content = f"# << {repo_name}>> \n## {repo_name} File Tree\n\n```\n{file_tree}\n```\n\n"
|
| 487 |
+
|
| 488 |
+
# 拡張子と言語のマッピングを読み込む
|
| 489 |
+
with open("docs/language_map.json", "r") as f:
|
| 490 |
+
language_map = json.load(f)
|
| 491 |
+
|
| 492 |
+
file_contents = process_files(repo_path, ignore_patterns)
|
| 493 |
+
for file_path, content in file_contents:
|
| 494 |
+
_, file_extension = os.path.splitext(file_path)
|
| 495 |
+
language = language_map.get(file_extension, "")
|
| 496 |
+
# コードブロック内のコードブロックの範囲の全行の先頭に2つのスペースを入れる
|
| 497 |
+
lines = content.split("\n")
|
| 498 |
+
modified_lines = []
|
| 499 |
+
inside_code_block = False
|
| 500 |
+
for line in lines:
|
| 501 |
+
if line.startswith("```"):
|
| 502 |
+
inside_code_block = not inside_code_block
|
| 503 |
+
modified_lines.append("\t" + line)
|
| 504 |
+
else:
|
| 505 |
+
if inside_code_block:
|
| 506 |
+
modified_lines.append("\t" + line)
|
| 507 |
+
else:
|
| 508 |
+
modified_lines.append(line)
|
| 509 |
+
content = "\n".join(modified_lines)
|
| 510 |
+
# コードブロックの中のバッククォートをエスケープ
|
| 511 |
+
markdown_content += f"## {file_path}\n\n```{language}\n{content}\n```\n\n"
|
| 512 |
+
|
| 513 |
+
return markdown_content
|
| 514 |
+
|
| 515 |
+
def save_markdown_file(repo_name, markdown_content):
|
| 516 |
+
with open(f"{repo_name}.md", "w", encoding="utf-8") as f:
|
| 517 |
+
f.write(markdown_content)
|
| 518 |
+
```
|
| 519 |
+
|
Dockerfile
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
FROM python:3.12-slim
|
| 2 |
|
| 3 |
WORKDIR /app
|
|
|
|
| 4 |
|
| 5 |
RUN apt-get update && \
|
| 6 |
apt-get install -y git && \
|
|
|
|
| 1 |
FROM python:3.12-slim
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
+
USER root
|
| 5 |
|
| 6 |
RUN apt-get update && \
|
| 7 |
apt-get install -y git && \
|
NotebookForgeBeta.md
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|