Doc: Describe changes to ClangFormat preferences

Task-number: QTCREATORBUG-30209
Change-Id: Iff7587cca92c016f2f6ff5f40150d620f623a9b2
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
This commit is contained in:
Leena Miettinen
2024-02-06 19:02:24 +01:00
parent 0d40cc5093
commit 8869fefb72
11 changed files with 56 additions and 64 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
@@ -18,30 +18,39 @@
To specify global indentation settings for the C++ editor:
\list 1
\li Select \preferences > \uicontrol {C++}.
\li Go to \preferences > \uicontrol {C++}.
\image qtcreator-code-style-clang-format-global.webp {Code Style preferences}
\li In \uicontrol {Formatting mode}, select:
\list
\li \uicontrol {Indenting Only} to only indent code.
\li \uicontrol {Full Formatting} to use the \key {Ctrl+I}
keyboard shortcut to format code instead of indenting.
\li \uicontrol Disable to turn off ClangFormat.
\li \uicontrol {Use Built-In Indenter} to turn off ClangFormat.
\endlist
\li Select \uicontrol {Ignore files greater than} to make parsing faster
by ignoring big files. Specify the maximum size of files to parse.
\li To apply the formatting while you type, select
\uicontrol {Format while typing}.
\li To apply the formatting to the edited code when you save the file,
select \uicontrol {Format edited code on file save}.
\li To change the ClangFormat style globally for all projects,
select \uicontrol {Override ClangFormat configuration file}.
\li In the \uicontrol {Current settings} field, select the settings to
modify and click \uicontrol Copy.
\li Give a name to the settings and click \uicontrol OK.
\li Click \uicontrol Edit to set
select \uicontrol {Use custom settings}.
\li In \uicontrol {Custom settings}, select the settings to change, and
then select \uicontrol Copy.
\li Give a name to the settings, and select \uicontrol OK.
\li In \uicontrol ClangFormat, edit the
\l{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}
{ClangFormat Style Options}.
{ClangFormat Style Options}. The live preview shows how the
preferences change the indentation.
If you enter invalid values, you see warning messages.
\endlist
In the other tabs, you can specify how to:
\section1 Using Built-In Indenter
\image qtcreator-code-style-built-in-indenter.webp {Code Style preferences for built-in indenter}
If you select \uicontrol {Use Built-In Indenter} in
\uicontrol {Formatting mode}, you can specify how to:
\list
\li Interpret the \key Tab and \key Backspace key presses.
@@ -52,12 +61,9 @@
\li Bind pointers (*) and references (&) in types and declarations to
identifiers, type names, or left or right \c const or \c volatile
keywords.
\li Name getter functions.
\endlist
Use the live preview to see how the preferences change the indentation.
\section1 Specifying Settings for Content
\section2 Specifying Settings for Content
You can indent public, protected, and private statements and declarations
related to them within classes.
@@ -67,24 +73,24 @@
\image qtcreator-code-style-content.png {Content preferences}
\section1 Specifying Settings for Braces
\section2 Specifying Settings for Braces
You can indent class, namespace, enum and function declarations and code
blocks.
\image qtcreator-code-style-braces.png {Braces preferences}
\section1 Specifying Settings for Switch Statements
\section2 Specifying Settings for Switch Statements
You can indent case or default statements, or statements or blocks related
to them within switch statements.
\image qtcreator-code-style-switch.png {Switch preferences}
\section1 Specifying Alignment
\section2 Specifying Alignment
To align continuation lines to tokens after assignments, such as \c = or
\c +=, select the \uicontrol {Align after assignments} check box. You can
\c +=, select \uicontrol {Align after assignments}. You can
specify additional settings for aligning continuation lines in the
\uicontrol General tab.
@@ -94,7 +100,7 @@
\image qtcreator-code-style-alignment.png {Alignment preferences}
\section1 Binding Pointers and References
\section2 Binding Pointers and References
To bind pointers (\c *) and references (\c &) in types and declarations to
identifiers, type names, or left or right \c const or \c volatile keywords,
@@ -105,15 +111,6 @@
\image qtcreator-pointers-references.png {Pointers and References preferences}
\section1 Creating Project-Specific ClangFormat Files
To override the \c {.clang-format} file for a particular project, create a
copy of the built-in style and edit its settings by selecting
\uicontrol Projects > \uicontrol {Project Settings} >
\uicontrol {Code Style} > \uicontrol Copy > \uicontrol Edit >
\uicontrol {ClangFormat} >
\uicontrol {Override ClangFormat configuration file}.
\section1 Creating ClangFormat Files from Command Line
You can create \c {.clang-format} files that have the configuration
@@ -124,5 +121,6 @@
clang-format -style=llvm -dump-config > .clang-format
\endcode
\sa {Indent text or code}, {Behavior}, {Qt Quick Code Style}, {Nim}
\sa {Indent text or code}, {Specify code style}, {Behavior},
{Qt Quick Code Style}, {Nim}
*/

