#!/bin/bash ## ------------------------------------------------------------------------ ## ## SPDX-License-Identifier: LGPL-2.1-or-later ## Copyright (C) 2012 - 2025 by the deal.II authors ## ## This file is part of the deal.II library. ## ## Part of the source code is dual licensed under Apache-2.0 WITH ## LLVM-exception OR LGPL-2.1-or-later. Detailed license information ## governing the source code and code contributions can be found in ## LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. ## ## ------------------------------------------------------------------------ # # This script indents all source files of deal.II according to our usual # code formatting standards. It is used to ensure that our code base looks # uniform, as uniformity helps make code easier to read. # # While we're already touching every file, this script also makes # sure we set permissions correctly and checks for correct unix-style line # endings. # # The script needs to be executed as # ./contrib/utilities/indent-all # from the top-level directory of the source tree, or via # make indent-all # from a build directory. # # The script can be invoked with DEAL_II_CLANG_FORMAT to change # the default version of clang-format. For example: # DEAL_II_CLANG_FORMAT=clang-format-16.0 ./contrib/utilities/indent-all # or, # make DEAL_II_CLANG_FORMAT="clang-format-16.0" indent-all # # Note: If the script is invoked with REPORT_ONLY=true set, # REPORT_ONLY=true ./contrib/utilities/indent-all # or, # make REPORT_ONLY=true indent-all # then indentation errors will only be reported without any actual file # changes. # if [ ! -f contrib/utilities/indent-all ]; then echo "*** This script must be run from the top-level directory of deal.II." exit 1 fi if [ ! -f contrib/utilities/indent_common.sh ]; then echo "*** This script requires contrib/utilities/indent_common.sh." exit 1 fi source contrib/utilities/indent_common.sh # # Run sanity checks: # checks # # Process all source and header files: # process "tests include source module examples contrib/python-bindings" ".*\.(cc|ccm|h)" format_file process "source" ".*\.inst.in" format_inst process "tests include source examples contrib" ".*\.py" format_python_file # # Fix permissions and convert to unix line ending if necessary: # process "tests include source examples cmake/scripts contrib/python-bindings" \ ".*\.(cc|h|inst.in|output.*|cmake)" fix_permissions process "doc/news/*/*" "doc/news/.*/.*/[0-9].*" fix_permissions process "tests include source examples cmake/scripts contrib/python-bindings" \ ".*\.(cc|h|inst.in|cmake)" dos_to_unix process "doc/news/*/*" "doc/news/.*/.*/[0-9].*" dos_to_unix process "tests include source examples contrib" ".*\.py" dos_to_unix # # Removing trailing whitespace # process "tests include source examples cmake/scripts contrib/python-bindings doc" \ ".*\.(cc|h|html|dox|txt)" remove_trailing_whitespace process "doc/news/*/*" "doc/news/.*/.*/[0-9].*" remove_trailing_whitespace process "tests include source examples contrib" ".*\.py" remove_trailing_whitespace # # Ensure only a single newline at end of files # process "tests include source examples cmake/scripts contrib/python-bindings doc" \ ".*\.(cc|h|html|dox|txt)" ensure_single_trailing_newline process "doc/news/*/*" "doc/news/.*/.*/[0-9].*" ensure_single_trailing_newline process "tests include source examples contrib" ".*\.py" ensure_single_trailing_newline