Added layout hints config option to package diagrams
This commit is contained in:
@@ -409,6 +409,8 @@ template <> struct convert<package_diagram> {
|
||||
if (!decode_diagram(node, rhs))
|
||||
return false;
|
||||
|
||||
get_option(node, rhs.layout);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -135,6 +135,8 @@ struct package_diagram : public diagram {
|
||||
virtual ~package_diagram() = default;
|
||||
|
||||
diagram_type type() const override;
|
||||
|
||||
option<layout_hints> layout{"layout"};
|
||||
};
|
||||
|
||||
struct config : public inheritable_diagram_options {
|
||||
|
||||
@@ -83,22 +83,39 @@ TEST_CASE("Test config layout", "[unit-test]")
|
||||
{
|
||||
auto cfg = clanguml::config::load("./test_config_data/layout.yml");
|
||||
|
||||
CHECK(cfg.diagrams.size() == 1);
|
||||
CHECK(cfg.diagrams.size() == 2);
|
||||
|
||||
auto &def = static_cast<clanguml::config::class_diagram &>(
|
||||
*cfg.diagrams["class_main"]);
|
||||
CHECK(def.type() == clanguml::config::diagram_type::class_diagram);
|
||||
|
||||
CHECK(def.layout().at("ABCD").size() == 2);
|
||||
CHECK(def.layout().at("ABCD")[0].hint == clanguml::config::hint_t::up);
|
||||
CHECK(def.layout().at("ABCD")[0].entity == "ABCD_SUBCLASS");
|
||||
CHECK(def.layout().at("ABCD")[1].hint == clanguml::config::hint_t::left);
|
||||
CHECK(def.layout().at("ABCD")[1].entity == "ABCD_SIBLING");
|
||||
auto check_layout = [](const auto &diagram,
|
||||
const clanguml::config::diagram_type type) {
|
||||
CHECK(diagram.type() == type);
|
||||
|
||||
CHECK(def.layout().at("ABCD_SIBLING").size() == 2);
|
||||
CHECK(def.layout().at("ABCD_SIBLING")[0].hint ==
|
||||
clanguml::config::hint_t::right);
|
||||
CHECK(def.layout().at("ABCD_SIBLING")[0].entity == "ABCD_OTHER_SIBLING");
|
||||
CHECK(def.layout().at("ABCD_SIBLING")[1].hint ==
|
||||
clanguml::config::hint_t::down);
|
||||
CHECK(def.layout().at("ABCD_SIBLING")[1].entity == "ABCD_SIBLING_SIBLING");
|
||||
CHECK(diagram.layout().at("ABCD").size() == 2);
|
||||
CHECK(diagram.layout().at("ABCD")[0].hint ==
|
||||
clanguml::config::hint_t::up);
|
||||
CHECK(diagram.layout().at("ABCD")[0].entity == "ABCD_SUBCLASS");
|
||||
CHECK(diagram.layout().at("ABCD")[1].hint ==
|
||||
clanguml::config::hint_t::left);
|
||||
CHECK(diagram.layout().at("ABCD")[1].entity == "ABCD_SIBLING");
|
||||
|
||||
CHECK(diagram.layout().at("ABCD_SIBLING").size() == 2);
|
||||
CHECK(diagram.layout().at("ABCD_SIBLING")[0].hint ==
|
||||
clanguml::config::hint_t::right);
|
||||
CHECK(diagram.layout().at("ABCD_SIBLING")[0].entity ==
|
||||
"ABCD_OTHER_SIBLING");
|
||||
CHECK(diagram.layout().at("ABCD_SIBLING")[1].hint ==
|
||||
clanguml::config::hint_t::down);
|
||||
CHECK(diagram.layout().at("ABCD_SIBLING")[1].entity ==
|
||||
"ABCD_SIBLING_SIBLING");
|
||||
};
|
||||
|
||||
check_layout(static_cast<clanguml::config::class_diagram &>(
|
||||
*cfg.diagrams["class_main"]),
|
||||
clanguml::config::diagram_type::class_diagram);
|
||||
|
||||
check_layout(static_cast<clanguml::config::package_diagram &>(
|
||||
*cfg.diagrams["package_main"]),
|
||||
clanguml::config::diagram_type::package_diagram);
|
||||
}
|
||||
@@ -19,4 +19,19 @@ diagrams:
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml
|
||||
- ABCD
|
||||
- ABCD
|
||||
package_main:
|
||||
type: package
|
||||
glob:
|
||||
- src/**/*.cc
|
||||
- src/**/*.h
|
||||
using_namespace:
|
||||
- clanguml
|
||||
generate_method_arguments: full
|
||||
layout:
|
||||
ABCD:
|
||||
- up: ABCD_SUBCLASS
|
||||
- left: ABCD_SIBLING
|
||||
ABCD_SIBLING:
|
||||
- right: ABCD_OTHER_SIBLING
|
||||
- down: ABCD_SIBLING_SIBLING
|
||||
Reference in New Issue
Block a user