- Notifications
You must be signed in to change notification settings - Fork1.1k
Astyle
Frederic Pillon edited this pageMar 6, 2023 ·5 revisions
AStyle is used for coding style checking.
Artistic Style is a source code indenter, formatter, and beautifier for the C, C++, C++/CLI, Objective‑C, C# and Java programming languages.
GitHub action is used to ensure each PR (Pull Request) andmain branch of theSTM32 core follow the code style definition defined.
Only sources files (*.h,*.hpp,*.c,*.cpp) from the followingSTM32 core directory lists are checked:
cores/libraries/variants/
.astyleignore file contains list of folder to ignore.
Hereafter the code style definition applied (.astylerc)
# STM32duino code style definition file for Astyle# Don't create backup files, let git handle itsuffix=none# K&R stylestyle=kr# 1 TBS addition to k&r, add braces to one liners# Use -j as it was changed in astyle from brackets to braces, this way it is compatible with older astyle versions-j# 2 spaces, convert tabs to spacesindent=spaces=2convert-tabs# Indent switches and casesindent-classesindent-switchesindent-casesindent-col1-comments# Remove spaces in and around parenthesesunpad-paren# Insert a space after if, while, for, and around operatorspad-headerpad-oper# Pointer/reference operators go next to the name (on the right)align-pointer=namealign-reference=name# Attach { for classes and namespacesattach-namespacesattach-classes# Extend longer lines, define maximum 120 value. This results in aligned code,# otherwise the lines are broken and not consistentmax-continuation-indent=120# if you like one-liners, keep themkeep-one-line-statements
Python scriptastyle.py is provided to ease use ofAStyle:
usage: astyle.py [-h] [-d <code style definition file>] [-g | -b <branch name>] [-i <ignore file>] [-p <astyle install path>] [-r <source root path>]Launch astyle on source files.options: -h, --help show this help message and exit -d <code style definition file>, --definition <code style definition file> Code style definition file for Astyle. Default: <repo path>/Arduino_Core_STM32/CI/astyle/.astylerc -g, --gitdiff Use changes files from git default branch. Default: {git_branch} -b <branch name>, --branch <branch name> Use changes files from git specified branch. -i <ignore file>, --ignore <ignore file> File containing path to ignore. Default: <repo path>/Arduino_Core_STM32/CI/astyle/.astyleignore -p <astyle install path>, --path <astyle install path> Astyle installation path -r <source root path>, --root <source root path> Source root path to use. Default: <repo path>/Arduino_Core_STM32