Enabled multiple relative link patterns in generate_links option (#297)

This commit is contained in:
Bartek Kryza
2024-07-28 18:33:14 +02:00
parent 37314baa3a
commit f97d42083b
7 changed files with 216 additions and 88 deletions

View File

@@ -450,8 +450,9 @@ void generator<C, D>::generate_link(std::ostream &ostr, const E &e) const
auto maybe_link_pattern = generators::generator<C, D>::get_link_pattern(e);
if (!maybe_link_pattern)
if (!maybe_link_pattern) {
return;
}
const auto &[link_prefix, link_pattern] = *maybe_link_pattern;
@@ -467,7 +468,7 @@ void generator<C, D>::generate_link(std::ostream &ostr, const E &e) const
catch (const inja::json::parse_error &e) {
LOG_ERROR("Failed to parse Jinja template: {}", link_pattern);
}
catch (const inja::json::exception &e) {
catch (const std::exception &e) {
LOG_ERROR("Failed to render PlantUML directive: \n{}\n due to: {}",
link_pattern, e.what());
}
@@ -475,29 +476,28 @@ void generator<C, D>::generate_link(std::ostream &ostr, const E &e) const
auto maybe_tooltip_pattern =
generators::generator<C, D>::get_tooltip_pattern(e);
if (!maybe_tooltip_pattern)
return;
if (maybe_tooltip_pattern) {
const auto &[tooltip_prefix, tooltip_pattern] = *maybe_tooltip_pattern;
const auto &[tooltip_prefix, tooltip_pattern] = *maybe_tooltip_pattern;
ostr << "{";
try {
auto ec = generators::generator<C, D>::element_context(e);
common::generators::make_context_source_relative(ec, tooltip_prefix);
if (!tooltip_pattern.empty()) {
ostr << generators::generator<C, D>::env().render(
std::string_view{tooltip_pattern}, ec);
ostr << "{";
try {
auto ec = generators::generator<C, D>::element_context(e);
common::generators::make_context_source_relative(
ec, tooltip_prefix);
if (!tooltip_pattern.empty()) {
ostr << generators::generator<C, D>::env().render(
std::string_view{tooltip_pattern}, ec);
}
}
catch (const inja::json::parse_error &e) {
LOG_ERROR("Failed to parse Jinja template: {}", tooltip_pattern);
}
catch (const std::exception &e) {
LOG_ERROR("Failed to render PlantUML directive: \n{}\n due to: {}",
tooltip_pattern, e.what());
}
ostr << "}";
}
catch (const inja::json::parse_error &e) {
LOG_ERROR("Failed to parse Jinja template: {}", tooltip_pattern);
}
catch (const inja::json::exception &e) {
LOG_ERROR("Failed to render PlantUML directive: \n{}\n due to: {}",
tooltip_pattern, e.what());
}
ostr << "}";
ostr << "]]";
}