[clang-doc] place HTML/JSON output inside their own directories (#150655)
Instead of just outputting everything into the designated root folder, HTML and JSON output will be placed in html/ and json/ directories.
This commit is contained in:
parent
cbfc22c06b
commit
4f007041a8
@ -144,17 +144,22 @@ Error MustacheHTMLGenerator::generateDocs(
|
||||
} else
|
||||
return JSONGenerator.takeError();
|
||||
}
|
||||
SmallString<128> JSONPath;
|
||||
sys::path::native(RootDir.str() + "/json", JSONPath);
|
||||
|
||||
StringMap<json::Value> JSONFileMap;
|
||||
{
|
||||
llvm::TimeTraceScope TS("Iterate JSON files");
|
||||
std::error_code EC;
|
||||
sys::fs::directory_iterator JSONIter(RootDir, EC);
|
||||
sys::fs::directory_iterator JSONIter(JSONPath, EC);
|
||||
std::vector<json::Value> JSONFiles;
|
||||
JSONFiles.reserve(Infos.size());
|
||||
if (EC)
|
||||
return createStringError("Failed to create directory iterator.");
|
||||
|
||||
SmallString<128> HTMLDirPath(RootDir.str() + "/html/");
|
||||
if (auto EC = sys::fs::create_directories(HTMLDirPath))
|
||||
return createFileError(HTMLDirPath, EC);
|
||||
while (JSONIter != sys::fs::directory_iterator()) {
|
||||
if (EC)
|
||||
return createFileError("Failed to iterate: " + JSONIter->path(), EC);
|
||||
@ -177,14 +182,15 @@ Error MustacheHTMLGenerator::generateDocs(
|
||||
return Parsed.takeError();
|
||||
|
||||
std::error_code FileErr;
|
||||
SmallString<16> HTMLPath(Path.begin(), Path.end());
|
||||
sys::path::replace_extension(HTMLPath, "html");
|
||||
raw_fd_ostream InfoOS(HTMLPath, FileErr, sys::fs::OF_None);
|
||||
SmallString<128> HTMLFilePath(HTMLDirPath);
|
||||
sys::path::append(HTMLFilePath, sys::path::filename(Path));
|
||||
sys::path::replace_extension(HTMLFilePath, "html");
|
||||
raw_fd_ostream InfoOS(HTMLFilePath, FileErr, sys::fs::OF_None);
|
||||
if (FileErr)
|
||||
return createFileOpenError(Path, FileErr);
|
||||
|
||||
if (Error Err = generateDocForJSON(*Parsed, sys::path::stem(HTMLPath),
|
||||
HTMLPath, InfoOS, CDCtx))
|
||||
if (Error Err = generateDocForJSON(*Parsed, sys::path::stem(HTMLFilePath),
|
||||
HTMLFilePath, InfoOS, CDCtx))
|
||||
return Err;
|
||||
JSONIter.increment(EC);
|
||||
}
|
||||
|
@ -600,7 +600,9 @@ Error JSONGenerator::generateDocs(
|
||||
Info *Info = Group.getValue().get();
|
||||
|
||||
SmallString<128> Path;
|
||||
sys::path::native(RootDir, Path);
|
||||
auto RootDirStr = RootDir.str() + "/json";
|
||||
StringRef JSONDir = StringRef(RootDirStr);
|
||||
sys::path::native(JSONDir, Path);
|
||||
if (!CreatedDirs.contains(Path)) {
|
||||
if (std::error_code Err = sys::fs::create_directories(Path);
|
||||
Err != std::error_code())
|
||||
|
@ -2,10 +2,10 @@
|
||||
// RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json > %t/build/compile_commands.json
|
||||
|
||||
// RUN: clang-doc --format=mustache --output=%t/docs --executor=all-TUs %t/build/compile_commands.json
|
||||
// RUN: FileCheck %s -input-file=%t/docs/_ZTV5Shape.html -check-prefix=HTML-SHAPE
|
||||
// RUN: FileCheck %s -input-file=%t/docs/_ZTV10Calculator.html -check-prefix=HTML-CALC
|
||||
// RUN: FileCheck %s -input-file=%t/docs/_ZTV9Rectangle.html -check-prefix=HTML-RECTANGLE
|
||||
// RUN: FileCheck %s -input-file=%t/docs/_ZTV6Circle.html -check-prefix=HTML-CIRCLE
|
||||
// RUN: FileCheck %s -input-file=%t/docs/html/_ZTV5Shape.html -check-prefix=HTML-SHAPE
|
||||
// RUN: FileCheck %s -input-file=%t/docs/html/_ZTV10Calculator.html -check-prefix=HTML-CALC
|
||||
// RUN: FileCheck %s -input-file=%t/docs/html/_ZTV9Rectangle.html -check-prefix=HTML-RECTANGLE
|
||||
// RUN: FileCheck %s -input-file=%t/docs/html/_ZTV6Circle.html -check-prefix=HTML-CIRCLE
|
||||
|
||||
HTML-SHAPE: <html lang="en-US">
|
||||
HTML-SHAPE: <head>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: rm -rf %t && mkdir -p %t
|
||||
// RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s
|
||||
// RUN: FileCheck %s < %t/_ZTV7MyClass.json
|
||||
// RUN: FileCheck %s < %t/json/_ZTV7MyClass.json
|
||||
|
||||
template<typename T>
|
||||
concept Addable = requires(T a, T b) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// RUN: rm -rf %t && mkdir -p %t
|
||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
||||
// RUN: FileCheck %s < %t/_ZTV7MyClass.json --check-prefix=BASE
|
||||
// RUN: FileCheck %s < %t/_ZTV7MyClassIiE.json --check-prefix=SPECIALIZATION
|
||||
// RUN: FileCheck %s < %t/json/_ZTV7MyClass.json --check-prefix=BASE
|
||||
// RUN: FileCheck %s < %t/json/_ZTV7MyClassIiE.json --check-prefix=SPECIALIZATION
|
||||
|
||||
template<typename T> struct MyClass {};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: rm -rf %t && mkdir -p %t
|
||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
||||
// RUN: FileCheck %s < %t/_ZTV7MyClass.json
|
||||
// RUN: FileCheck %s < %t/json/_ZTV7MyClass.json
|
||||
|
||||
template<typename T> struct MyClass {
|
||||
T MemberTemplate;
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: rm -rf %t && mkdir -p %t
|
||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
||||
// RUN: FileCheck %s < %t/_ZTV7MyClass.json
|
||||
// RUN: FileCheck %s < %t/json/_ZTV7MyClass.json
|
||||
|
||||
struct Foo;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: rm -rf %t && mkdir -p %t
|
||||
// RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s
|
||||
// RUN: FileCheck %s < %t/index.json
|
||||
// RUN: FileCheck %s < %t/json/index.json
|
||||
|
||||
template<typename T> concept Incrementable = requires (T a) {
|
||||
a++;
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: rm -rf %t && mkdir -p %t
|
||||
// RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s
|
||||
// RUN: FileCheck %s < %t/index.json
|
||||
// RUN: FileCheck %s < %t/json/index.json
|
||||
|
||||
// Requires that T suports post and pre-incrementing.
|
||||
template<typename T>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: rm -rf %t && mkdir -p %t
|
||||
// RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s
|
||||
// RUN: FileCheck %s < %t/index.json
|
||||
// RUN: FileCheck %s < %t/json/index.json
|
||||
|
||||
template<typename T>
|
||||
concept Incrementable = requires(T x) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: rm -rf %t && mkdir -p %t
|
||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
||||
// RUN: FileCheck %s < %t/index.json
|
||||
// RUN: FileCheck %s < %t/json/index.json
|
||||
|
||||
static void myFunction() {}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: rm -rf %t && mkdir -p %t
|
||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
||||
// RUN: FileCheck %s < %t/_ZTV7MyClass.json
|
||||
// RUN: FileCheck %s < %t/json/_ZTV7MyClass.json
|
||||
|
||||
struct MyClass {
|
||||
template<class T> T methodTemplate(T param) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: rm -rf %t && mkdir -p %t
|
||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
||||
// RUN: FileCheck %s < %t/index.json
|
||||
// RUN: FileCheck %s < %t/json/index.json
|
||||
|
||||
class MyClass {};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
// RUN: rm -rf %t && mkdir -p %t
|
||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
||||
// RUN: FileCheck %s < %t/nested.json --check-prefix=NESTED
|
||||
// RUN: FileCheck %s < %t/inner.json --check-prefix=INNER
|
||||
// RUN: FileCheck %s < %t/json/nested.json --check-prefix=NESTED
|
||||
// RUN: FileCheck %s < %t/json/inner.json --check-prefix=INNER
|
||||
|
||||
namespace nested {
|
||||
int Global;
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: rm -rf %t && mkdir -p %t
|
||||
// RUN: clang-doc --format=mustache --output=%t --executor=standalone %s
|
||||
// RUN: FileCheck %s < %t/index.html
|
||||
// RUN: FileCheck %s < %t/html/index.html
|
||||
|
||||
enum Color {
|
||||
RED,
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: rm -rf %t && mkdir -p %t
|
||||
// RUN: clang-doc --format=mustache --output=%t --executor=standalone %s
|
||||
// RUN: FileCheck %s < %t/MyNamespace.html
|
||||
// RUN: FileCheck %s < %t/html/MyNamespace.html
|
||||
|
||||
namespace MyNamespace {
|
||||
class Foo;
|
||||
|
Loading…
x
Reference in New Issue
Block a user