| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Artistic Style (astyle) is a source code indenter, formatter, and beautifier for the C, C++, C++/CLI, Objective‑C, C# and Java programming languages.
This project wraps astyle in a Python package. The package can be used:
The main reason to use this Python wrapper, rather than native astyle binaries, is that makes it easy for developers working on a project to have exactly the same version of astyle, regardless of their operating system. This prevents formatting differences which sometimes occur between different versions of astyle.
repos:
- repo: https://github.com/igrr/astyle_py.git
rev: v1.1.0
hooks:
- id: astyle_py
args: [--astyle-version=3.4.7 --style=linux]Place the required astyle formatting options to the args array. See the next section for details.
Use --dry-run argument if you only want the pre-commit hook to report the formatting errors, and not fix them automatically.
If necessary, add verbose: true option to see the output.
Use files: option to configure the regex pattern used to match the files to be formatted. The default pattern is '^.*\.(c|cpp|cxx|h|hpp|inc)$'. You can exclude certain files via additional arguments, as described in the next section.
Install the package from PyPI:
pip install astyle-py
Usage:
astyle_py [options] <files to format>
This package can be used as a library to implement custom formatting tools. See sample.py for an example.
See http://astyle.sourceforge.net/astyle.html for the details on Astyle formatting options.
Note that this wrapper doesn't implement the options from "Other options" and "Command Line Only" categories, except for those listed above.
Option --rules=<file> allows loading the formatting options from a rules file in YAML format. The rules file can specify different formatting rules for different parts of the project. This can be useful for monorepos which contain libraries written with different formatting conventions.
The rules file consists of sections (rules). For each section the following keywords may be specified:
If the file path matches multiple rules, the latest rule is applied. If the file path doesn't match any rule, the options from the special DEFAULT rule are used.
Here is an example of a rules file:
DEFAULT:
# These formatting options will be used by default
options: "--style=otbs --indent=spaces=4 --convert-tabs"
thirdparty_lib_1: # The section name is arbitrary
# Override formatting rules for the files in a certain directory
options: "--style=linux"
include:
- "/thirdparty/lib1/"
code_to_ignore_for_now:
# Ignore files in some other directories
check: false
include:
- "/src/component1/"
- "/src/component2/"
- "tests/" # matches a subdirectory 'tests' anywhere in the source treeThis python wrapper bundles multiple copies of Astyle, you can choose which one to use:
The following versions are supported:
To simplify distribution of astyle, it is compiled to WebAssembly (astyle_py/libastyle.wasm) and executed using wasmtime runtime via its Python bindings. This package should work on all operating systems supported by wasmtime — at the time of writing these are:
Other project which wraps astyle into a Python package include:
Please see CONTRIBUTING.md for details.
Thanks to André Simon for maintaining Astyle project!
| Back | FazBrowse Home | New Git URL |