Added method type diagram filter (#145)

This commit is contained in:
Bartek Kryza
2023-06-02 01:05:37 +02:00
parent e7f738c6dc
commit e40dc3a60c
20 changed files with 433 additions and 9 deletions

View File

@@ -62,6 +62,27 @@ std::string to_string(const method_arguments ma)
}
}
std::string to_string(method_type mt)
{
switch (mt) {
case method_type::constructor:
return "constructor";
case method_type::assignment:
return "assignment";
case method_type::operator_:
return "operator";
case method_type::defaulted:
return "defaulted";
case method_type::deleted:
return "deleted";
case method_type::static_:
return "static";
default:
assert(false);
return "";
}
}
std::string to_string(const comment_parser_t cp)
{
switch (cp) {

View File

@@ -37,6 +37,17 @@ namespace config {
enum class method_arguments { full, abbreviated, none };
enum class method_type {
constructor,
assignment,
operator_,
defaulted,
deleted,
static_
};
std::string to_string(method_type mt);
enum class package_type_t { kNamespace, kDirectory };
enum class member_order_t { lexical, as_is };
@@ -96,6 +107,8 @@ struct filter {
std::vector<std::string> context;
std::vector<std::filesystem::path> paths;
std::vector<method_type> method_types;
};
enum class hint_t { up, down, left, right, together, row, column };

View File

@@ -34,6 +34,7 @@ using clanguml::config::layout_hint;
using clanguml::config::location_t;
using clanguml::config::member_order_t;
using clanguml::config::method_arguments;
using clanguml::config::method_type;
using clanguml::config::package_diagram;
using clanguml::config::package_type_t;
using clanguml::config::plantuml;
@@ -221,6 +222,32 @@ template <> struct convert<access_t> {
}
};
//
// config method_type decoder
//
template <> struct convert<method_type> {
static bool decode(const Node &node, method_type &rhs)
{
const auto &val = node.as<std::string>();
if (val == to_string(method_type::constructor))
rhs = method_type::constructor;
else if (val == to_string(method_type::assignment))
rhs = method_type::assignment;
else if (val == to_string(method_type::operator_))
rhs = method_type::operator_;
else if (val == to_string(method_type::defaulted))
rhs = method_type::defaulted;
else if (val == to_string(method_type::deleted))
rhs = method_type::deleted;
else if (val == to_string(method_type::static_))
rhs = method_type::static_;
else
return false;
return true;
}
};
//
// config relationship_t decoder
//
@@ -337,6 +364,10 @@ template <> struct convert<filter> {
rhs.element_types =
node["element_types"].as<decltype(rhs.element_types)>();
if (node["method_types"])
rhs.method_types =
node["method_types"].as<decltype(rhs.method_types)>();
if (node["access"])
rhs.access = node["access"].as<decltype(rhs.access)>();
@@ -515,7 +546,8 @@ template <> struct convert<include_diagram> {
rhs.relative_to.set(std::filesystem::current_path());
// Convert the path in relative_to to an absolute path, with respect
// to the directory where the `.clang-uml` configuration file is located
// to the directory where the `.clang-uml` configuration file is
// located
if (rhs.relative_to) {
auto absolute_relative_to =
std::filesystem::path{node["__parent_path"].as<std::string>()} /

View File

@@ -45,6 +45,13 @@ YAML::Emitter &operator<<(YAML::Emitter &out, const diagram_t &d)
} // namespace clanguml::common::model
namespace clanguml::config {
YAML::Emitter &operator<<(YAML::Emitter &out, const method_type &m)
{
out << to_string(m);
return out;
}
YAML::Emitter &operator<<(YAML::Emitter &out, const filter &f)
{
out << YAML::BeginMap;
@@ -62,6 +69,8 @@ YAML::Emitter &operator<<(YAML::Emitter &out, const filter &f)
out << YAML::Key << "elements" << YAML::Value << f.elements;
if (!f.element_types.empty())
out << YAML::Key << "element_types" << YAML::Value << f.element_types;
if (!f.method_types.empty())
out << YAML::Key << "method_types" << YAML::Value << f.method_types;
if (!f.paths.empty())
out << YAML::Key << "paths" << YAML::Value << f.paths;
if (!f.relationships.empty())