{"id":17150365,"url":"https://github.com/dlech/micropython-uncrustify","last_synced_at":"2025-11-01T03:04:44.164Z","repository":{"id":142620672,"uuid":"566952508","full_name":"dlech/micropython-uncrustify","owner":"dlech","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-30T17:16:04.000Z","size":18488,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"micropython","last_synced_at":"2025-01-22T07:48:28.711Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dlech.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":"CONTRIBUTING.md","funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-16T19:02:58.000Z","updated_at":"2024-06-08T16:36:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"63179737-49d3-45e2-8f3d-7af8c2c006f5","html_url":"https://github.com/dlech/micropython-uncrustify","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlech%2Fmicropython-uncrustify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlech%2Fmicropython-uncrustify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlech%2Fmicropython-uncrustify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dlech%2Fmicropython-uncrustify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dlech","download_url":"https://codeload.github.com/dlech/micropython-uncrustify/tar.gz/refs/heads/micropython","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240304560,"owners_count":19780312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T21:35:28.662Z","updated_at":"2025-11-01T03:04:44.107Z","avatar_url":"https://github.com/dlech.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Travis CI](http://badges.herokuapp.com/travis/uncrustify/uncrustify?style=flat-square\u0026env=BADGE=linux\u0026label=Linux\u0026branch=master)](https://travis-ci.org/uncrustify/uncrustify)\n[![Travis CI](http://badges.herokuapp.com/travis/uncrustify/uncrustify?style=flat-square\u0026env=BADGE=osx\u0026label=OSX\u0026branch=master)](https://travis-ci.org/uncrustify/uncrustify)\n[![AppVeyor](https://img.shields.io/appveyor/ci/uncrustify/uncrustify/master.svg?style=flat-square\u0026label=Windows)](https://ci.appveyor.com/project/uncrustify/uncrustify)\n[![Coverity](https://scan.coverity.com/projects/8264/badge.svg)](https://scan.coverity.com/projects/uncrustify)\n[![Coverage Status](https://coveralls.io/repos/github/uncrustify/uncrustify/badge.svg?branch=master)](https://coveralls.io/github/uncrustify/uncrustify?branch=master)\n\u003ca href=\"#\"\u003e\u003cimg src=\"https://img.shields.io/badge/C++-11-blue.svg?style=flat-square\"\u003e\u003c/a\u003e\n\n---------------------------\n\n# Uncrustify\nA source code beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and VALA\n\n## Features\n* Highly configurable - 742 configurable options as of version 0.72.0\n- \u003cdetails\u003e\u003csummary\u003eadd/remove spaces\u003c/summary\u003e\n\n  - `sp_before_sparen`: _Add or remove space before '(' of 'if', 'for', 'switch', 'while', etc._\n  - `sp_compare`: _Add or remove space around compare operator '\u003c', '\u003e', '==', etc_\n\u003c/details\u003e\n\n- \u003cdetails\u003e\u003csummary\u003eadd/remove newlines\u003c/summary\u003e\n\n  - `nl_if_brace`: _Add or remove newline between 'if' and '{'_\n  - `nl_brace_while`: _Add or remove newline between '}' and 'while' of 'do' statement_\n\u003c/details\u003e\n\n- \u003cdetails\u003e\u003csummary\u003eadd/remove blanklines\u003c/summary\u003e\n\n  - `eat_blanks_before_close_brace`: _Whether to remove blank lines before '}'_\n  - `nl_max`: _The maximum consecutive newlines (3 = 2 blank lines)_\n\u003c/details\u003e\n\n- \u003cdetails\u003e\u003csummary\u003eindent code\u003c/summary\u003e\n\n  - `indent_switch_case`: _indent_switch_case: Spaces to indent 'case' from 'switch'_\n  - `indent_class_colon`: _Whether to indent the stuff after a leading base class colon_\n\u003c/details\u003e\n\n- \u003cdetails\u003e\u003csummary\u003ealign code\u003c/summary\u003e\n\n  - `align_func_params`: _Align variable definitions in prototypes and functions_\n  - `align_struct_init_span`: _The span for aligning struct initializer values (0=don't align)_\n\u003c/details\u003e\n\n- \u003cdetails\u003e\u003csummary\u003emodify code\u003c/summary\u003e\n\n  - `mod_full_brace_for`: _Add or remove braces on single-line 'for' statement_\n  - `mod_paren_on_return`: _Add or remove unnecessary paren on 'return' statement_\n\u003c/details\u003e\n\nHere is an example [configuration file](https://raw.githubusercontent.com/uncrustify/uncrustify/master/documentation/htdocs/ben.cfg.txt),\nand here is a [before](https://raw.githubusercontent.com/uncrustify/uncrustify/master/documentation/htdocs/examples/c-1.in.c)\nand [after](https://raw.githubusercontent.com/uncrustify/uncrustify/master/documentation/htdocs/examples/c-1.out.c)\nC source example.\nThat should give you a pretty good idea of what Uncrustify can do.\n\n\n\n\n\n---------------------------------------------------------------------------\n\n## Binaries\nPre compiled binaries for Windows can be downloaded [here](https://sourceforge.net/projects/uncrustify/files/uncrustify/).\n\n## Build\n[Python](https://www.python.org/) is an \"interpreted high-level programming language for general-purpose programming\", for this project it is needed to extend the capabilities of CMake.\n\n[CMake](https://cmake.org/) is a tool that generates build systems\n(Makefiles, Visual Studio project files, Xcode project files and others).\n\nTo generate a build system for Uncrustify using CMake, create a build\nfolder and run CMake from it:\n\n```bash\n$ mkdir build\n$ cd build\n$ cmake ..\n```\n(Use `cmake -G Xcode ..` for Xcode)\n\nThen use the build tools of your build system (in many cases this will\nsimply be `make`, but on Windows it could be MSBuild or Visual Studio).\nOr use CMake to invoke it:\n\n```bash\n$ cmake --build .\n```\n\nIf testing is enabled, CMake generates a `test` target, which you can\n_build_ using your build system tools (usually `make test`). This can also\nbe invoked using CTest:\n\n```bash\n$ ctest -V -C Debug\n```\n\nThere is also an `install` target, which can be used to install the\nUncrustify executable (typically `make install`).\n\n### A note on CMake configurations\nSome build systems are single-configuration, which means you specify the\nbuild type when running CMake (by setting the `CMAKE_BUILD_TYPE`\nvariable), and the generated files then build that configuration.\n\nAn example of a single-configuration build system are Makefiles. You can\nbuild the Release configuration of Uncrustify (from the build folder) with:\n\n```bash\n$ cmake -DCMAKE_BUILD_TYPE=Release ..\n$ make\n```\n\nOther build systems are multi-configuration, which means you specify the\nbuild type when building.\n\nAn example of a multi-configuration build system are Visual Studios project\nfiles. When you open the project in Visual Studio, you can select which\nconfiguration to build. You can also do this while building from the\ncommand line with `cmake --build . --config Release`.\n\n\n## Bugs\nPost any bugs to the issue tracker found on the projects GitHub page:\n  https://github.com/uncrustify/uncrustify/issues\n\nPlease include the following with your issue:\n - a description of what is not working right\n - input code sufficient to demonstrate the issue\n - expected output code\n - configuration options used to generate the output\n\nMore about this is in the [ISSUE_TEMPLATE](https://github.com/uncrustify/uncrustify/blob/master/.github/ISSUE_TEMPLATE)\n\n\n### Known problems\n[Look at the Wiki](https://github.com/uncrustify/uncrustify/wiki/Known-Problems)\n\n\n## Which repositories have uncrustify?\n[Look here](https://repology.org/metapackage/uncrustify/versions)\n\n\n## Contribute\nIf you want to add a feature, fix a bug, or implement missing\nfunctionality, feel free to do so! Patches are welcome!\nHere are some areas that need attention:\n\n- __Patches for Objective-C support__. We really need someone who knows\n  this language as it has more than plenty open issues. A good starting\n  point would be to integrate changes made in the\n  [Unity fork](https://github.com/Unity-Technologies/uncrustify/tree/fixes/c-oc-java)\n- Test Java support and provide feedback (or patches!)\n- Test Embedded SQL to see what works\n- A logo of some sort\n- Anything else that you want to do to make it better?\n\n### A note about pull requests\nFirstly take a look at the [CONTRIBUTING.md](https://github.com/uncrustify/uncrustify/blob/master/CONTRIBUTING.md)\n\nCurrently we have two continuous integration systems that test your PRs,\nTravisCI and Appveyor.\nTested are the test cases, the formatting of the code base and\nthe output of the command line options.\n\nTest cases can be found in the `tests/` directory. Every file ending with\n`.test` is a test set. Inside each line with these components is a\nsingle test: `testNr[!] testConfigFileName testInputFileName [lang]`\n\nThe configuration file `testConfigFileName` has to be located inside `tests/config`,\nthe input file `testInputFileName` inside `tests/input/\u003ctestSetName\u003e/`,\nand expected results file inside the `tests/expected/\u003ctestSetName\u003e/`\ndirectory.\nExpected results have the following naming convention: `testNr-testConfigFileName`.\n\nOptionally a `!` can follow the `testNr` to enable a custom rerun\nconfiguration.\nRerun configurations need to be named like this:\n`testConfigFileName`(without extension)+`.rerun`+`.extension`\n\nAlso, optionally a language for the input can be provided with `lang`.\n\nThe codebase has to be formatted by the options set up in\n`forUncrustifySources.cfg`. Failing to format the sources correctly will\ncause TravisCI build failures.\n\nThe Command line interface (CLI) output is tested by the\n`test_cli_options.sh` script. It is located inside of `tests/cli/` and operates\non the subdirectories of that folder.\n\nIf a PR is altering the CLI output, files inside those directories might\nneed to be manually updated. This often happens when options are\nadded, removed or altered. Keep in mind that the version string line\n(example: `# Uncrustify-0.69.0_f`) of outputs from commands like\n`--show-config` should be replaced with a blank line.\n\n### Debugging\n\nThe first method is to use uncrustify itself to get debug informations.\nUsing:\n```.txt\n   uncrustify -c myExample.cfg -f myExample.cpp -p myExample.p -L A 2\u003emyExample.A\n```\nyou get two files for the first informations.\nThe p-file gives you details of the parsing process and indentation.\n```.txt\n# Line                Tag              Parent          Columns Br/Lvl/pp     Flag   Nl  Text\n#   1\u003e              CLASS[               NONE][  1/  1/  6/  0][0/0/0][  10070000][0-0] class\n#   1\u003e               TYPE[              CLASS][  7/  7/ 14/  1][0/0/0][  10000000][0-0]       Capteur\n#   1\u003e         BRACE_OPEN[              CLASS][ 15/ 15/ 16/  1][0/0/0][ 100000400][0-0]               {\n```\n\nThe A-file gives you many details about the run itself, where the process is running thru,\nwhich values have the most important variables.\n```.txt\ntokenize(2351): orig_line is 1, orig_col is 1, text() 'class', type is CLASS, orig_col_end is 6\ntokenize(2351): orig_line is 1, orig_col is 7, text() 'Capteur', type is WORD, orig_col_end is 14\ntokenize(2351): orig_line is 1, orig_col is 15, text() '{', type is BRACE_OPEN, orig_col_end is 16\n```\n\nIt might be usefull to add some code lines to see where something is happening.\nUse the package `unc_tools`.\nRemove the comment at line:\n```.cpp\n#define DEVELOP_ONLY\n```\nImport the package:\n```.cpp\n#include \"unc_tools.h\"\n```\nAdd at some places the line:\n```.cpp\nprot_the_line(__LINE__, 6, 0);\n```\nCompile again with DEBUG option.\n\n\n\n### How to add an option\n\nIf you need a new option, there are a few steps to follow.\nTake as example the option `sp_trailing_ret_t`\n\nFirst define the option:\n- Insert the code below to the file src/options.h\n_NOTE:\nThis file is processed by make_options.py, and must conform to a particular\nformat. Option groups are marked by '//begin ' (in upper case; this example\nis lower case to prevent being considered a region marker for code folding)\nfollowed by the group description. Options consist of two lines of\ndeclaration preceded by one or more lines of C++ comments. The comments form\nthe option description and are taken verbatim, aside from stripping the\nleading '// '. Only comments immediately preceding an option declaration,\nwith no blank lines, are taken as part of the description, so a blank line\nmay be used to separate notations from a description.\nAn option declaration is 'extern TYPE\\nNAME;', optionally followed by\n' // = VALUE' if the option has a default value that is different from the\ndefault-constructed value type of the option. The 'VALUE' must be valid C++\ncode, and is taken verbatim as an argument when creating the option's\ninstantiation. Note also that the line break, as shown, is required.\n_\n```.cpp\n// Add or remove space around trailing return operator '-\u003e'.\nextern Option\u003ciarf_e\u003e\nsp_trailing_ret_t;\n```\n- Insert the code below to the file src/space.cpp\n```.cpp\n   if (chunk_is_token(first, CT_TRAILING_RET_T))\n   {\n      // Add or remove space around trailing return operator '-\u003e'.\n      log_rule(\"sp_trailing_ret_t\");\n      return(options::sp_trailing_ret_t());\n   }\n```\n\n\n### Portability\n\nWe are pretty sure that nothing OS-specific is used in the code base.\nThe software has been previously tested on the following operating systems:\n- Linux\n- QNX\n- OS X\n- FreeBSD, NetBSD, OpenBSD\n- Sun Solaris 9\n- Windows (binary available)\n\n\n---------------------------------------------------------------------------\n\n## Running the program\n\n__NOTE__ This application works reasonably well but it has bugs. Do __not__\napply it on your whole codebase without checking the results!\n\nHere are ways to run it:\n```\n$ uncrustify -c mystyle.cfg -f somefile.c -o somefile.c.unc\n$ uncrustify -c mystyle.cfg -f somefile.c \u003e somefile.c.unc\n$ uncrustify -c mystyle.cfg somefile.c\n$ uncrustify -c mystyle.cfg --no-backup somefile.c\n$ uncrustify -c mystyle.cfg *.c\n$ uncrustify -c mystyle.cfg --no-backup *.c\n```\nThe `-c` flag selects the configuration file.\nThe `-f` flag specifies the input file.\nThe `-o` flag specifies the output file.\nIf flag `-f` is used without flag `-o` the output will be send to `stdout`.\n\nAlternatively multiple or single files that should be processed can be\nspecified at the command end without flags.\nIf the flag `--no-backup` is missing, every file is saved with the initial\nname and an additional suffix (can be changed with --suffix).\n\nFor more options descriptions call:\n```bash\n$ uncrustify -h\n```\n\n## Configuring the program\nUncrustify usually reads configuration files that are passed via the `-c`\nflag. If the flag is not provided Uncrustify will try to find a\nconfiguration file via the `UNCRUSTIFY_CONFIG` environment variable or a\nfile with the name `uncrustify` or `.uncrustify` in your home folder.\n\nTo get a list of:\n- all available options use:\n  ```bash\n  uncrustify --show-config\n  ```\n\n- all available options in a usable configuration file format use:\n  ```bash\n  uncrustify --update-config\n  ```\n\n  or\n\n  ```bash\n  uncrustify --update-config-with-doc\n  ```\n\n  As the names suggest both options can produce output that adds newly\n  introduced options to your old configuration file. For this your old\n  configuration file has to be passed via the `-c` flag:\n  ```bash\n  uncrustify --update-config-with-doc -c path/to/your.cfg\n  ```\n\nExample configuration files that can be used as a starting point can be\nfound in the `etc/` directory (such as [ben.cfg](./etc/ben.cfg)).\n\nModify to your liking. Use a quality side-by-side diff tool to determine\nif the program did what you wanted. Repeat until your style is refined.\n\nTo ease the process a bit, some 3rd party tools are available:\n- [Universal Indent GUI](http://universalindent.sourceforge.net/) - A\n  cross-platform graphical configuration file editor for many code\n  beautifiers, including Uncrustify.\n- [uncrustify_config](https://github.com/CDanU/uncrustify_config) - A web\n  configuration tool based on Uncrustify's emscripten interface.\n- [UncrustifyX](https://github.com/ryanmaxwell/UncrustifyX) - Uncrustify\n  utility and documentation browser for Mac OS X\n\nUnder Windows:\nUncrustify is a command-line tool, if you run it by double-clicking the\nexecutable, it will open a command prompt run the executable\n(which prints the help message), and then immediately close the window\nas uncrustify exits.\n\nYou can open the command prompt (which is an interactive terminal\nwindow that allows you to run commands without it closing as soon as\nthey exit) and run uncrustify.exe there.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlech%2Fmicropython-uncrustify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdlech%2Fmicropython-uncrustify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdlech%2Fmicropython-uncrustify/lists"}