[clang-tools-extra] [llvm] [clang-doc] Add basic e2e test (PR #93928)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 6 17:38:40 PDT 2024
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 98714866830f505d7bb87de6b92a28f280a34b9b 5a647f015051a572a36af6418fadb424db470cec -- clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Calculator.cpp clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Calculator.h clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Circle.cpp clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Circle.h clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Rectangle.cpp clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Rectangle.h clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Shape.h clang-tools-extra/test/clang-doc/clang-doc-project1.cpp clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 2e566db27b..15ad0b2404 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -81,9 +81,11 @@ static llvm::cl::list<std::string> UserStylesheets(
llvm::cl::desc("CSS stylesheets to extend the default styles."),
llvm::cl::cat(ClangDocCategory));
-static llvm::cl::opt<std::string> UserAssetPath(
- "asset", llvm::cl::desc("User supplied asset path for html output to override the default css and js files"),
- llvm::cl::cat(ClangDocCategory));
+static llvm::cl::opt<std::string>
+ UserAssetPath("asset",
+ llvm::cl::desc("User supplied asset path for html output to "
+ "override the default css and js files"),
+ llvm::cl::cat(ClangDocCategory));
static llvm::cl::opt<std::string> SourceRoot("source-root", llvm::cl::desc(R"(
Directory where processed files are stored.
@@ -135,10 +137,10 @@ std::string GetExecutablePath(const char *Argv0, void *MainAddr) {
return llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
}
-inline bool ends_with(std::string const & value, std::string const & ending)
-{
- if (ending.size() > value.size()) return false;
- return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
+inline bool ends_with(std::string const &value, std::string const &ending) {
+ if (ending.size() > value.size())
+ return false;
+ return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
}
int main(int argc, const char **argv) {
@@ -197,34 +199,32 @@ Example usage for a project using a compile commands database:
llvm::SmallString<128> NativeClangDocPath;
llvm::sys::path::native(ClangDocPath, NativeClangDocPath);
if (!UserAssetPath.empty()) {
- std::error_code code;
- llvm::sys::fs::directory_iterator dirIt(std::string(UserAssetPath), code);
- while (!code && dirIt != llvm::sys::fs::directory_iterator()) {
- std::basic_string<char> filePath = dirIt->path();
- if (llvm::sys::fs::is_regular_file(filePath)) {
- if (ends_with(filePath, ".css")) {
- CDCtx.UserStylesheets.push_back(filePath);
- }
- else if (ends_with(filePath, ".js")) {
- CDCtx.UserStylesheets.push_back(filePath);
- }
- }
+ std::error_code code;
+ llvm::sys::fs::directory_iterator dirIt(std::string(UserAssetPath), code);
+ while (!code && dirIt != llvm::sys::fs::directory_iterator()) {
+ std::basic_string<char> filePath = dirIt->path();
+ if (llvm::sys::fs::is_regular_file(filePath)) {
+ if (ends_with(filePath, ".css")) {
+ CDCtx.UserStylesheets.push_back(filePath);
+ } else if (ends_with(filePath, ".js")) {
+ CDCtx.UserStylesheets.push_back(filePath);
+ }
}
- }
- else {
- llvm::SmallString<128> AssetsPath;
- AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath);
- llvm::sys::path::append(AssetsPath, "..", "share", "clang");
- llvm::SmallString<128> DefaultStylesheet;
- llvm::sys::path::native(AssetsPath, DefaultStylesheet);
- llvm::sys::path::append(DefaultStylesheet,
- "clang-doc-default-stylesheet.css");
- llvm::SmallString<128> IndexJS;
- llvm::sys::path::native(AssetsPath, IndexJS);
- llvm::sys::path::append(IndexJS, "index.js");
- CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(),
- std::string(DefaultStylesheet));
- CDCtx.FilesToCopy.emplace_back(IndexJS.str());
+ }
+ } else {
+ llvm::SmallString<128> AssetsPath;
+ AssetsPath = llvm::sys::path::parent_path(NativeClangDocPath);
+ llvm::sys::path::append(AssetsPath, "..", "share", "clang");
+ llvm::SmallString<128> DefaultStylesheet;
+ llvm::sys::path::native(AssetsPath, DefaultStylesheet);
+ llvm::sys::path::append(DefaultStylesheet,
+ "clang-doc-default-stylesheet.css");
+ llvm::SmallString<128> IndexJS;
+ llvm::sys::path::native(AssetsPath, IndexJS);
+ llvm::sys::path::append(IndexJS, "index.js");
+ CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(),
+ std::string(DefaultStylesheet));
+ CDCtx.FilesToCopy.emplace_back(IndexJS.str());
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/93928
More information about the cfe-commits
mailing list