Fixed plantuml config option inheritance
This commit is contained in:
@@ -35,8 +35,7 @@ enum class relationship_t {
|
||||
kAssociation,
|
||||
kInstantiation,
|
||||
kFriendship,
|
||||
kDependency,
|
||||
kInclusion
|
||||
kDependency
|
||||
};
|
||||
|
||||
enum class message_t { kCall, kReturn };
|
||||
|
||||
@@ -105,22 +105,6 @@ common::model::diagram_t class_diagram::type() const
|
||||
return common::model::diagram_t::kClass;
|
||||
}
|
||||
|
||||
bool class_diagram::has_class(std::string clazz)
|
||||
{
|
||||
for (const auto &c : classes()) {
|
||||
for (const auto &ns : using_namespace()) {
|
||||
std::string prefix{};
|
||||
if (!ns.empty()) {
|
||||
prefix = ns + "::";
|
||||
}
|
||||
if (prefix + c == clazz)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
common::model::diagram_t sequence_diagram::type() const
|
||||
{
|
||||
return common::model::diagram_t::kSequence;
|
||||
@@ -136,13 +120,6 @@ common::model::diagram_t include_diagram::type() const
|
||||
return common::model::diagram_t::kInclude;
|
||||
}
|
||||
|
||||
template <>
|
||||
void append_value<std::vector<std::string>>(
|
||||
std::vector<std::string> &l, const std::vector<std::string> &r)
|
||||
{
|
||||
l.insert(l.end(), r.begin(), r.end());
|
||||
}
|
||||
|
||||
template <> void append_value<plantuml>(plantuml &l, const plantuml &r)
|
||||
{
|
||||
l.append(r);
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace clanguml {
|
||||
namespace config {
|
||||
|
||||
@@ -29,6 +31,7 @@ template <typename T> struct option {
|
||||
option_inherit_mode im = option_inherit_mode::kOverride)
|
||||
: name{name_}
|
||||
, value{}
|
||||
, inheritance_mode{im}
|
||||
{
|
||||
}
|
||||
option(const std::string &name_, const T &initial_value,
|
||||
@@ -36,6 +39,7 @@ template <typename T> struct option {
|
||||
: name{name_}
|
||||
, value{initial_value}
|
||||
, has_value{true}
|
||||
, inheritance_mode{im}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -48,12 +52,13 @@ template <typename T> struct option {
|
||||
|
||||
void override(const option<T> &o)
|
||||
{
|
||||
if (!is_declared && o.is_declared) {
|
||||
if (inheritance_mode == option_inherit_mode::kAppend)
|
||||
append_value(value, o.value);
|
||||
else
|
||||
value = o.value;
|
||||
|
||||
if (o.is_declared && inheritance_mode == option_inherit_mode::kAppend) {
|
||||
append_value(value, o.value);
|
||||
is_declared = true;
|
||||
has_value = true;
|
||||
}
|
||||
else if (!is_declared && o.is_declared) {
|
||||
value = o.value;
|
||||
is_declared = true;
|
||||
has_value = true;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
|
||||
TEST_CASE("Test config simple", "[unit-test]")
|
||||
{
|
||||
using clanguml::common::model::access_t;
|
||||
using clanguml::common::model::relationship_t;
|
||||
using clanguml::util::contains;
|
||||
|
||||
auto cfg = clanguml::config::load("./test_config_data/simple.yml");
|
||||
|
||||
CHECK(cfg.diagrams.size() == 1);
|
||||
@@ -39,6 +43,31 @@ TEST_CASE("Test config simple", "[unit-test]")
|
||||
"https://github.com/bkryza/clang-uml/blob/{{ git.branch }}/{{ "
|
||||
"element.source.file }}#L{{ element.source.line }}");
|
||||
CHECK(diagram.generate_links().tooltip == "{{ element.comment }}");
|
||||
|
||||
CHECK(contains(diagram.include().access, access_t::kPublic));
|
||||
CHECK(contains(diagram.include().access, access_t::kProtected));
|
||||
CHECK(contains(diagram.include().access, access_t::kPrivate));
|
||||
|
||||
CHECK(
|
||||
contains(diagram.include().relationships, relationship_t::kExtension));
|
||||
CHECK(contains(
|
||||
diagram.include().relationships, relationship_t::kAggregation));
|
||||
CHECK(contains(
|
||||
diagram.include().relationships, relationship_t::kAssociation));
|
||||
CHECK(contains(
|
||||
diagram.include().relationships, relationship_t::kComposition));
|
||||
CHECK(contains(
|
||||
diagram.include().relationships, relationship_t::kContainment));
|
||||
CHECK(
|
||||
contains(diagram.include().relationships, relationship_t::kDependency));
|
||||
CHECK(
|
||||
contains(diagram.include().relationships, relationship_t::kFriendship));
|
||||
CHECK(contains(
|
||||
diagram.include().relationships, relationship_t::kInstantiation));
|
||||
CHECK(
|
||||
contains(diagram.include().relationships, relationship_t::kOwnership));
|
||||
|
||||
CHECK(contains(diagram.exclude().relationships, relationship_t::kNone));
|
||||
}
|
||||
|
||||
TEST_CASE("Test config inherited", "[unit-test]")
|
||||
@@ -63,6 +92,12 @@ TEST_CASE("Test config inherited", "[unit-test]")
|
||||
CHECK(cus.include_relations_also_as_members());
|
||||
CHECK(cus.generate_packages() == false);
|
||||
CHECK(cus.generate_links == false);
|
||||
CHECK(cus.puml().before.size() == 2);
|
||||
CHECK(cus.puml().before.at(0) == "title This is diagram A");
|
||||
CHECK(cus.puml().before.at(1) == "This is a common header");
|
||||
CHECK(cus.puml().after.size() == 2);
|
||||
CHECK(cus.puml().after.at(0) == "note left of A: This is a note");
|
||||
CHECK(cus.puml().after.at(1) == "This is a common footnote");
|
||||
}
|
||||
|
||||
TEST_CASE("Test config includes", "[unit-test]")
|
||||
|
||||
@@ -10,7 +10,11 @@ include:
|
||||
glob:
|
||||
- src/**/*.cc
|
||||
- src/**/*.h
|
||||
|
||||
plantuml:
|
||||
before:
|
||||
- This is a common header
|
||||
after:
|
||||
- This is a common footnote
|
||||
diagrams:
|
||||
class_default:
|
||||
type: class
|
||||
@@ -21,4 +25,8 @@ diagrams:
|
||||
include_relations_also_as_members: true
|
||||
glob:
|
||||
- src/main.cc
|
||||
|
||||
plantuml:
|
||||
before:
|
||||
- title This is diagram A
|
||||
after:
|
||||
- "note left of A: This is a note"
|
||||
@@ -16,4 +16,21 @@ diagrams:
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml
|
||||
- ABCD
|
||||
- ABCD
|
||||
access:
|
||||
- public
|
||||
- protected
|
||||
- private
|
||||
relationships:
|
||||
- inheritance
|
||||
- composition
|
||||
- aggregation
|
||||
- containment
|
||||
- ownership
|
||||
- association
|
||||
- instantiation
|
||||
- friendship
|
||||
- dependency
|
||||
exclude:
|
||||
relationships:
|
||||
- none
|
||||
Reference in New Issue
Block a user