Fixed namespace exclusion filtering
This commit is contained in:
@@ -2,7 +2,7 @@ compilation_database_dir: debug
|
|||||||
output_directory: docs/diagrams
|
output_directory: docs/diagrams
|
||||||
generate_links:
|
generate_links:
|
||||||
link: 'https://github.com/bkryza/clang-uml/blob/{{ git.commit }}/{{ element.source.path }}#L{{ element.source.line }}'
|
link: 'https://github.com/bkryza/clang-uml/blob/{{ git.commit }}/{{ element.source.path }}#L{{ element.source.line }}'
|
||||||
tooltip: '{% if "comment" in element %}{{ abbrv(trim(replace(element.comment, "\n+", " ")), 256) }}{% else %}{{ element.name }}{% endif %}'
|
tooltip: '{% if existsIn(element, "comment") and existsIn(element.comment, "brief") %}{{ abbrv(trim(replace(element.comment.brief.0, "\n+", " ")), 256) }}{% else %}{{ element.name }}{% endif %}'
|
||||||
diagrams:
|
diagrams:
|
||||||
main_package:
|
main_package:
|
||||||
include!: uml/main_package_diagram.yml
|
include!: uml/main_package_diagram.yml
|
||||||
|
|||||||
@@ -208,6 +208,9 @@ void generator<C, D>::generate_plantuml_directives(
|
|||||||
|
|
||||||
ostr << directive << '\n';
|
ostr << directive << '\n';
|
||||||
}
|
}
|
||||||
|
catch (const inja::json::parse_error &e) {
|
||||||
|
LOG_ERROR("Failed to parse Jinja template: {}", d);
|
||||||
|
}
|
||||||
catch (const inja::json::exception &e) {
|
catch (const inja::json::exception &e) {
|
||||||
LOG_ERROR("Failed to render PlantUML directive: \n{}\n due to: {}",
|
LOG_ERROR("Failed to render PlantUML directive: \n{}\n due to: {}",
|
||||||
d, e.what());
|
d, e.what());
|
||||||
@@ -236,20 +239,42 @@ void generator<C, D>::generate_link(std::ostream &ostr, const E &e) const
|
|||||||
if (e.file().empty())
|
if (e.file().empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!m_config.generate_links().link.empty()) {
|
ostr << " [[";
|
||||||
ostr << " [[";
|
try {
|
||||||
ostr << env().render(std::string_view{m_config.generate_links().link},
|
if (!m_config.generate_links().link.empty()) {
|
||||||
element_context(e));
|
|
||||||
|
ostr << env().render(
|
||||||
|
std::string_view{m_config.generate_links().link},
|
||||||
|
element_context(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const inja::json::parse_error &e) {
|
||||||
|
LOG_ERROR("Failed to parse Jinja template: {}",
|
||||||
|
m_config.generate_links().link);
|
||||||
|
}
|
||||||
|
catch (const inja::json::exception &e) {
|
||||||
|
LOG_ERROR("Failed to render PlantUML directive: \n{}\n due to: {}",
|
||||||
|
m_config.generate_links().link, e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_config.generate_links().tooltip.empty()) {
|
ostr << "{";
|
||||||
ostr << "{";
|
try {
|
||||||
ostr << env().render(
|
if (!m_config.generate_links().tooltip.empty()) {
|
||||||
std::string_view{m_config.generate_links().tooltip},
|
ostr << env().render(
|
||||||
element_context(e));
|
std::string_view{m_config.generate_links().tooltip},
|
||||||
ostr << "}";
|
element_context(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const inja::json::parse_error &e) {
|
||||||
|
LOG_ERROR("Failed to parse Jinja template: {}",
|
||||||
|
m_config.generate_links().link);
|
||||||
|
}
|
||||||
|
catch (const inja::json::exception &e) {
|
||||||
|
LOG_ERROR("Failed to render PlantUML directive: \n{}\n due to: {}",
|
||||||
|
m_config.generate_links().link, e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ostr << "}";
|
||||||
ostr << "]]";
|
ostr << "]]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ void diagram_element::complete(bool completed) { complete_ = completed; }
|
|||||||
bool operator==(const diagram_element &l, const diagram_element &r)
|
bool operator==(const diagram_element &l, const diagram_element &r)
|
||||||
{
|
{
|
||||||
return l.id() == r.id();
|
return l.id() == r.id();
|
||||||
// return l.full_name(false) == r.full_name(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const diagram_element &rhs)
|
std::ostream &operator<<(std::ostream &out, const diagram_element &rhs)
|
||||||
|
|||||||
@@ -173,11 +173,23 @@ tvl::value_t namespace_filter::match(
|
|||||||
const diagram & /*d*/, const element &e) const
|
const diagram & /*d*/, const element &e) const
|
||||||
{
|
{
|
||||||
if (dynamic_cast<const package *>(&e) != nullptr) {
|
if (dynamic_cast<const package *>(&e) != nullptr) {
|
||||||
return tvl::any_of(
|
return tvl::any_of(namespaces_.begin(), namespaces_.end(),
|
||||||
namespaces_.begin(), namespaces_.end(), [&e](const auto &nsit) {
|
[&e, is_inclusive = is_inclusive()](const auto &nsit) {
|
||||||
return (e.get_namespace() | e.name()).starts_with(nsit) ||
|
auto element_full_name_starts_with_namespace =
|
||||||
nsit.starts_with(e.get_namespace() | e.name()) ||
|
(e.get_namespace() | e.name()).starts_with(nsit);
|
||||||
|
auto element_full_name_equals_pattern =
|
||||||
(e.get_namespace() | e.name()) == nsit;
|
(e.get_namespace() | e.name()) == nsit;
|
||||||
|
auto namespace_starts_with_element_qualified_name =
|
||||||
|
nsit.starts_with(e.get_namespace());
|
||||||
|
|
||||||
|
auto result = element_full_name_starts_with_namespace |
|
||||||
|
element_full_name_equals_pattern;
|
||||||
|
|
||||||
|
if (is_inclusive)
|
||||||
|
result =
|
||||||
|
result | namespace_starts_with_element_qualified_name;
|
||||||
|
|
||||||
|
return result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -10,10 +10,6 @@ diagrams:
|
|||||||
include:
|
include:
|
||||||
namespaces:
|
namespaces:
|
||||||
- clanguml::t00014
|
- clanguml::t00014
|
||||||
exclude:
|
|
||||||
namespaces:
|
|
||||||
- std
|
|
||||||
- clanguml::t00014::std
|
|
||||||
plantuml:
|
plantuml:
|
||||||
before:
|
before:
|
||||||
- left to right direction
|
- left to right direction
|
||||||
@@ -19,4 +19,5 @@ diagrams:
|
|||||||
- inheritance
|
- inheritance
|
||||||
exclude:
|
exclude:
|
||||||
namespaces:
|
namespaces:
|
||||||
- std
|
- clanguml::t00039::detail
|
||||||
|
- clanguml::t00039::ns3::detail
|
||||||
@@ -42,6 +42,11 @@ struct AAAA : public virtual AAA {
|
|||||||
};
|
};
|
||||||
} // namespace ns2
|
} // namespace ns2
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
struct AA : public A {
|
||||||
|
};
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
namespace ns3 {
|
namespace ns3 {
|
||||||
template <typename T> struct F {
|
template <typename T> struct F {
|
||||||
T *t;
|
T *t;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ TEST_CASE("t00039", "[test-case][class]")
|
|||||||
REQUIRE_THAT(puml, IsBaseClass(_A("A"), _A("AA")));
|
REQUIRE_THAT(puml, IsBaseClass(_A("A"), _A("AA")));
|
||||||
REQUIRE_THAT(puml, IsBaseClass(_A("AA"), _A("AAA")));
|
REQUIRE_THAT(puml, IsBaseClass(_A("AA"), _A("AAA")));
|
||||||
REQUIRE_THAT(puml, IsBaseClass(_A("AAA"), _A("ns2::AAAA")));
|
REQUIRE_THAT(puml, IsBaseClass(_A("AAA"), _A("ns2::AAAA")));
|
||||||
|
REQUIRE_THAT(puml, !IsClass(_A("detail::AA")));
|
||||||
|
|
||||||
REQUIRE_THAT(puml, !IsClass(_A("B")));
|
REQUIRE_THAT(puml, !IsClass(_A("B")));
|
||||||
REQUIRE_THAT(puml, !IsClass(_A("ns1::BB")));
|
REQUIRE_THAT(puml, !IsClass(_A("ns1::BB")));
|
||||||
|
|||||||
@@ -15,3 +15,6 @@ diagrams:
|
|||||||
- clanguml::t00041::RR
|
- clanguml::t00041::RR
|
||||||
subclasses:
|
subclasses:
|
||||||
- clanguml::t00041::ns1::N
|
- clanguml::t00041::ns1::N
|
||||||
|
exclude:
|
||||||
|
namespaces:
|
||||||
|
- clanguml::t00041::detail
|
||||||
@@ -24,9 +24,15 @@ struct E {
|
|||||||
struct F {
|
struct F {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
struct G {
|
||||||
|
};
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
struct RR : public R {
|
struct RR : public R {
|
||||||
E *e;
|
E *e;
|
||||||
F *f;
|
F *f;
|
||||||
|
detail::G *g;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RRR : public RR {
|
struct RRR : public RR {
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ TEST_CASE("t00041", "[test-case][class]")
|
|||||||
REQUIRE_THAT(puml, IsClass(_A("R")));
|
REQUIRE_THAT(puml, IsClass(_A("R")));
|
||||||
REQUIRE_THAT(puml, IsClass(_A("RR")));
|
REQUIRE_THAT(puml, IsClass(_A("RR")));
|
||||||
REQUIRE_THAT(puml, IsClass(_A("RRR")));
|
REQUIRE_THAT(puml, IsClass(_A("RRR")));
|
||||||
|
REQUIRE_THAT(puml, !IsClass(_A("detail::G")));
|
||||||
|
|
||||||
REQUIRE_THAT(puml, IsBaseClass(_A("R"), _A("RR")));
|
REQUIRE_THAT(puml, IsBaseClass(_A("R"), _A("RR")));
|
||||||
REQUIRE_THAT(puml, IsBaseClass(_A("RR"), _A("RRR")));
|
REQUIRE_THAT(puml, IsBaseClass(_A("RR"), _A("RRR")));
|
||||||
|
|||||||
Reference in New Issue
Block a user