Skip to content

clang_format

clang-format documentation

ClangFormat

Bases: Tool[_R]

Methods:

Name Description
__call__

OVERVIEW: A tool to format

Attributes:

Name Type Description
argv ClangFormat[Argv]

argv property

__call__

__call__(*args: str | PathLike[str], Werror: Flag = ..., Wno_error: Value = ..., assume_filename: Value = ..., cursor: Value = ..., dry_run: Flag = ..., dump_config: Flag = ..., fail_on_incomplete_format: Flag = ..., fallback_style: Value = ..., ferror_limit: Value = ..., files: Value = ..., help_list: Flag = ..., i: Flag = ..., length: Value = ..., lines: Value = ..., n: Flag = ..., offset: Value = ..., output_replacements_xml: Flag = ..., qualifier_alignment: Value = ..., sort_includes: Flag = ..., style: Value = ..., verbose: Flag = ..., **flags: Any) -> _R

OVERVIEW: A tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.

Parameters:

Name Type Description Default
Werror Flag
  • If set, changes formatting warnings to errors.
...
Wno_error Value
  • If set, don't error out on the specified warning type. May be repeated: a list emits the flag once per item.
...
assume_filename Value
  • Set filename used to determine the language and to find .clang-format file.
...
cursor Value
  • The position of the cursor when invoking clang-format from an editor integration.
...
dry_run Flag
  • If set, do not actually make the formatting changes.
...
dump_config Flag
  • Dump configuration options to stdout and exit.
...
fail_on_incomplete_format Flag
  • If set, fail with exit code 1 on incomplete format.
...
fallback_style Value
  • The name of the predefined style used as a fallback in case clang-format is invoked with -style=file, but can not find the .clang-format file to use.
...
ferror_limit Value
  • Set the maximum number of clang-format errors to emit before stopping (0 = no limit).
...
files Value
  • A file containing a list of files to process, one per line.
...
help_list Flag
  • Display list of available options (--help-list-hidden for more).
...
i Flag
  • Inplace edit s, if specified.
...
length Value
  • Format a range of this length (in bytes).
...
lines Value
  • : - format a range of lines (both 1-based).
...
n Flag
  • Alias for --dry-run.
...
offset Value
  • Format a range starting at this byte offset.
...
output_replacements_xml Flag
  • Output replacements as XML.
...
qualifier_alignment Value

determined by the QualifierAlignment style flag.

...
sort_includes Flag
  • If set, overrides the include sorting behavior determined by the SortIncludes style flag.
...
style Value
  • Set coding style.
...
verbose Flag
  • If set, shows the list of processed files.
...