Skip to content

Commit c893f1d

Browse files
authored
Treat ipynb as json (#135137)
Fixes #110727
1 parent 8bea91f commit c893f1d

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

clang/docs/ClangFormat.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
5050
CSharp: .cs
5151
Java: .java
5252
JavaScript: .js .mjs .cjs .ts
53-
Json: .json
53+
Json: .json .ipynb
5454
Objective-C: .m .mm
5555
Proto: .proto .protodevel
5656
TableGen: .td

clang/lib/Format/Format.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4086,8 +4086,10 @@ static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
40864086
return FormatStyle::LK_TableGen;
40874087
if (FileName.ends_with_insensitive(".cs"))
40884088
return FormatStyle::LK_CSharp;
4089-
if (FileName.ends_with_insensitive(".json"))
4089+
if (FileName.ends_with_insensitive(".json") ||
4090+
FileName.ends_with_insensitive(".ipynb")) {
40904091
return FormatStyle::LK_Json;
4092+
}
40914093
if (FileName.ends_with_insensitive(".sv") ||
40924094
FileName.ends_with_insensitive(".svh") ||
40934095
FileName.ends_with_insensitive(".v") ||

clang/tools/clang-format/ClangFormat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static cl::opt<std::string> AssumeFileName(
8888
" CSharp: .cs\n"
8989
" Java: .java\n"
9090
" JavaScript: .js .mjs .cjs .ts\n"
91-
" Json: .json\n"
91+
" Json: .json .ipynb\n"
9292
" Objective-C: .m .mm\n"
9393
" Proto: .proto .protodevel\n"
9494
" TableGen: .td\n"

clang/tools/clang-format/clang-format-diff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def main():
6363
"-iregex",
6464
metavar="PATTERN",
6565
default=r".*\.(?:cpp|cc|c\+\+|cxx|cppm|ccm|cxxm|c\+\+m|c|cl|h|hh|hpp"
66-
r"|hxx|m|mm|inc|js|ts|proto|protodevel|java|cs|json|s?vh?)",
66+
r"|hxx|m|mm|inc|js|ts|proto|protodevel|java|cs|json|ipynb|s?vh?)",
6767
help="custom pattern selecting file paths to reformat "
6868
"(case insensitive, overridden by -regex)",
6969
)

clang/tools/clang-format/git-clang-format

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ def main():
116116
"cjs", # JavaScript
117117
"ts", # TypeScript
118118
"cs", # C Sharp
119-
"json", # Json
119+
"json",
120+
"ipynb", # Json
120121
"sv",
121122
"svh",
122123
"v",

0 commit comments

Comments
 (0)