Added package diagram layout hints generation
This commit is contained in:
@@ -58,6 +58,22 @@ std::string to_string(const diagram_type t)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string to_string(const hint_t t)
|
||||||
|
{
|
||||||
|
switch (t) {
|
||||||
|
case hint_t::up:
|
||||||
|
return "up";
|
||||||
|
case hint_t::down:
|
||||||
|
return "down";
|
||||||
|
case hint_t::left:
|
||||||
|
return "left";
|
||||||
|
case hint_t::right:
|
||||||
|
return "right";
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void plantuml::append(const plantuml &r)
|
void plantuml::append(const plantuml &r)
|
||||||
{
|
{
|
||||||
before.insert(before.end(), r.before.begin(), r.before.end());
|
before.insert(before.end(), r.before.begin(), r.before.end());
|
||||||
@@ -439,10 +455,6 @@ template <> struct convert<layout_hint> {
|
|||||||
rhs.hint = hint_t::right;
|
rhs.hint = hint_t::right;
|
||||||
rhs.entity = node["right"].as<std::string>();
|
rhs.entity = node["right"].as<std::string>();
|
||||||
}
|
}
|
||||||
else if (node["hidden"]) {
|
|
||||||
rhs.hint = hint_t::hidden;
|
|
||||||
rhs.entity = node["hidden"].as<std::string>();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ struct filter {
|
|||||||
std::vector<common::model::scope_t> scopes;
|
std::vector<common::model::scope_t> scopes;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class hint_t { up, down, left, right, hidden };
|
enum class hint_t { up, down, left, right };
|
||||||
|
|
||||||
struct layout_hint {
|
struct layout_hint {
|
||||||
hint_t hint;
|
hint_t hint;
|
||||||
@@ -75,6 +75,7 @@ struct layout_hint {
|
|||||||
using layout_hints = std::map<std::string, std::vector<layout_hint>>;
|
using layout_hints = std::map<std::string, std::vector<layout_hint>>;
|
||||||
|
|
||||||
std::string to_string(const diagram_type t);
|
std::string to_string(const diagram_type t);
|
||||||
|
std::string to_string(const hint_t t);
|
||||||
|
|
||||||
struct inheritable_diagram_options {
|
struct inheritable_diagram_options {
|
||||||
option<std::vector<std::string>> glob{"glob"};
|
option<std::vector<std::string>> glob{"glob"};
|
||||||
|
|||||||
@@ -109,6 +109,31 @@ void generator::generate_relationships(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void generator::generate_config_layout_hints(std::ostream &ostr) const
|
||||||
|
{
|
||||||
|
const auto &uns = m_config.using_namespace();
|
||||||
|
|
||||||
|
// Generate layout hints
|
||||||
|
for (const auto &[entity, hints] : m_config.layout()) {
|
||||||
|
for (const auto &hint : hints) {
|
||||||
|
std::stringstream hint_str;
|
||||||
|
try {
|
||||||
|
hint_str << m_model.to_alias(ns_relative(uns, entity))
|
||||||
|
<< " -[hidden]"
|
||||||
|
<< clanguml::config::to_string(hint.hint) << "- "
|
||||||
|
<< m_model.to_alias(ns_relative(uns, hint.entity))
|
||||||
|
<< '\n';
|
||||||
|
ostr << hint_str.str();
|
||||||
|
}
|
||||||
|
catch (error::uml_alias_missing &e) {
|
||||||
|
LOG_ERROR("=== Skipping layout hint from {} to {} due "
|
||||||
|
"to: {}",
|
||||||
|
entity, hint.entity, e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void generator::generate(const package &p, std::ostream &ostr) const
|
void generator::generate(const package &p, std::ostream &ostr) const
|
||||||
{
|
{
|
||||||
const auto &uns = m_config.using_namespace();
|
const auto &uns = m_config.using_namespace();
|
||||||
@@ -175,6 +200,8 @@ void generator::generate(std::ostream &ostr) const
|
|||||||
ostr << '\n';
|
ostr << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generate_config_layout_hints(ostr);
|
||||||
|
|
||||||
// Process aliases in any of the puml directives
|
// Process aliases in any of the puml directives
|
||||||
for (const auto &b : m_config.puml().after) {
|
for (const auto &b : m_config.puml().after) {
|
||||||
std::string note{b};
|
std::string note{b};
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ public:
|
|||||||
|
|
||||||
void generate_relationships(const package &p, std::ostream &ostr) const;
|
void generate_relationships(const package &p, std::ostream &ostr) const;
|
||||||
|
|
||||||
|
void generate_config_layout_hints(std::ostream &ostr) const;
|
||||||
|
|
||||||
void generate(const package &e, std::ostream &ostr) const;
|
void generate(const package &e, std::ostream &ostr) const;
|
||||||
|
|
||||||
void generate(std::ostream &ostr) const;
|
void generate(std::ostream &ostr) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user