Added class diagram layout hints

This commit is contained in:
Bartek Kryza
2022-02-15 20:36:03 +01:00
parent 1e551ebbff
commit 64ffac3a77
6 changed files with 115 additions and 0 deletions

View File

@@ -348,6 +348,31 @@ void generator::generate(const enum_ &e, std::ostream &ostr) const
}
}
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(std::ostream &ostr) const
{
ostr << "@startuml" << '\n';
@@ -393,6 +418,8 @@ void generator::generate(std::ostream &ostr) const
ostr << '\n';
}
generate_config_layout_hints(ostr);
// Process aliases in any of the puml directives
for (const auto &b : m_config.puml().after) {
std::string note{b};

View File

@@ -64,6 +64,8 @@ public:
void generate_alias(const enum_ &e, std::ostream &ostr) const;
void generate_config_layout_hints(std::ostream &ostr) const;
void generate(const class_ &c, std::ostream &ostr) const;
void generate(const enum_ &e, std::ostream &ostr) const;