Fixed namespace exclusion filtering

This commit is contained in:
Bartek Kryza
2022-09-21 23:01:31 +02:00
parent 920388d84a
commit 4caf7308b2
11 changed files with 71 additions and 22 deletions

View File

@@ -208,6 +208,9 @@ void generator<C, D>::generate_plantuml_directives(
ostr << directive << '\n';
}
catch (const inja::json::parse_error &e) {
LOG_ERROR("Failed to parse Jinja template: {}", d);
}
catch (const inja::json::exception &e) {
LOG_ERROR("Failed to render PlantUML directive: \n{}\n due to: {}",
d, e.what());
@@ -236,20 +239,42 @@ void generator<C, D>::generate_link(std::ostream &ostr, const E &e) const
if (e.file().empty())
return;
if (!m_config.generate_links().link.empty()) {
ostr << " [[";
ostr << env().render(std::string_view{m_config.generate_links().link},
element_context(e));
ostr << " [[";
try {
if (!m_config.generate_links().link.empty()) {
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 << env().render(
std::string_view{m_config.generate_links().tooltip},
element_context(e));
ostr << "}";
ostr << "{";
try {
if (!m_config.generate_links().tooltip.empty()) {
ostr << env().render(
std::string_view{m_config.generate_links().tooltip},
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 << "]]";
}

View File

@@ -96,7 +96,6 @@ void diagram_element::complete(bool completed) { complete_ = completed; }
bool operator==(const diagram_element &l, const diagram_element &r)
{
return l.id() == r.id();
// return l.full_name(false) == r.full_name(false);
}
std::ostream &operator<<(std::ostream &out, const diagram_element &rhs)

View File

@@ -173,11 +173,23 @@ tvl::value_t namespace_filter::match(
const diagram & /*d*/, const element &e) const
{
if (dynamic_cast<const package *>(&e) != nullptr) {
return tvl::any_of(
namespaces_.begin(), namespaces_.end(), [&e](const auto &nsit) {
return (e.get_namespace() | e.name()).starts_with(nsit) ||
nsit.starts_with(e.get_namespace() | e.name()) ||
return tvl::any_of(namespaces_.begin(), namespaces_.end(),
[&e, is_inclusive = is_inclusive()](const auto &nsit) {
auto element_full_name_starts_with_namespace =
(e.get_namespace() | e.name()).starts_with(nsit);
auto element_full_name_equals_pattern =
(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 {