32 if (
const auto maybe_comment = jc.
get().comment();
33 maybe_comment.has_value()) {
34 ctx[
"element"][
"comment"] = maybe_comment.value();
51 ctx[
"element"][
"type"] = jc.
get().type_name();
52 ctx[
"element"][
"alias"] = jc.
get().alias();
53 ctx[
"element"][
"full_name"] =
55 auto maybe_doxygen_link = jc.
get().doxygen_link();
56 if (maybe_doxygen_link)
57 ctx[
"element"][
"doxygen_link"] = maybe_doxygen_link.value();
66 ctx[
"element"][
"using_namespace"] = jc.
get().using_namespace().to_string();
67 ctx[
"element"][
"namespace"] = jc.
get().get_namespace().to_string();
75 ctx[
"element"][
"type"] =
"relationship";
76 ctx[
"element"][
"name"] = jc.
get().label();
77 ctx[
"element"][
"relationship_type"] =
to_string(jc.
get().type());
78 ctx[
"element"][
"multiplicity"][
"source"] = jc.
get().multiplicity_source();
79 ctx[
"element"][
"multiplicity"][
"destination"] =
80 jc.
get().multiplicity_destination();
90 std::filesystem::path fullNamePath{
91 ctx[
"element"][
"full_name"].get<std::string>()};
92 fullNamePath.make_preferred();
93 ctx[
"element"][
"full_name"] = fullNamePath.string();
98 const auto &e = jc.
get();
100 if (!e.file().empty()) {
101 const std::filesystem::path file{e.file()};
102 std::string git_relative_path = file.string();
103 if (!e.file_relative().empty()) {
105 if (file.is_absolute() && ctx.contains(
"git")) {
107 if (file.is_absolute() && ctx.contains(
"git")) {
110 std::filesystem::relative(file, ctx[
"git"][
"toplevel"])
115 ctx[
"source"][
"path"] = e.file();
119 git_relative_path =
"";
120 ctx[
"source"][
"path"] = e.file();
123 ctx[
"source"][
"full_path"] = file.string();
124 ctx[
"source"][
"name"] = file.filename().string();
125 ctx[
"source"][
"line"] = e.line();
131 const auto &e = jc.
get();
133 if (!e.file().empty()) {
134 const std::filesystem::path file{e.file()};
135 std::string git_relative_path = file.string();
136 if (!e.file_relative().empty()) {
138 if (file.is_absolute() && ctx.contains(
"git")) {
140 if (file.is_absolute() && ctx.contains(
"git")) {
143 std::filesystem::relative(file, ctx[
"git"][
"toplevel"])
145 ctx[
"element"][
"source"][
"path"] =
149 ctx[
"element"][
"source"][
"path"] = e.file();
153 git_relative_path =
"";
154 ctx[
"element"][
"source"][
"path"] = e.file();
157 ctx[
"element"][
"source"][
"full_path"] = file.string();
158 ctx[
"element"][
"source"][
"name"] = file.filename().string();
159 ctx[
"element"][
"source"][
"line"] = e.line();
166 if (
const auto maybe_comment = jc.
get().comment();
167 maybe_comment.has_value()) {
168 ctx[
"comment"] = maybe_comment.value();
178 ctx[
"type"] = jc.
get().type_name();
179 ctx[
"alias"] = jc.
get().alias();
181 auto maybe_doxygen_link = jc.
get().doxygen_link();
182 if (maybe_doxygen_link)
183 ctx[
"doxygen_link"] = maybe_doxygen_link.value();
192 ctx[
"using_namespace"] = jc.
get().using_namespace().to_string();
193 ctx[
"namespace"] = jc.
get().get_namespace().to_string();
194 if (
const auto maybe_comment = jc.
get().comment();
195 maybe_comment.has_value()) {
196 ctx[
"comment"] = maybe_comment.value();
204 std::filesystem::path fullNamePath{ctx[
"full_name"].get<std::string>()};
205 fullNamePath.make_preferred();
206 ctx[
"full_name"] = fullNamePath.string();
210 const inja::json &
context,
const std::string &jinja_template)
212 std::optional<std::string> result;
214 if (jinja_template.empty())
219 auto rendered_template =
220 env.render(std::string_view{jinja_template},
context);
222 result = std::move(rendered_template);
225 LOG_WARN(
"Failed to render Jinja template '{}' due to unresolvable "
227 jinja_template, e.what());
229 catch (
const inja::json::parse_error &e) {
230 LOG_WARN(
"Failed to parse Jinja template: {}", jinja_template);
232 catch (
const inja::json::exception &e) {
233 LOG_WARN(
"Failed to render Jinja template: \n{}\n due to: {}",
234 jinja_template, e.what());
236 catch (
const std::regex_error &e) {
237 LOG_WARN(
"Failed to render Jinja template: \n{}\n due to "
238 "std::regex_error: {}",
239 jinja_template, e.what());
241 catch (
const std::exception &e) {
242 LOG_WARN(
"Failed to render Jinja template: \n{}\n due to: {}",
243 jinja_template, e.what());
250 inja::Environment &env,
const std::string &jinja_template)