[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
|
} else
|
||||||
return JSONGenerator.takeError();
|
return JSONGenerator.takeError();
|
||||||
}
|
}
|
||||||
|
SmallString<128> JSONPath;
|
||||||
|
sys::path::native(RootDir.str() + "/json", JSONPath);
|
||||||
|
|
||||||
StringMap<json::Value> JSONFileMap;
|
StringMap<json::Value> JSONFileMap;
|
||||||
{
|
{
|
||||||
llvm::TimeTraceScope TS("Iterate JSON files");
|
llvm::TimeTraceScope TS("Iterate JSON files");
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
sys::fs::directory_iterator JSONIter(RootDir, EC);
|
sys::fs::directory_iterator JSONIter(JSONPath, EC);
|
||||||
std::vector<json::Value> JSONFiles;
|
std::vector<json::Value> JSONFiles;
|
||||||
JSONFiles.reserve(Infos.size());
|
JSONFiles.reserve(Infos.size());
|
||||||
if (EC)
|
if (EC)
|
||||||
return createStringError("Failed to create directory iterator.");
|
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()) {
|
while (JSONIter != sys::fs::directory_iterator()) {
|
||||||
if (EC)
|
if (EC)
|
||||||
return createFileError("Failed to iterate: " + JSONIter->path(), EC);
|
return createFileError("Failed to iterate: " + JSONIter->path(), EC);
|
||||||
@ -177,14 +182,15 @@ Error MustacheHTMLGenerator::generateDocs(
|
|||||||
return Parsed.takeError();
|
return Parsed.takeError();
|
||||||
|
|
||||||
std::error_code FileErr;
|
std::error_code FileErr;
|
||||||
SmallString<16> HTMLPath(Path.begin(), Path.end());
|
SmallString<128> HTMLFilePath(HTMLDirPath);
|
||||||
sys::path::replace_extension(HTMLPath, "html");
|
sys::path::append(HTMLFilePath, sys::path::filename(Path));
|
||||||
raw_fd_ostream InfoOS(HTMLPath, FileErr, sys::fs::OF_None);
|
sys::path::replace_extension(HTMLFilePath, "html");
|
||||||
|
raw_fd_ostream InfoOS(HTMLFilePath, FileErr, sys::fs::OF_None);
|
||||||
if (FileErr)
|
if (FileErr)
|
||||||
return createFileOpenError(Path, FileErr);
|
return createFileOpenError(Path, FileErr);
|
||||||
|
|
||||||
if (Error Err = generateDocForJSON(*Parsed, sys::path::stem(HTMLPath),
|
if (Error Err = generateDocForJSON(*Parsed, sys::path::stem(HTMLFilePath),
|
||||||
HTMLPath, InfoOS, CDCtx))
|
HTMLFilePath, InfoOS, CDCtx))
|
||||||
return Err;
|
return Err;
|
||||||
JSONIter.increment(EC);
|
JSONIter.increment(EC);
|
||||||
}
|
}
|
||||||
|
@ -600,7 +600,9 @@ Error JSONGenerator::generateDocs(
|
|||||||
Info *Info = Group.getValue().get();
|
Info *Info = Group.getValue().get();
|
||||||
|
|
||||||
SmallString<128> Path;
|
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 (!CreatedDirs.contains(Path)) {
|
||||||
if (std::error_code Err = sys::fs::create_directories(Path);
|
if (std::error_code Err = sys::fs::create_directories(Path);
|
||||||
Err != std::error_code())
|
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: 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: 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/html/_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/html/_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/html/_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/_ZTV6Circle.html -check-prefix=HTML-CIRCLE
|
||||||
|
|
||||||
HTML-SHAPE: <html lang="en-US">
|
HTML-SHAPE: <html lang="en-US">
|
||||||
HTML-SHAPE: <head>
|
HTML-SHAPE: <head>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// RUN: rm -rf %t && mkdir -p %t
|
// RUN: rm -rf %t && mkdir -p %t
|
||||||
// RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s
|
// 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>
|
template<typename T>
|
||||||
concept Addable = requires(T a, T b) {
|
concept Addable = requires(T a, T b) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// RUN: rm -rf %t && mkdir -p %t
|
// RUN: rm -rf %t && mkdir -p %t
|
||||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
||||||
// RUN: FileCheck %s < %t/_ZTV7MyClass.json --check-prefix=BASE
|
// RUN: FileCheck %s < %t/json/_ZTV7MyClass.json --check-prefix=BASE
|
||||||
// RUN: FileCheck %s < %t/_ZTV7MyClassIiE.json --check-prefix=SPECIALIZATION
|
// RUN: FileCheck %s < %t/json/_ZTV7MyClassIiE.json --check-prefix=SPECIALIZATION
|
||||||
|
|
||||||
template<typename T> struct MyClass {};
|
template<typename T> struct MyClass {};
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// RUN: rm -rf %t && mkdir -p %t
|
// RUN: rm -rf %t && mkdir -p %t
|
||||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
// 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 {
|
template<typename T> struct MyClass {
|
||||||
T MemberTemplate;
|
T MemberTemplate;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// RUN: rm -rf %t && mkdir -p %t
|
// RUN: rm -rf %t && mkdir -p %t
|
||||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
// 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;
|
struct Foo;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// RUN: rm -rf %t && mkdir -p %t
|
// RUN: rm -rf %t && mkdir -p %t
|
||||||
// RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s
|
// 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) {
|
template<typename T> concept Incrementable = requires (T a) {
|
||||||
a++;
|
a++;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// RUN: rm -rf %t && mkdir -p %t
|
// RUN: rm -rf %t && mkdir -p %t
|
||||||
// RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s
|
// 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.
|
// Requires that T suports post and pre-incrementing.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// RUN: rm -rf %t && mkdir -p %t
|
// RUN: rm -rf %t && mkdir -p %t
|
||||||
// RUN: clang-doc --extra-arg -std=c++20 --output=%t --format=json --executor=standalone %s
|
// 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>
|
template<typename T>
|
||||||
concept Incrementable = requires(T x) {
|
concept Incrementable = requires(T x) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// RUN: rm -rf %t && mkdir -p %t
|
// RUN: rm -rf %t && mkdir -p %t
|
||||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
// 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() {}
|
static void myFunction() {}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// RUN: rm -rf %t && mkdir -p %t
|
// RUN: rm -rf %t && mkdir -p %t
|
||||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
// 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 {
|
struct MyClass {
|
||||||
template<class T> T methodTemplate(T param) {
|
template<class T> T methodTemplate(T param) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// RUN: rm -rf %t && mkdir -p %t
|
// RUN: rm -rf %t && mkdir -p %t
|
||||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
// 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 {};
|
class MyClass {};
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// RUN: rm -rf %t && mkdir -p %t
|
// RUN: rm -rf %t && mkdir -p %t
|
||||||
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
// RUN: clang-doc --output=%t --format=json --executor=standalone %s
|
||||||
// RUN: FileCheck %s < %t/nested.json --check-prefix=NESTED
|
// RUN: FileCheck %s < %t/json/nested.json --check-prefix=NESTED
|
||||||
// RUN: FileCheck %s < %t/inner.json --check-prefix=INNER
|
// RUN: FileCheck %s < %t/json/inner.json --check-prefix=INNER
|
||||||
|
|
||||||
namespace nested {
|
namespace nested {
|
||||||
int Global;
|
int Global;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// RUN: rm -rf %t && mkdir -p %t
|
// RUN: rm -rf %t && mkdir -p %t
|
||||||
// RUN: clang-doc --format=mustache --output=%t --executor=standalone %s
|
// 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 {
|
enum Color {
|
||||||
RED,
|
RED,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// RUN: rm -rf %t && mkdir -p %t
|
// RUN: rm -rf %t && mkdir -p %t
|
||||||
// RUN: clang-doc --format=mustache --output=%t --executor=standalone %s
|
// 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 {
|
namespace MyNamespace {
|
||||||
class Foo;
|
class Foo;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user