Refactored class, package and include diagram test cases (#266)
This commit is contained in:
@@ -18,18 +18,10 @@
|
||||
|
||||
#include "generator.h"
|
||||
|
||||
namespace clanguml::common::model {
|
||||
namespace clanguml::common {
|
||||
namespace model {
|
||||
using nlohmann::json;
|
||||
|
||||
namespace detail {
|
||||
std::string render_name(std::string name)
|
||||
{
|
||||
util::replace_all(name, "##", "::");
|
||||
|
||||
return name;
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
void to_json(nlohmann::json &j, const source_location &sl)
|
||||
{
|
||||
j = json{{"file", sl.file_relative()},
|
||||
@@ -40,9 +32,10 @@ void to_json(nlohmann::json &j, const source_location &sl)
|
||||
void to_json(nlohmann::json &j, const element &c)
|
||||
{
|
||||
j = json{{"id", std::to_string(c.id())},
|
||||
{"name", detail::render_name(c.name())},
|
||||
{"name", common::generators::json::render_name(c.name())},
|
||||
{"namespace", c.get_namespace().to_string()}, {"type", c.type_name()},
|
||||
{"display_name", detail::render_name(c.full_name(true))}};
|
||||
{"display_name",
|
||||
common::generators::json::render_name(c.full_name(true))}};
|
||||
|
||||
if (const auto &comment = c.comment(); comment)
|
||||
j["comment"] = comment.value();
|
||||
@@ -81,4 +74,16 @@ void to_json(nlohmann::json &j, const relationship &c)
|
||||
if (const auto &comment = c.comment(); comment)
|
||||
j["comment"] = comment.value();
|
||||
}
|
||||
} // namespace model
|
||||
|
||||
namespace generators::json {
|
||||
|
||||
std::string render_name(std::string name)
|
||||
{
|
||||
util::replace_all(name, "##", "::");
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
} // namespace generators::json
|
||||
} // namespace clanguml::common::model
|
||||
|
||||
@@ -51,6 +51,8 @@ using clanguml::common::model::element;
|
||||
using clanguml::common::model::message_t;
|
||||
using clanguml::common::model::relationship_t;
|
||||
|
||||
std::string render_name(std::string name);
|
||||
|
||||
/**
|
||||
* @brief Base class for diagram generators
|
||||
*
|
||||
|
||||
@@ -78,12 +78,14 @@ std::string indent(const unsigned level)
|
||||
return std::string(level * kIndentWidth, ' '); // NOLINT
|
||||
}
|
||||
|
||||
std::string render_name(std::string name)
|
||||
std::string render_name(std::string name, bool round_brackets)
|
||||
{
|
||||
util::replace_all(name, "<", "<");
|
||||
util::replace_all(name, ">", ">");
|
||||
util::replace_all(name, "(", "(");
|
||||
util::replace_all(name, ")", ")");
|
||||
if (round_brackets) {
|
||||
util::replace_all(name, "(", "(");
|
||||
util::replace_all(name, ")", ")");
|
||||
}
|
||||
util::replace_all(name, "##", "::");
|
||||
util::replace_all(name, "{", "{");
|
||||
util::replace_all(name, "}", "}");
|
||||
|
||||
@@ -44,7 +44,7 @@ std::string to_mermaid(message_t r);
|
||||
|
||||
std::string indent(unsigned level);
|
||||
|
||||
std::string render_name(std::string name);
|
||||
std::string render_name(std::string name, bool round_brackets = true);
|
||||
|
||||
/**
|
||||
* @brief Base class for diagram generators
|
||||
|
||||
Reference in New Issue
Block a user