Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/docs/ClangFormat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
Clang-format options:

--Werror - If set, changes formatting warnings to errors
--Wno-error=<value> - If set, don't error out on the specified warning type.
--Wno-error=<value> - If set don't error out on the specified warning type.
=unknown - If set, unknown format options are only warned about.
This can be used to enable formatting, even if the
configuration contains unknown (newer) options.
Expand All @@ -49,7 +49,7 @@ to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
supported:
CSharp: .cs
Java: .java
JavaScript: .js .mjs .cjs .ts
JavaScript: .mjs .js .ts
Json: .json
Objective-C: .m .mm
Proto: .proto .protodevel
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4086,8 +4086,10 @@ static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
return FormatStyle::LK_TableGen;
if (FileName.ends_with_insensitive(".cs"))
return FormatStyle::LK_CSharp;
if (FileName.ends_with_insensitive(".json"))
if (FileName.ends_with_insensitive(".json") ||
FileName.ends_with_insensitive(".ipynb")) {
return FormatStyle::LK_Json;
}
if (FileName.ends_with_insensitive(".sv") ||
FileName.ends_with_insensitive(".svh") ||
FileName.ends_with_insensitive(".v") ||
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/clang-format/ClangFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static cl::opt<std::string> AssumeFileName(
" CSharp: .cs\n"
" Java: .java\n"
" JavaScript: .js .mjs .cjs .ts\n"
" Json: .json\n"
" Json: .json .ipynb\n"
" Objective-C: .m .mm\n"
" Proto: .proto .protodevel\n"
" TableGen: .td\n"
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/clang-format/clang-format-diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def main():
"-iregex",
metavar="PATTERN",
default=r".*\.(?:cpp|cc|c\+\+|cxx|cppm|ccm|cxxm|c\+\+m|c|cl|h|hh|hpp"
r"|hxx|m|mm|inc|js|ts|proto|protodevel|java|cs|json|s?vh?)",
r"|hxx|m|mm|inc|js|ts|proto|protodevel|java|cs|json|ipynb|s?vh?)",
help="custom pattern selecting file paths to reformat "
"(case insensitive, overridden by -regex)",
)
Expand Down
3 changes: 2 additions & 1 deletion clang/tools/clang-format/git-clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ def main():
"cjs", # JavaScript
"ts", # TypeScript
"cs", # C Sharp
"json", # Json
"json",
"ipynb", # Json
"sv",
"svh",
"v",
Expand Down
Loading