Added support for iterating over diagram elements from inja templates (fixes #54)

This commit is contained in:
Bartek Kryza
2022-09-15 23:36:29 +02:00
parent 693a09e20d
commit 17db587426
20 changed files with 115 additions and 20 deletions

View File

@@ -74,6 +74,8 @@ public:
virtual bool should_include(
const namespace_ &ns, const std::string &name) const;
virtual inja::json context() const = 0;
private:
std::string name_;
std::unique_ptr<diagram_filter> filter_;

View File

@@ -48,6 +48,8 @@ public:
std::string name() const { return name_; }
virtual std::string type_name() const { return "__undefined__"; };
virtual std::string full_name(bool /*relative*/) const { return name(); }
std::vector<relationship> &relationships();

View File

@@ -40,6 +40,7 @@ inja::json element::context() const
{
inja::json ctx;
ctx["name"] = name();
ctx["type"] = type_name();
ctx["alias"] = alias();
ctx["full_name"] = full_name(false);
ctx["namespace"] = get_namespace().to_string();

View File

@@ -71,7 +71,7 @@ public:
return dynamic_cast<nested_trait<T, Path> &>(parent.value())
.template add_element<V>(std::move(p));
else {
spdlog::error("No parent element found at: {}", path.to_string());
spdlog::info("No parent element found at: {}", path.to_string());
throw std::runtime_error(
"No parent element found for " + path.to_string());
}

View File

@@ -42,6 +42,8 @@ public:
package &operator=(const package &) = delete;
package &operator=(package &&) = delete;
std::string type_name() const override { return "package"; }
std::string full_name(bool relative) const override;
bool is_deprecated() const;