Refactored class, package and include diagram test cases (#266)

This commit is contained in:
Bartek Kryza
2024-05-14 11:39:07 +02:00
parent eeae5caef5
commit 27eaea5bbe
105 changed files with 660 additions and 4427 deletions

View File

@@ -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

View File

@@ -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
*

View File

@@ -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, "<", "&lt;");
util::replace_all(name, ">", "&gt;");
util::replace_all(name, "(", "&lpar;");
util::replace_all(name, ")", "&rpar;");
if (round_brackets) {
util::replace_all(name, "(", "&lpar;");
util::replace_all(name, ")", "&rpar;");
}
util::replace_all(name, "##", "::");
util::replace_all(name, "{", "&lbrace;");
util::replace_all(name, "}", "&rbrace;");

View File

@@ -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