Added include diagram JSON model generator
This commit is contained in:
@@ -205,16 +205,36 @@ void generate_diagram(const std::string &od, const std::string &name,
|
||||
dynamic_cast<diagram_config &>(*diagram), translation_units,
|
||||
verbose);
|
||||
|
||||
auto path = std::filesystem::path{od} / fmt::format("{}.puml", name);
|
||||
std::ofstream ofs;
|
||||
ofs.open(path, std::ofstream::out | std::ofstream::trunc);
|
||||
for (const auto generator_type : generators) {
|
||||
if (generator_type == generator_type_t::plantuml) {
|
||||
auto path =
|
||||
std::filesystem::path{od} / fmt::format("{}.puml", name);
|
||||
std::ofstream ofs;
|
||||
ofs.open(path, std::ofstream::out | std::ofstream::trunc);
|
||||
|
||||
ofs << clanguml::include_diagram::generators::plantuml::generator(
|
||||
dynamic_cast<diagram_config &>(*diagram), *model);
|
||||
ofs << clanguml::include_diagram::generators::plantuml::
|
||||
generator(
|
||||
dynamic_cast<diagram_config &>(*diagram), *model);
|
||||
|
||||
ofs.close();
|
||||
ofs.close();
|
||||
|
||||
LOG_INFO("Written {} diagram to {}", name, path.string());
|
||||
LOG_INFO("Written {} diagram to {}", name, path.string());
|
||||
}
|
||||
else if (generator_type == generator_type_t::json) {
|
||||
auto path =
|
||||
std::filesystem::path{od} / fmt::format("{}.json", name);
|
||||
std::ofstream ofs;
|
||||
|
||||
ofs.open(path, std::ofstream::out | std::ofstream::trunc);
|
||||
ofs << clanguml::include_diagram::generators::json::generator(
|
||||
dynamic_cast<clanguml::config::include_diagram &>(*diagram),
|
||||
*model);
|
||||
|
||||
ofs.close();
|
||||
|
||||
LOG_INFO("Written {} diagram to {}", name, path.string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "common/generators/generators.h"
|
||||
#include "common/model/diagram_filter.h"
|
||||
#include "config/config.h"
|
||||
#include "include_diagram/generators/json/include_diagram_generator.h"
|
||||
#include "include_diagram/generators/plantuml/include_diagram_generator.h"
|
||||
#include "package_diagram/generators/json/package_diagram_generator.h"
|
||||
#include "package_diagram/generators/plantuml/package_diagram_generator.h"
|
||||
|
||||
@@ -17,3 +17,21 @@
|
||||
*/
|
||||
|
||||
#include "source_file.h"
|
||||
|
||||
namespace clanguml::common::model {
|
||||
|
||||
std::string to_string(source_file_t sf)
|
||||
{
|
||||
switch (sf) {
|
||||
case source_file_t::kDirectory:
|
||||
return "directory";
|
||||
case source_file_t::kHeader:
|
||||
return "header";
|
||||
case source_file_t::kImplementation:
|
||||
return "implementation";
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace clanguml::common::model
|
||||
|
||||
@@ -36,6 +36,8 @@ namespace clanguml::common::model {
|
||||
|
||||
enum class source_file_t { kDirectory, kHeader, kImplementation };
|
||||
|
||||
std::string to_string(source_file_t sf);
|
||||
|
||||
struct fs_path_sep {
|
||||
#ifdef _WIN32
|
||||
static constexpr std::string_view value = "\\";
|
||||
|
||||
Reference in New Issue
Block a user