ci: add astyle pre-commit check

This commit is contained in:
Ivan Grokhotkov
2022-09-08 08:48:30 +02:00
parent d33ee17dee
commit 43741ec803
6 changed files with 214 additions and 18 deletions

View File

@@ -193,15 +193,19 @@ For updating a single commit, it is possible to run ``dos2unix FILENAME`` and th
Formatting Your Code
^^^^^^^^^^^^^^^^^^^^
You can use ``astyle`` program to format your code according to the above recommendations.
ESP-IDF uses Astyle to format source code. The configuration is stored in :project_file:`tools/ci/astyle-rules.yml` file.
If you are writing a file from scratch, or doing a complete rewrite, feel free to re-format the entire file. If you are changing a small portion of file, do not re-format the code you did not change. This will help others when they review your changes.
To re-format a file, run:
Initially, all components are excluded from formatting checks. You can enable formatting checks for the component by removing it from ``components_not_formatted_temporary`` list. Then run:
.. code-block:: bash
tools/format.sh components/my_component/file.c
pre-commit run --files <path_to_files> astyle_py
Alternatively, you can run ``astyle_py`` manually. You can install it with ``pip install astyle_py==VERSION``. Make sure you have the same version installed as the one specified in :project_file:`.pre-commit-config.yaml` file. With ``astyle_py`` installed, run:
.. code-block:: bash
astyle_py --rules=$IDF_PATH/tools/ci/astyle-rules.yml <path-to-file>
Type Definitions