docs(zh-CN): translate code block(plain text) (#753)

Co-authored-by: neo <neo.dowithless@gmail.com>
This commit is contained in:
zdoc.app
2026-03-23 06:39:24 +08:00
committed by GitHub
parent fd2a8edb53
commit 4f6f587700
118 changed files with 1807 additions and 1835 deletions

View File

@@ -6,7 +6,7 @@
```
rules/
├── common/ # Language-agnostic principles (always install)
├── common/ # 语言无关原则(始终安装)
│ ├── coding-style.md
│ ├── git-workflow.md
│ ├── testing.md
@@ -15,11 +15,11 @@ rules/
│ ├── hooks.md
│ ├── agents.md
│ └── security.md
├── typescript/ # TypeScript/JavaScript specific
├── python/ # Python specific
├── golang/ # Go specific
├── swift/ # Swift specific
└── php/ # PHP specific
├── typescript/ # TypeScript/JavaScript 特定
├── python/ # Python 特定
├── golang/ # Go 特定
├── swift/ # Swift 特定
└── php/ # PHP 特定
```
* **common/** 包含通用原则 —— 没有语言特定的代码示例。

View File

@@ -5,9 +5,9 @@
始终创建新对象,绝不改变现有对象:
```
// Pseudocode
WRONG: modify(original, field, value) → changes original in-place
CORRECT: update(original, field, value) → returns new copy with change
// 伪代码
WRONG: modify(original, field, value) → 原地修改 original
CORRECT: update(original, field, value) → 返回包含更改的新副本
```
理由:不可变数据可以防止隐藏的副作用,使调试更容易,并支持安全的并发。

View File

@@ -18,10 +18,10 @@ paths:
```
src/test/java/com/example/app/
service/ # Unit tests for service layer
controller/ # Web layer / API tests
repository/ # Data access tests
integration/ # Cross-layer integration tests
service/ # 服务层单元测试
controller/ # Web 层/API 测试
repository/ # 数据访问测试
integration/ # 跨层集成测试
```
`src/test/java` 中镜像 `src/main/java` 的包结构。

View File

@@ -120,10 +120,10 @@ fun `delete item emits updated list without deleted item`() = runTest { }
```
src/
├── commonTest/kotlin/ # Shared tests (ViewModel, UseCase, Repository)
├── androidUnitTest/kotlin/ # Android unit tests (JUnit)
├── androidInstrumentedTest/kotlin/ # Instrumented tests (Room, UI)
└── iosTest/kotlin/ # iOS-specific tests
├── commonTest/kotlin/ # 共享测试(ViewModelUseCaseRepository
├── androidUnitTest/kotlin/ # Android 单元测试(JUnit
├── androidInstrumentedTest/kotlin/ # 仪器化测试(RoomUI
└── iosTest/kotlin/ # iOS 专用测试
```
最低测试覆盖率:每个功能都需要覆盖 ViewModel + UseCase。

View File

@@ -28,10 +28,10 @@ paths:
使用 **perltidy** 并采用以下设置:
```
-i=4 # 4-space indent
-l=100 # 100 char line length
-ce # cuddled else
-bar # opening brace always right
-i=4 # 4 空格缩进
-l=100 # 100 字符行宽
-ce # else 紧贴前括号
-bar # 左花括号始终在右侧
```
## 代码检查

View File

@@ -129,15 +129,15 @@ for user in &users {
src/
├── main.rs
├── lib.rs
├── auth/ # Domain module
├── auth/ # 领域模块
│ ├── mod.rs
│ ├── token.rs
│ └── middleware.rs
├── orders/ # Domain module
├── orders/ # 领域模块
│ ├── mod.rs
│ ├── model.rs
│ └── service.rs
└── db/ # Infrastructure
└── db/ # 基础设施
├── mod.rs
└── pool.rs
```

View File

@@ -20,17 +20,17 @@ paths:
```text
my_crate/
├── src/
│ ├── lib.rs # Unit tests in #[cfg(test)] modules
│ ├── lib.rs # 位于 #[cfg(test)] 模块中的单元测试
│ ├── auth/
│ │ └── mod.rs # #[cfg(test)] mod tests { ... }
│ └── orders/
│ └── service.rs # #[cfg(test)] mod tests { ... }
├── tests/ # Integration tests (each file = separate binary)
├── tests/ # 集成测试(每个文件 = 独立的二进制文件)
│ ├── api_test.rs
│ ├── db_test.rs
│ └── common/ # Shared test utilities
│ └── common/ # 共享的测试工具
│ └── mod.rs
└── benches/ # Criterion benchmarks
└── benches/ # Criterion 基准测试
└── benchmark.rs
```