Fixed nested class namespace rendering
This commit is contained in:
@@ -23,6 +23,30 @@
|
||||
namespace clanguml {
|
||||
namespace util {
|
||||
|
||||
std::vector<std::string> split(std::string str, std::string delimiter)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
|
||||
while (str.size()) {
|
||||
int index = str.find(delimiter);
|
||||
if (index != std::string::npos) {
|
||||
result.push_back(str.substr(0, index));
|
||||
str = str.substr(index + delimiter.size());
|
||||
if (str.size() == 0)
|
||||
result.push_back(str);
|
||||
}
|
||||
else {
|
||||
result.push_back(str);
|
||||
str = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (result.empty())
|
||||
result.push_back(str);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string namespace_relative(
|
||||
const std::vector<std::string> &namespaces, const std::string &n)
|
||||
{
|
||||
@@ -31,7 +55,7 @@ std::string namespace_relative(
|
||||
continue;
|
||||
|
||||
if (n == ns)
|
||||
return "";
|
||||
return split(n, "::").back();
|
||||
|
||||
if (n.find(ns) == 0) {
|
||||
if (n.size() <= ns.size() + 2)
|
||||
|
||||
@@ -6,6 +6,8 @@ diagrams:
|
||||
glob:
|
||||
- ../../tests/t00004/t00004.cc
|
||||
using_namespace:
|
||||
- clanguml::t00004::A::AA
|
||||
- clanguml::t00004::A
|
||||
- clanguml::t00004
|
||||
include:
|
||||
namespaces:
|
||||
|
||||
@@ -255,9 +255,9 @@ TEST_CASE("Test t00004", "[unit-test]")
|
||||
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||
REQUIRE_THAT(puml, Contains("class A"));
|
||||
REQUIRE_THAT(puml, Contains("A +-- A::AA"));
|
||||
REQUIRE_THAT(puml, Contains("A::AA +-- A::AA::AAA"));
|
||||
REQUIRE_THAT(puml, Contains("A::AA +-- A::AA::Lights"));
|
||||
REQUIRE_THAT(puml, Contains("A +-- AA"));
|
||||
REQUIRE_THAT(puml, Contains("AA +-- AAA"));
|
||||
REQUIRE_THAT(puml, Contains("AA +-- Lights"));
|
||||
|
||||
save_puml(
|
||||
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||
|
||||
Reference in New Issue
Block a user