docs: make English the default documentation language
This commit is contained in:
1 parent
c57982e032
commit
3c2bdcb7b6
55 files changed
+1920
-893
No files matched your search
@@ -1,12 +1,13 @@
|
||||
# 代码约定(Coding Conventions)
|
||||
<p align="right">
|
||||
<a href="coding-conventions.zh_CN.md">简体中文</a> · <strong>English</strong>
|
||||
</p>
|
||||
|
||||
- **语言/风格**:C 用四空格缩进 + K&R 大括号,跟随相邻文件;函数/局部变量 `snake_case`,公开硬件常量 `BSP_*`,文件内状态 `s_` 前缀;BSP API 用 `bsp_` 前缀,demo 入口 `demo_<feature>_<action>`;内部符号优先 `static`。UI 文案用英文,解释性注释可用中文;保留记录硬件寄存器值与内存约束的注释。
|
||||
- **复用既有组件**:可复用硬件逻辑放 `components/bsp`;菜单/动画/业务交互/验证页面放 `main`。不要另造轮子,遵循既有 BSP API。
|
||||
- **注释要求(尽可能详细)**:项目源码需要尽可能详细地编写函数说明、变量说明,增加完善的代码注释。
|
||||
- **函数说明**:每个非平凡函数都要有注释,说明:用途/职责、参数含义、返回值、失败值、副作用、阻塞行为、线程/任务上下文、内存所有权、调用前提与初始化顺序。涉及硬件的函数额外注明寄存器操作、时序约束与已知陷阱。
|
||||
- **变量说明**:模块级/文件级变量、宏、结构体字段都要有语义注释,说明其用途、取值范围、生命周期/所有权、跨任务共享时的同步要求。硬件常量注释注明来源(数据手册/实测/推导)。
|
||||
- **逻辑注释**:复杂逻辑、状态机转移、边界条件、时序依赖、并发/同步点都要有注释解释"为什么这么做",而不只是"做了什么"。寄存器配置、魔数、位操作、时序参数必须注明含义与依据。
|
||||
- **覆盖范围**:宁可注释偏多,也不留难懂代码;新代码与修改代码同样适用;注释用中文,保留英文技术术语。
|
||||
- **测试同步**:写代码时同步新增测试用例,或修改受本次改动影响的既有测试;若暂无合适自动化测试落点,在项目规范里写清测试缺口和手工验证路径。
|
||||
- **缓存组件**:若引入缓存组件(如 NVS 缓存、内存缓存等),默认设置过期时间;长期缓存需说明保留原因、过期风险与清理机制。当前固件不含需要 TTL 约束的缓存,无需特别处理。
|
||||
- **资源约束**:ESP32-C3 无 PSRAM,不增加 LVGL buffer / 音频分配 / 任务栈前先核对内部 RAM;足够的总空闲堆不保证有足够大连续块。
|
||||
# Coding Conventions
|
||||
|
||||
- Write C with four-space indentation and K&R braces, following neighboring files. Use `snake_case`, `BSP_*` public constants, `s_` file-local state, `bsp_` public BSP APIs, and `demo_<feature>_<action>` demo entry points. Prefer `static` for internal symbols.
|
||||
- Keep UI text and default documentation in English. Explanatory source comments may use Chinese while retaining established English technical terms.
|
||||
- Put reusable hardware behavior in `components/bsp`; keep menus, animations, product interaction, and validation pages in `main`.
|
||||
- Document non-trivial functions, state, ownership, blocking behavior, task context, initialization order, failure values, register choices, timing, synchronization, and hardware-specific constants. Explain why, not merely what.
|
||||
- Add or update tests with code changes. If automation is not practical, record the test gap and exact manual validation path.
|
||||
- If adding a cache, define expiration and cleanup unless durable retention is explicitly justified.
|
||||
- The ESP32-C3 has no PSRAM. Review internal RAM and largest-contiguous-block impact before increasing LVGL buffers, audio allocations, network state, or task stacks.
|
||||
Reference in new issue
Block a user