Added generate_links config option
This commit is contained in:
@@ -91,6 +91,7 @@ void inheritable_diagram_options::inherit(
|
||||
exclude.override(parent.exclude);
|
||||
puml.override(parent.puml);
|
||||
generate_method_arguments.override(parent.generate_method_arguments);
|
||||
generate_links.override(parent.generate_links);
|
||||
}
|
||||
|
||||
bool diagram::should_include_entities(const std::string &ent)
|
||||
@@ -268,6 +269,7 @@ using clanguml::common::model::scope_t;
|
||||
using clanguml::config::class_diagram;
|
||||
using clanguml::config::config;
|
||||
using clanguml::config::filter;
|
||||
using clanguml::config::generate_links_config;
|
||||
using clanguml::config::hint_t;
|
||||
using clanguml::config::layout_hint;
|
||||
using clanguml::config::method_arguments;
|
||||
@@ -439,6 +441,19 @@ template <> struct convert<filter> {
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// generate_links_config Yaml decoder
|
||||
//
|
||||
template <> struct convert<generate_links_config> {
|
||||
static bool decode(const Node &node, generate_links_config &rhs)
|
||||
{
|
||||
if (node["prefix"])
|
||||
rhs.prefix = node["prefix"].as<decltype(rhs.prefix)>();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> bool decode_diagram(const Node &node, T &rhs)
|
||||
{
|
||||
get_option(node, rhs.glob);
|
||||
@@ -464,6 +479,7 @@ template <> struct convert<class_diagram> {
|
||||
get_option(node, rhs.include_relations_also_as_members);
|
||||
get_option(node, rhs.generate_method_arguments);
|
||||
get_option(node, rhs.generate_packages);
|
||||
get_option(node, rhs.generate_links);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -479,6 +495,7 @@ template <> struct convert<sequence_diagram> {
|
||||
return false;
|
||||
|
||||
get_option(node, rhs.start_from);
|
||||
get_option(node, rhs.generate_links);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -494,6 +511,7 @@ template <> struct convert<package_diagram> {
|
||||
return false;
|
||||
|
||||
get_option(node, rhs.layout);
|
||||
get_option(node, rhs.generate_links);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -545,6 +563,7 @@ template <> struct convert<config> {
|
||||
get_option(node, rhs.puml);
|
||||
get_option(node, rhs.generate_method_arguments);
|
||||
get_option(node, rhs.generate_packages);
|
||||
get_option(node, rhs.generate_links);
|
||||
|
||||
auto diagrams = node["diagrams"];
|
||||
|
||||
|
||||
@@ -74,6 +74,10 @@ struct layout_hint {
|
||||
|
||||
using layout_hints = std::map<std::string, std::vector<layout_hint>>;
|
||||
|
||||
struct generate_links_config {
|
||||
std::string prefix;
|
||||
};
|
||||
|
||||
std::string to_string(const diagram_type t);
|
||||
std::string to_string(const hint_t t);
|
||||
|
||||
@@ -88,6 +92,7 @@ struct inheritable_diagram_options {
|
||||
option<method_arguments> generate_method_arguments{
|
||||
"generate_method_arguments", method_arguments::full};
|
||||
option<bool> generate_packages{"generate_packages", false};
|
||||
option<generate_links_config> generate_links{"generate_links"};
|
||||
|
||||
void inherit(const inheritable_diagram_options &parent);
|
||||
};
|
||||
@@ -97,8 +102,6 @@ struct diagram : public inheritable_diagram_options {
|
||||
|
||||
virtual diagram_type type() const = 0;
|
||||
|
||||
std::string name;
|
||||
|
||||
bool should_include_entities(const std::string &ent);
|
||||
|
||||
bool should_include_relationship(const std::string &rel);
|
||||
@@ -119,6 +122,7 @@ struct diagram : public inheritable_diagram_options {
|
||||
|
||||
bool should_include(const common::model::namespace_ &path) const;
|
||||
|
||||
std::string name;
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ template <typename T> struct option {
|
||||
option_inherit_mode im = option_inherit_mode::override)
|
||||
: name{name_}
|
||||
, value{initial_value}
|
||||
, has_value{true}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -42,6 +43,7 @@ template <typename T> struct option {
|
||||
{
|
||||
value = v;
|
||||
is_declared = true;
|
||||
has_value = true;
|
||||
}
|
||||
|
||||
void override(const option<T> &o)
|
||||
@@ -53,6 +55,7 @@ template <typename T> struct option {
|
||||
value = o.value;
|
||||
|
||||
is_declared = true;
|
||||
has_value = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +65,12 @@ template <typename T> struct option {
|
||||
|
||||
const T &operator()() const { return value; }
|
||||
|
||||
operator bool() const { return has_value; }
|
||||
|
||||
std::string name;
|
||||
T value;
|
||||
bool is_declared{false};
|
||||
bool has_value{false};
|
||||
option_inherit_mode inheritance_mode;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,6 +34,9 @@ TEST_CASE("Test config simple", "[unit-test]")
|
||||
CHECK(diagram.generate_method_arguments() ==
|
||||
clanguml::config::method_arguments::full);
|
||||
CHECK(diagram.generate_packages() == true);
|
||||
CHECK(diagram.generate_links == true);
|
||||
CHECK(diagram.generate_links().prefix ==
|
||||
"https://github.com/bkryza/clang-uml/blob/master/");
|
||||
}
|
||||
|
||||
TEST_CASE("Test config inherited", "[unit-test]")
|
||||
@@ -48,6 +51,7 @@ TEST_CASE("Test config inherited", "[unit-test]")
|
||||
CHECK(def.glob()[1] == "src/**/*.h");
|
||||
CHECK(clanguml::util::contains(def.using_namespace(), "clanguml"));
|
||||
CHECK(def.generate_packages() == false);
|
||||
CHECK(def.generate_links == false);
|
||||
|
||||
auto &cus = *cfg.diagrams["class_custom"];
|
||||
CHECK(cus.type() == clanguml::config::diagram_type::class_diagram);
|
||||
@@ -55,7 +59,8 @@ TEST_CASE("Test config inherited", "[unit-test]")
|
||||
CHECK(cus.glob()[0] == "src/main.cc");
|
||||
CHECK(cus.using_namespace().starts_with({"clanguml::ns1"}));
|
||||
CHECK(cus.include_relations_also_as_members());
|
||||
CHECK(def.generate_packages() == false);
|
||||
CHECK(cus.generate_packages() == false);
|
||||
CHECK(cus.generate_links == false);
|
||||
}
|
||||
|
||||
TEST_CASE("Test config includes", "[unit-test]")
|
||||
|
||||
@@ -9,6 +9,8 @@ diagrams:
|
||||
using_namespace: clanguml
|
||||
generate_method_arguments: full
|
||||
generate_packages: true
|
||||
generate_links:
|
||||
prefix: https://github.com/bkryza/clang-uml/blob/master/
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml
|
||||
|
||||
Reference in New Issue
Block a user