Added relationship direction flag to context diagram filter (#274)
This commit is contained in:
@@ -171,6 +171,20 @@ std::string to_string(member_order_t mo)
|
||||
return "";
|
||||
}
|
||||
}
|
||||
std::string to_string(context_direction_t cd)
|
||||
{
|
||||
switch (cd) {
|
||||
case context_direction_t::inward:
|
||||
return "inward";
|
||||
case context_direction_t::outward:
|
||||
return "outward";
|
||||
case context_direction_t::any:
|
||||
return "any";
|
||||
default:
|
||||
assert(false);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<std::string> plantuml::get_style(
|
||||
const common::model::relationship_t relationship_type) const
|
||||
|
||||
@@ -159,9 +159,14 @@ struct mermaid {
|
||||
void append(const mermaid &r);
|
||||
};
|
||||
|
||||
enum class context_direction_t { inward, outward, any };
|
||||
|
||||
std::string to_string(context_direction_t cd);
|
||||
|
||||
struct context_config {
|
||||
common::string_or_regex pattern;
|
||||
unsigned radius{0};
|
||||
context_direction_t direction{context_direction_t::any};
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -114,10 +114,15 @@ types:
|
||||
- lambda
|
||||
- cuda_kernel
|
||||
- cuda_device
|
||||
direction_t: !variant
|
||||
- inward
|
||||
- outward
|
||||
- any
|
||||
context_filter_match_t:
|
||||
match:
|
||||
radius: int
|
||||
pattern: regex_or_string_t
|
||||
direction: !optional direction_t
|
||||
context_filter_t:
|
||||
- regex_or_string_t
|
||||
- context_filter_match_t
|
||||
|
||||
@@ -35,6 +35,7 @@ using clanguml::config::callee_type;
|
||||
using clanguml::config::class_diagram;
|
||||
using clanguml::config::config;
|
||||
using clanguml::config::context_config;
|
||||
using clanguml::config::context_direction_t;
|
||||
using clanguml::config::diagram_template;
|
||||
using clanguml::config::filter;
|
||||
using clanguml::config::generate_links_config;
|
||||
@@ -259,6 +260,25 @@ template <> struct convert<module_access_t> {
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// config context_direction_t decoder
|
||||
//
|
||||
template <> struct convert<context_direction_t> {
|
||||
static bool decode(const Node &node, context_direction_t &rhs)
|
||||
{
|
||||
if (node.as<std::string>() == "inward")
|
||||
rhs = context_direction_t::inward;
|
||||
else if (node.as<std::string>() == "outward")
|
||||
rhs = context_direction_t::outward;
|
||||
else if (node.as<std::string>() == "any")
|
||||
rhs = context_direction_t::any;
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// config method_type decoder
|
||||
//
|
||||
@@ -460,8 +480,11 @@ template <> struct convert<context_config> {
|
||||
{
|
||||
using namespace std::string_literals;
|
||||
if (node.IsMap() && has_key(node, "match")) {
|
||||
rhs.radius = node["match"]["radius"].as<unsigned>();
|
||||
rhs.pattern = node["match"]["pattern"].as<string_or_regex>();
|
||||
const auto &match = node["match"];
|
||||
rhs.radius = match["radius"].as<unsigned>();
|
||||
rhs.pattern = match["pattern"].as<string_or_regex>();
|
||||
if (has_key(match, "direction"))
|
||||
rhs.direction = match["direction"].as<context_direction_t>();
|
||||
}
|
||||
else {
|
||||
rhs.radius = 1;
|
||||
|
||||
Reference in New Issue
Block a user