Added support for 'together' option in class diagrams without rendered namespaces
This commit is contained in:
@@ -142,6 +142,31 @@ std::vector<std::string> diagram::get_translation_units() const
|
||||
return translation_units;
|
||||
}
|
||||
|
||||
std::optional<std::string> class_diagram::get_together_group(
|
||||
const std::string &full_name) const
|
||||
{
|
||||
const auto relative_name = using_namespace().relative(full_name);
|
||||
|
||||
for (const auto &[hint_target, hints] : layout()) {
|
||||
for (const auto &hint : hints) {
|
||||
if (hint.hint == hint_t::together) {
|
||||
const auto &together_others =
|
||||
std::get<std::vector<std::string>>(hint.entity);
|
||||
|
||||
if ((full_name == hint_target) ||
|
||||
util::contains(together_others, full_name))
|
||||
return hint_target;
|
||||
|
||||
if ((relative_name == hint_target) ||
|
||||
util::contains(together_others, relative_name))
|
||||
return hint_target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void diagram::initialize_type_aliases()
|
||||
{
|
||||
if (type_aliases().count("std::basic_string<char>") == 0U) {
|
||||
|
||||
@@ -80,13 +80,13 @@ struct filter {
|
||||
std::vector<std::filesystem::path> paths;
|
||||
};
|
||||
|
||||
enum class hint_t { up, down, left, right };
|
||||
enum class hint_t { up, down, left, right, together };
|
||||
|
||||
std::string to_string(hint_t t);
|
||||
|
||||
struct layout_hint {
|
||||
hint_t hint{hint_t::up};
|
||||
std::string entity;
|
||||
std::variant<std::string, std::vector<std::string>> entity;
|
||||
};
|
||||
|
||||
using layout_hints = std::map<std::string, std::vector<layout_hint>>;
|
||||
@@ -184,6 +184,9 @@ struct class_diagram : public diagram {
|
||||
|
||||
option<layout_hints> layout{"layout"};
|
||||
|
||||
std::optional<std::string> get_together_group(
|
||||
const std::string &full_name) const;
|
||||
|
||||
void initialize_relationship_hints();
|
||||
};
|
||||
|
||||
|
||||
@@ -468,6 +468,10 @@ template <> struct convert<layout_hint> {
|
||||
rhs.hint = hint_t::right;
|
||||
rhs.entity = node["right"].as<std::string>();
|
||||
}
|
||||
else if (node["together"]) {
|
||||
rhs.hint = hint_t::together;
|
||||
rhs.entity = node["together"].as<std::vector<std::string>>();
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
@@ -645,7 +649,8 @@ config load(
|
||||
doc["git"] = git_config;
|
||||
}
|
||||
|
||||
return doc.as<config>();
|
||||
auto d = doc.as<config>();
|
||||
return d;
|
||||
}
|
||||
catch (YAML::BadFile &e) {
|
||||
throw std::runtime_error(fmt::format(
|
||||
|
||||
@@ -159,7 +159,13 @@ YAML::Emitter &operator<<(
|
||||
YAML::Emitter &operator<<(YAML::Emitter &out, const layout_hint &c)
|
||||
{
|
||||
out << YAML::BeginMap;
|
||||
out << YAML::Key << c.hint << YAML::Value << c.entity;
|
||||
|
||||
out << YAML::Key << c.hint << YAML::Value;
|
||||
if (std::holds_alternative<std::string>(c.entity))
|
||||
out << std::get<std::string>(c.entity);
|
||||
else if (std::holds_alternative<std::vector<std::string>>(c.entity))
|
||||
out << std::get<std::vector<std::string>>(c.entity);
|
||||
|
||||
out << YAML::EndMap;
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user