Skip to content

Commit c9ddaf7

Browse files
Update doc for clang-format and clang-tidy and correct the inconsistency between the document description and the actual formatting behavior (#21)
* docs: Add docs for clang-format and clang-tidy * docs: Add docs for clang-format and clang-tidy to readme * docs: Fix doc format * docs: Remove redundant spaces * docs: fix brace and control-statement parenthesis spacing; update .clang-format and documentation * Update clang-tidy.md to remove space Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 9e29d06 commit c9ddaf7

File tree

4 files changed

+768
-4
lines changed

4 files changed

+768
-4
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ColumnLimit: 100 # Maximum line width
3333
# -----------------------------------------------------------------------------
3434
# Spaces
3535
# -----------------------------------------------------------------------------
36-
SpaceBeforeParens: Never # No space before function call parentheses
36+
SpaceBeforeParens: ControlStatements # Space before parentheses for control statements (if/for/while); function calls remain tight
3737
SpacesInContainerLiterals: true # Enforce spaces in container literals
3838
SpaceBeforeAssignmentOperators: true # Add space before assignment operators
3939
SpacesInParentheses: false # No extra spaces inside parentheses

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ xlings install mcpp:clang-format
4242

4343
## 目录
4444

45-
- 一、`标识符`命名风格
45+
- 一、标识符命名风格
4646
- 1.0 [类型名 - 大驼峰](./README.md#10-类型名---大驼峰)
4747
- 1.1 [对象/数据成员 - 小驼峰](./README.md#11-对象数据成员---小驼峰)
4848
- 1.2 [函数 - 下划线(snake_case)](./README.md#12-函数---下划线snake_case)
@@ -68,10 +68,13 @@ xlings install mcpp:clang-format
6868
- 3.3 [用 std::string_view 替代 char*](./README.md#33-用-stdstring_view-替代-char)
6969
- 3.4 [用 optional/expected 替代 int 错误码](./README.md#34-用-optionalexpected-替代-int-错误码)
7070
- 3.5 [RAII 资源管理](./README.md#35-raii-资源管理)
71+
- 四、配置文件
72+
- 4.0 [Clang-Format 配置](./clang-format.md)
73+
- 4.1 [Clang-Tidy 配置](./clang-tidy.md)
7174

72-
## 一、`标识符`命名风格
75+
## 一、标识符命名风格
7376

74-
> 核心思想通过`标识符`风格设计, 能快速识别 - 类型、函数、数据以及封装性
77+
> 核心思想通过**标识符**风格设计, 能快速识别 - 类型、函数、数据以及封装性
7578
7679
下方示例综合展示各小节要点:
7780

@@ -795,6 +798,13 @@ struct AutoLog {
795798
};
796799
```
797800

801+
## 四、配置文件
802+
803+
本章包含两个常用工具的配置说明:`clang-format`(代码格式化)和 `clang-tidy`(静态检查)。详细文档见:
804+
805+
- [Clang-Format 配置](./clang-format.md) — 代码格式化规则与示例。
806+
- [Clang-Tidy 配置](./clang-tidy.md) — 静态检查规则集合与示例。
807+
798808
---
799809

800810
## 相关链接

0 commit comments

Comments
 (0)