Added JSON package diagram generator

This commit is contained in:
Bartek Kryza
2023-03-25 12:20:35 +01:00
parent 43b81f97ce
commit c1bce60656
6 changed files with 285 additions and 44 deletions

View File

@@ -32,37 +32,48 @@ TEST_CASE("t30001", "[test-case][package]")
REQUIRE(!model->should_include("clanguml::t30001::detail::C"));
REQUIRE(!model->should_include("std::vector"));
auto puml = generate_package_puml(diagram, *model);
AliasMatcher _A(puml);
{
auto puml = generate_package_puml(diagram, *model);
AliasMatcher _A(puml);
REQUIRE_THAT(puml, StartsWith("@startuml"));
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
REQUIRE_THAT(puml, StartsWith("@startuml"));
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
REQUIRE_THAT(puml, IsPackage("A"));
REQUIRE_THAT(puml, IsPackage("AAA"));
REQUIRE_THAT(puml, IsPackage("AAA"));
REQUIRE_THAT(puml, IsPackage("A"));
REQUIRE_THAT(puml, IsPackage("AAA"));
REQUIRE_THAT(puml, IsPackage("AAA"));
// TODO: Fix _A() to handle fully qualified names, right
// now it only finds the first element with unqualified
// name match
REQUIRE_THAT(
puml, HasNote(_A("AA"), "top", "This is namespace AA in namespace A"));
// TODO: Fix _A() to handle fully qualified names, right
// now it only finds the first element with unqualified
// name match
REQUIRE_THAT(puml,
HasNote(_A("AA"), "top", "This is namespace AA in namespace A"));
REQUIRE_THAT(puml,
HasLink(_A("AAA"),
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
"t30001/t30001.cc#L6",
clanguml::util::get_git_commit()),
"AAA"));
REQUIRE_THAT(puml,
HasLink(_A("AAA"),
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
"t30001/t30001.cc#L6",
clanguml::util::get_git_commit()),
"AAA"));
REQUIRE_THAT(puml,
HasLink(_A("BBB"),
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
"t30001/t30001.cc#L8",
clanguml::util::get_git_commit()),
"BBB"));
REQUIRE_THAT(puml,
HasLink(_A("BBB"),
fmt::format("https://github.com/bkryza/clang-uml/blob/{}/tests/"
"t30001/t30001.cc#L8",
clanguml::util::get_git_commit()),
"BBB"));
REQUIRE_THAT(puml, HasComment("t30001 test diagram of type package"));
REQUIRE_THAT(puml, HasComment("t30001 test diagram of type package"));
save_puml(config.output_directory() + "/" + diagram->name + ".puml", puml);
save_puml(
config.output_directory() + "/" + diagram->name + ".puml", puml);
}
{
auto j = generate_package_json(diagram, *model);
using namespace json;
save_json(config.output_directory() + "/" + diagram->name + ".json", j);
}
}