View File

@@ -16,11 +16,11 @@
To specify preferences for the Nim editor (experimental):
\list 1
\li Select \preferences > \uicontrol Nim.
\li In the \uicontrol {Current settings} field, select the settings to
modify and click \uicontrol Copy.
\li Go to \preferences > \uicontrol Nim.
\li In \uicontrol {Custom settings}, select the settings to
modify, and then select \uicontrol Copy.
\image qtcreator-preferences-nim-code-style.webp {Nim Code Style preferences}
\li Give a name to the settings and click \uicontrol OK.
\li Give a name to the settings, and select \uicontrol OK.
\li Specify how to interpret the \key Tab key presses and how to align
continuation lines.
\li Select \uicontrol OK to save the settings.
@@ -36,7 +36,7 @@
completion.
To use Nimsuggest, you must install it on the development PC and enter the
path to the tool executable in the \uicontrol Path field.
path to the tool executable in \uicontrol Path.
\image qtcreator-preferences-nim-tools.webp

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2023 The Qt Company Ltd.
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
// **********************************************************************
@@ -19,16 +19,15 @@
and editor the file opens in. \QC opens C++ files in \uicontrol Edit mode
in the C++ code editor and QML files in the Qt Quick editor.
You can specify indentation for:
Specify indentation for:
\list
\li C++ files
\li QML files
\li Nim files
\li Other text files
\endlist
You can specify code style either globally or separately for each project.
Specify code style either globally or separately for each project.
You can specify several sets of code style settings and easily switch between
them. In addition, you can import and export code style settings.
@@ -36,31 +35,30 @@
\list 1
\li Select \uicontrol Projects > \uicontrol {Project Settings} >
\li Go to \uicontrol Projects > \uicontrol {Project Settings} >
\uicontrol {Code Style}.
\image qtcreator-code-style-clang-format-project.webp {Code Style settings in Projects mode}
\li In the \uicontrol Language field, select \uicontrol C++,
\li In \uicontrol Language, select \uicontrol C++,
\uicontrol {Qt Quick}, or \uicontrol Nim.
\li Deselect the \uicontrol {Use global settings} check box.
\li For C++, clear \uicontrol {Use global settings} to use the
\c {.clang-format} file for the project.
\li In the \uicontrol {Current settings} field, select the settings to modify
and click \uicontrol Copy.
\li Give a name to the settings and click \uicontrol OK.
\li Click \uicontrol Edit to specify a code style for the project.
\li To override the project's \c {.clang-format} file,
select \uicontrol {Use custom settings}.
\li In \uicontrol {Custom settings}, select the settings to use for the
project.
\endlist
In rare cases, ClangFormat can trip over a code construct and
trigger a \QC crash. If that happens for your project, select
\uicontrol Disable as the formatting mode to switch
ClangFormat off for the project. If you can reproduce the crash,
please select \uicontrol Help > \uicontrol {Report Bug} to report
the bug and and attach the code that triggers the crash.
\uicontrol {Use Built-In Indenter} in \uicontrol {Formatting mode} to
turn off ClangFormat for the project. If you can reproduce the crash,
go to \uicontrol Help > \uicontrol {Report Bug} to report
the bug and attach the code that triggers the crash to the bug report.
\sa {Indent text or code}, {Edit MIME types}, {C++ Code Style},
{Qt Quick Code Style}, {Nim}

View File

@@ -19,20 +19,16 @@
To specify QML code style globally:
\list 1
\li Select \preferences > \uicontrol {Qt Quick}.
\li In the \uicontrol {Current settings} field, select the settings to
modify and click \uicontrol Copy.
\image qtcreator-options-code-style-qml.png {QML Code Style preferences}
\li Give a name to the settings and click \uicontrol OK.
\li Click \uicontrol Edit to specify code style settings for the project.
\image qtcreator-code-style-settings-edit-qtquick.png {Edit Code Style dialog}
\endlist
You can specify how to interpret the \key Tab key presses and how to align
\li Go to \preferences > \uicontrol {Qt Quick} > \uicontrol {Code Style}.
\li In \uicontrol {Custom settings}, select the settings to
modify, and then select \uicontrol Copy.
\image qtcreator-preferences-qtquick-code-style.webp {Qt Quick Code Style preferences}
\li Give a name to the settings, and select \uicontrol OK.
\li Specify how to interpret the \key Tab key presses and how to align
continuation lines.
In \uicontrol {Line length}, you can adjust the maximum line length for
\li In \uicontrol {Line length}, set the maximum line length for
code lines.
\endlist
To override the global preferences for a particular project, select
\uicontrol Projects > \uicontrol {Code Style}.