CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
79 lines
2.5 KiB
ReStructuredText
79 lines
2.5 KiB
ReStructuredText
=========
|
|
LibFormat
|
|
=========
|
|
|
|
LibFormat is a library that implements automatic source code formatting based
|
|
on Clang. This document describes the LibFormat interface and design as well
|
|
as some basic style discussions.
|
|
|
|
If you just want to use `clang-format` as a tool or integrated into an editor,
|
|
checkout :doc:`ClangFormat`.
|
|
|
|
Design
|
|
------
|
|
|
|
FIXME: Write up design.
|
|
|
|
|
|
Interface
|
|
---------
|
|
|
|
The core routine of LibFormat is ``reformat()``:
|
|
|
|
.. code-block:: c++
|
|
|
|
tooling::Replacements reformat(const FormatStyle &Style, Lexer &Lex,
|
|
SourceManager &SourceMgr,
|
|
std::vector<CharSourceRange> Ranges);
|
|
|
|
This reads a token stream out of the lexer ``Lex`` and reformats all the code
|
|
ranges in ``Ranges``. The ``FormatStyle`` controls basic decisions made during
|
|
formatting. A list of options can be found under :ref:`style-options`.
|
|
|
|
The style options are described in :doc:`ClangFormatStyleOptions`.
|
|
|
|
|
|
.. _style-options:
|
|
|
|
Style Options
|
|
-------------
|
|
|
|
The style options describe specific formatting options that can be used in
|
|
order to make `ClangFormat` comply with different style guides. Currently,
|
|
several style guides are hard-coded:
|
|
|
|
.. code-block:: c++
|
|
|
|
/// Returns a format style complying with the LLVM coding standards:
|
|
/// https://llvm.org/docs/CodingStandards.html.
|
|
FormatStyle getLLVMStyle();
|
|
|
|
/// Returns a format style complying with Google's C++ style guide:
|
|
/// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml.
|
|
FormatStyle getGoogleStyle();
|
|
|
|
/// Returns a format style complying with Chromium's style guide:
|
|
/// https://chromium.googlesource.com/chromium/src/+/refs/heads/main/styleguide/styleguide.md
|
|
FormatStyle getChromiumStyle();
|
|
|
|
/// Returns a format style complying with the GNU coding standards:
|
|
/// https://www.gnu.org/prep/standards/standards.html
|
|
FormatStyle getGNUStyle();
|
|
|
|
/// Returns a format style complying with Mozilla's style guide
|
|
/// https://firefox-source-docs.mozilla.org/code-quality/coding-style/index.html
|
|
FormatStyle getMozillaStyle();
|
|
|
|
/// Returns a format style complying with Webkit's style guide:
|
|
/// https://webkit.org/code-style-guidelines/
|
|
FormatStyle getWebkitStyle();
|
|
|
|
/// Returns a format style complying with Microsoft's style guide:
|
|
/// https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
|
|
FormatStyle getMicrosoftStyle();
|
|
|
|
These options are also exposed in the :doc:`standalone tools <ClangFormat>`
|
|
through the `-style` option.
|
|
|
|
In the future, we plan on making this configurable.
|