Skip to content

Commit

Permalink
[clang-format] NFC Document the other space before colon option
Browse files Browse the repository at this point in the history
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
  • Loading branch information
eywdck2l committed Apr 7, 2023
1 parent 5b7881b commit 8385ee0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions clang/docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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++

Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions clang/include/clang/Format/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
/// { {
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 8385ee0

Please sign in to comment.