[llvm-branch-commits] [clang-tools-extra] [clang-doc] integrate the JSON generator with Mustache templates (PR #149006)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jul 15 18:56:11 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- clang-tools-extra/clang-doc/BitcodeReader.cpp clang-tools-extra/clang-doc/BitcodeWriter.cpp clang-tools-extra/clang-doc/BitcodeWriter.h clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp clang-tools-extra/clang-doc/JSONGenerator.cpp clang-tools-extra/clang-doc/Representation.cpp clang-tools-extra/clang-doc/Representation.h clang-tools-extra/clang-doc/Serialize.cpp clang-tools-extra/test/clang-doc/json/class-requires.cpp clang-tools-extra/test/clang-doc/json/class-template.cpp clang-tools-extra/test/clang-doc/json/class.cpp clang-tools-extra/test/clang-doc/json/compound-constraints.cpp clang-tools-extra/test/clang-doc/json/concept.cpp clang-tools-extra/test/clang-doc/json/function-requires.cpp clang-tools-extra/test/clang-doc/json/method-template.cpp clang-tools-extra/test/clang-doc/json/namespace.cpp clang-tools-extra/test/clang-doc/json/nested-namespace.cpp clang-tools-extra/test/clang-doc/mustache-index.cpp clang-tools-extra/test/clang-doc/mustache-separate-namespace.cpp clang-tools-extra/unittests/clang-doc/HTMLMustacheGeneratorTest.cpp clang-tools-extra/unittests/clang-doc/JSONGeneratorTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
index a6839edcf..0a0046ce4 100644
--- a/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLMustacheGenerator.cpp
@@ -27,7 +27,9 @@ using namespace llvm::mustache;
namespace clang {
namespace doc {
-static Error generateDocForJSON(json::Value &JSON, StringRef Filename, StringRef Path, raw_fd_ostream &OS, const ClangDocContext &CDCtx);
+static Error generateDocForJSON(json::Value &JSON, StringRef Filename,
+ StringRef Path, raw_fd_ostream &OS,
+ const ClangDocContext &CDCtx);
static Error createFileOpenError(StringRef FileName, std::error_code EC) {
return createFileError("cannot open file " + FileName, EC);
@@ -164,7 +166,8 @@ Error MustacheHTMLGenerator::generateDocs(
auto Parsed = json::parse((*File)->getBuffer());
if (!Parsed)
- return Parsed.takeError();;
+ return Parsed.takeError();
+ ;
JSONFileMap.try_emplace(Path, *Parsed);
JSONIter.increment(EC);
}
@@ -183,8 +186,8 @@ Error MustacheHTMLGenerator::generateDocs(
if (FileErr)
return createFileOpenError(File.getKey(), FileErr);
- if (Error Err =
- generateDocForJSON(JSON, sys::path::stem(PathModStr), PathModStr, InfoOS, CDCtx))
+ if (Error Err = generateDocForJSON(JSON, sys::path::stem(PathModStr),
+ PathModStr, InfoOS, CDCtx))
return Err;
}
}
@@ -221,16 +224,21 @@ static Error setupTemplateValue(const ClangDocContext &CDCtx, json::Value &V,
return Error::success();
}
-static Error generateDocForJSON(json::Value &JSON, StringRef Filename, StringRef Path, raw_fd_ostream &OS, const ClangDocContext &CDCtx) {
- auto StrValue = (*JSON.getAsObject())["InfoType"];
+static Error generateDocForJSON(json::Value &JSON, StringRef Filename,
+ StringRef Path, raw_fd_ostream &OS,
+ const ClangDocContext &CDCtx) {
+ auto StrValue = (*JSON.getAsObject())["InfoType"];
if (StrValue.kind() != json::Value::Kind::String)
- return createStringError("JSON file '%s' does not contain 'InfoType' field.", Filename.str().c_str());
+ return createStringError(
+ "JSON file '%s' does not contain 'InfoType' field.",
+ Filename.str().c_str());
auto ObjTypeStr = StrValue.getAsString();
if (!ObjTypeStr.has_value())
- return createStringError("JSON file '%s' does not contain 'InfoType' field as a string.", Filename.str().c_str());
+ return createStringError(
+ "JSON file '%s' does not contain 'InfoType' field as a string.",
+ Filename.str().c_str());
-
- if (ObjTypeStr.value() == "namespace") {
+ if (ObjTypeStr.value() == "namespace") {
if (auto Err = setupTemplateValue(CDCtx, JSON, Path))
return Err;
assert(NamespaceTemplate && "NamespaceTemplate is nullptr.");
``````````
</details>
https://github.com/llvm/llvm-project/pull/149006
More information about the llvm-branch-commits
mailing list