|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is the Chinese translation repository for the Kubebuilder documentation. It's built using mdBook and contains comprehensive documentation for the Kubebuilder project, including tutorials, reference materials, and migration guides. |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +- **mdBook Documentation**: Built using Rust's mdBook with custom preprocessors |
| 12 | +- **Custom Go Utilities**: Located in `book/utils/` for processing documentation |
| 13 | +- **Preprocessors**: |
| 14 | + - `litgo.sh` - Processes Go code examples using literate-go utility |
| 15 | + - `markerdocs.sh` - Generates marker documentation |
| 16 | +- **Content Structure**: Main content in `book/src/` with Chinese documentation |
| 17 | +- **Build Artifacts**: Generated site outputs to `book/` directory |
| 18 | + |
| 19 | +## Essential Commands |
| 20 | + |
| 21 | +### Building and Serving |
| 22 | + |
| 23 | +```bash |
| 24 | +# Build the documentation (includes downloading dependencies) |
| 25 | +./book/install-and-build.sh build |
| 26 | + |
| 27 | +# Serve locally for development (after mdBook is installed) |
| 28 | +cd book && mdbook serve |
| 29 | +# Then visit http://localhost:3000 |
| 30 | + |
| 31 | +# Deploy to Cloudflare (requires environment variables) |
| 32 | +./deploy-cloudflare.sh |
| 33 | +``` |
| 34 | + |
| 35 | +### Development |
| 36 | + |
| 37 | +```bash |
| 38 | +# Build Go utilities (preprocessors) |
| 39 | +cd book/utils |
| 40 | +go build -o ../../bin/literate-go ./litgo |
| 41 | +go build -o ../../bin/marker-docs ./markerdocs |
| 42 | + |
| 43 | +# Manual mdBook operations (after install-and-build.sh) |
| 44 | +cd book |
| 45 | +mdbook build # Build only |
| 46 | +mdbook clean # Clean build artifacts |
| 47 | +``` |
| 48 | + |
| 49 | +## Key Dependencies |
| 50 | + |
| 51 | +- **Go 1.23+**: Required for building utilities and examples |
| 52 | +- **mdBook v0.4.40**: Rust-based documentation generator |
| 53 | +- **controller-gen v0.19.0**: Kubernetes code generation tool |
| 54 | +- **Node.js 18+**: For Cloudflare deployment via Wrangler |
| 55 | + |
| 56 | +## Build Process |
| 57 | + |
| 58 | +1. Downloads and installs mdBook binary for current platform |
| 59 | +2. Builds Go utilities in `book/utils/` |
| 60 | +3. Installs controller-gen tool |
| 61 | +4. Runs mdBook with custom preprocessors |
| 62 | +5. Outputs static site to `book/` directory |
| 63 | + |
| 64 | +## Deployment |
| 65 | + |
| 66 | +- **Cloudflare Pages**: Automated via GitHub Actions on push to main/master |
| 67 | +- **Environment Variables Required**: |
| 68 | + - `CLOUDFLARE_API_TOKEN` |
| 69 | + - `CLOUDFLARE_ACCOUNT_ID` |
| 70 | +- **Local Deploy**: Use `./deploy-cloudflare.sh` script |
| 71 | + |
| 72 | +## File Structure |
| 73 | + |
| 74 | +- `book/src/SUMMARY.md` - Table of contents for Chinese documentation |
| 75 | +- `book/book.toml` - mdBook configuration |
| 76 | +- `book/utils/` - Go utilities for documentation processing |
| 77 | +- `book/install-and-build.sh` - Main build script |
| 78 | +- `deploy-cloudflare.sh` - Cloudflare deployment script |
| 79 | +- `.github/workflows/` - CI/CD automation |
| 80 | + |
| 81 | +## Important Notes |
| 82 | + |
| 83 | +- This is a translation project - content follows the original Kubebuilder documentation structure |
| 84 | +- Custom preprocessors handle Go code examples and marker documentation |
| 85 | +- Build script handles cross-platform mdBook installation automatically |
| 86 | +- All scripts include proper error handling and platform detection |
0 commit comments