[clang] 8385ee0 - [clang-format] NFC Document the other space before colon option
via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 7 06:52:44 PDT 2023
Author: sstwcw
Date: 2023-04-07T13:52:18Z
New Revision: 8385ee05e59d2e05f0040c5dbdd0580b3e75f36b
URL: https://github.com/llvm/llvm-project/commit/8385ee05e59d2e05f0040c5dbdd0580b3e75f36b
DIFF: https://github.com/llvm/llvm-project/commit/8385ee05e59d2e05f0040c5dbdd0580b3e75f36b.diff
LOG: [clang-format] NFC Document the other space before colon option
There are two options that do much the same thing, but for different
languages. With the addition to the doc, the user is less likely to
configure the wrong option and get frustrated that it doesn't work.
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D147422
Added:
Modified:
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
Removed:
################################################################################
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index f8ab42f46ba81..899d5b2df6031 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -4782,7 +4782,8 @@ the configuration (without a prefix: ``Auto``).
.. _SpaceBeforeJsonColon:
**SpaceBeforeJsonColon** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ <SpaceBeforeJsonColon>`
- If ``true``, a space will be add before a JSON colon.
+ If ``true``, a space will be added before a JSON colon. For other
+ languages, e.g. JavaScript, use ``SpacesInContainerLiterals`` instead.
.. code-block:: c++
@@ -5100,8 +5101,9 @@ the configuration (without a prefix: ``Auto``).
.. _SpacesInContainerLiterals:
**SpacesInContainerLiterals** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ <SpacesInContainerLiterals>`
- If ``true``, spaces are inserted inside container literals (e.g.
- ObjC and Javascript array and dict literals).
+ If ``true``, spaces are inserted inside container literals (e.g. ObjC and
+ Javascript array and dict literals). For JSON, use
+ ``SpaceBeforeJsonColon`` instead.
.. code-block:: js
diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h
index 0dfa052822458..980e6297fd6ac 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3749,7 +3749,8 @@ struct FormatStyle {
/// \version 7
bool SpaceBeforeInheritanceColon;
- /// If ``true``, a space will be add before a JSON colon.
+ /// If ``true``, a space will be added before a JSON colon. For other
+ /// languages, e.g. JavaScript, use ``SpacesInContainerLiterals`` instead.
/// \code
/// true: false:
/// { {
@@ -4032,8 +4033,9 @@ struct FormatStyle {
/// \version 10
bool SpacesInConditionalStatement;
- /// If ``true``, spaces are inserted inside container literals (e.g.
- /// ObjC and Javascript array and dict literals).
+ /// If ``true``, spaces are inserted inside container literals (e.g. ObjC and
+ /// Javascript array and dict literals). For JSON, use
+ /// ``SpaceBeforeJsonColon`` instead.
/// \code{.js}
/// true: false:
/// var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3];
More information about the cfe-commits
mailing list