开发环境搭建
开发环境搭建
Section titled “开发环境搭建”⏱️ 预计阅读时间: 10 分钟
| 工具 | 版本要求 | 用途 |
|---|---|---|
| MoonBit | ≥ 0.14 | 核心语言工具链 |
| Git | ≥ 2.30 | 版本控制 |
| VS Code | 最新 | 推荐编辑器 |
| Bun | ≥ 1.0 | 站点构建(可选,仅需修改文档时) |
安装 MoonBit
Section titled “安装 MoonBit”# macOS / Linuxcurl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
# Windows (PowerShell)irm https://cli.moonbitlang.com/install/powershell.ps1 | iex
# 验证安装moon version --allMoonBit CLI 包含以下命令:
| 命令 | 功能 |
|---|---|
moon new | 创建新项目 |
moon build | 编译项目 |
moon test | 运行测试 |
moon fmt | 格式化代码 |
moon info | 更新接口文件 (.mbti) |
moon check | 类型检查 |
moon coverage | 覆盖率分析 |
# Fork Github 仓库后git clone https://github.com/<your-username>/mbtgraph.gitcd mbtgraph
# 查看分支git branch -a # 主分支 main, 站点分支 sitegit checkout site # 文档/站点相关工作在 site 分支mbtgraph/├── lib/ # 🟣 MoonBit 核心库│ ├── core/ # 基础定义(types, traits, error)│ ├── storage/ # 8 种存储实现│ ├── algo/ # 49+ 算法│ │ ├── traversal/ # BFS, DFS, 拓扑排序│ │ ├── shortest_path/ # Dijkstra, Bellman-Ford, Floyd-Warshall│ │ ├── flow/ # Dinic, Edmonds-Karp, 费用流│ │ └── ... # 着色、匹配、社区检测等│ ├── io/ # 序列化与统计│ └── utils/ # 工具函数├── site/ # 🌐 Astro 文档站点│ ├── src/content/docs/ # 文档内容(Starlight)│ │ ├── algorithms/ # 算法教程│ │ ├── getting-started/ # 入门指南│ │ ├── core-concepts/ # 基础教程│ │ ├── api/ # API 参考│ │ ├── use-cases/ # 实战案例│ │ └── contributing/ # 贡献指南(你在这里)│ ├── src/lib/algs/ # 算法可视化模块│ └── src/pages/ # Astro 页面├── docs/ # 📄 项目文档与设计记录│ ├── ARCHITECTURE.md # 架构设计│ ├── TODO.md # 任务清单│ └── design/ # 详细设计文档├── examples/ # 💡 用法示例├── benchmarks/ # 📊 基准测试└── tests/ # 🔬 集成测试(Python 脚本)# 1. 编译检查moon check # 类型检查整个项目moon check lib/algo/dijkstra # 检查单模块
# 2. 格式化与接口更新moon fmt # 格式化所有代码moon info # 更新 .mbti 绑定文件
# 3. 运行测试moon test # 全量测试moon test lib/algo/pagerank # 单模块测试moon test --update # 更新快照
# 4. 覆盖率moon coverage analyze文档站点(仅编辑文档时需要)
Section titled “文档站点(仅编辑文档时需要)”cd site
# 安装依赖bun install
# 开发服务器bun run dev # http://localhost:4321
# 构建bun run build # 输出到 dist/
# 预览bun run preview提交 Pull Request
Section titled “提交 Pull Request”git checkout -b feature/your-featuregit add <files>git commit -m "feat(module): description"git push origin feature/your-feature然后在 GitHub 上创建 PR 到 moonbit/mbtgraph 的 main 或 site 分支。
相关文档: