diff --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst index e1f677178c00a..92af06e5083d6 100644 --- a/clang/docs/ClangFormat.rst +++ b/clang/docs/ClangFormat.rst @@ -50,7 +50,7 @@ to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code. CSharp: .cs Java: .java JavaScript: .js .mjs .cjs .ts - Json: .json + Json: .json .ipynb Objective-C: .m .mm Proto: .proto .protodevel TableGen: .td diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index eec5cc8632168..b90bd8276e1e2 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -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") || diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index 28610052b9b74..c45e3a2c28327 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -88,7 +88,7 @@ static cl::opt 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" diff --git a/clang/tools/clang-format/clang-format-diff.py b/clang/tools/clang-format/clang-format-diff.py index aebe193eadb34..c82b41e8bd031 100755 --- a/clang/tools/clang-format/clang-format-diff.py +++ b/clang/tools/clang-format/clang-format-diff.py @@ -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)", ) diff --git a/clang/tools/clang-format/git-clang-format b/clang/tools/clang-format/git-clang-format index 85eff4761e289..2d2c117601c2f 100755 --- a/clang/tools/clang-format/git-clang-format +++ b/clang/tools/clang-format/git-clang-format @@ -115,7 +115,8 @@ def main(): "cjs", # JavaScript "ts", # TypeScript "cs", # C Sharp - "json", # Json + "json", + "ipynb", # Json "sv", "svh", "v",