diff --git a/docs/en-us/develop/development.md b/docs/en-us/develop/development.md index 6feb1dec3b..354a3c4cc0 100644 --- a/docs/en-us/develop/development.md +++ b/docs/en-us/develop/development.md @@ -85,7 +85,36 @@ Welcome to the [GitHub Pull Request Tutorial](./pr-tutorial.md) that anyone can Note: operations regarding Git can be done by VS2022 instead of command line tools, using the Git changes tab. -## Enable clang-format in Visual Studio +## MAA file formatting requirements + +MAA uses a series of formatting tools to ensure that the code and resource files in the repository are visually unified for easy maintenance and reading. + +Please ensure that it has been formatted before submission, or [enable Pre commit Hooks for automatic formatting](#use-pre-commit-hooks-to-automatically-format-code). + +The currently enabled formatting tools are as follows: + +|File Type | Format Tool| +| --- | --- | +| C++ | [clang-format](https://clang.llvm.org/docs/ClangFormat.html) | +| Json/Yaml | [Prettier](https://prettier.io/) | +| Markdown | [markdownlint](https://github.com/DavidAnson/markdownlint-cli2) | + +### Use Pre-commit Hooks to Automatically Format Code + +1. Ensure that you have Python and Node environments on your computer. + +2. Execute the following command in the root directory of the project: + + ```bash + pip install pre-commit + pre-commit install + ``` + +If pre-commit still cannot be used after pip install, please check if the pip installation path has been added to the PATH. + +The formatting tool will automatically run every time you submit to ensure that your code format conforms to the style guide. + +### Enable clang-format in Visual Studio 1. Install clang-format version 17 or higher. diff --git a/docs/zh-cn/develop/development.md b/docs/zh-cn/develop/development.md index d391b235cd..767915d530 100644 --- a/docs/zh-cn/develop/development.md +++ b/docs/zh-cn/develop/development.md @@ -119,6 +119,8 @@ MAA 使用一系列的格式化工具来保证仓库中的代码和资源文件 pre-commit install ``` +如果pip安装后依然无法运行pre-commit,请确认pip安装地址已被添加到PATH + 接下来,每次提交时都将会自动运行格式化工具,来确保你的代码格式符合规范 ### 在 Visual Studio 中启用 clang-format