Added support for C++20 module based packages in class diagrams (#101)

This commit is contained in:
Bartek Kryza
2023-12-18 21:55:18 +01:00
parent ea6892f754
commit c51ae5b6ee
24 changed files with 296 additions and 12 deletions

View File

@@ -170,10 +170,17 @@ void generator::generate(const package &p, nlohmann::json &parent) const
if (!uns.starts_with({p.full_name(false)})) {
LOG_DBG("Generating package {}", p.name());
if (config().package_type() == config::package_type_t::kDirectory)
switch (config().package_type()) {
case config::package_type_t::kDirectory:
package_object["type"] = "directory";
else
break;
case config::package_type_t::kModule:
package_object["type"] = "module";
break;
case config::package_type_t::kNamespace:
package_object["type"] = "namespace";
break;
}
package_object["name"] = p.name();
package_object["display_name"] = p.full_name(false);

View File

@@ -67,7 +67,7 @@ void generator::generate_alias(const class_ &c, std::ostream &ostr) const
class_type = "abstract";
std::string full_name;
if (config().generate_packages())
if (config().generate_fully_qualified_name())
full_name = c.full_name_no_ns();
else
full_name = c.full_name();
@@ -89,7 +89,7 @@ void generator::generate_alias(const enum_ &e, std::ostream &ostr) const
{
print_debug(e, ostr);
if (config().generate_packages())
if (config().generate_fully_qualified_name())
ostr << "enum"
<< " \"" << e.name();
else
@@ -106,7 +106,7 @@ void generator::generate_alias(const concept_ &c, std::ostream &ostr) const
{
print_debug(c, ostr);
if (config().generate_packages())
if (config().generate_fully_qualified_name())
ostr << "class"
<< " \"" << c.name();
else

View File

@@ -2150,6 +2150,15 @@ void translation_unit_visitor::add_class(std::unique_ptr<class_> &&c)
diagram().add(p, std::move(c));
}
else if ((config().generate_packages() &&
config().package_type() == config::package_type_t::kModule)) {
const auto module_path = config().make_module_relative(c->module());
common::model::path p{module_path, common::model::path_type::kModule};
diagram().add(p, std::move(c));
}
else {
diagram().add(c->path(), std::move(c));
}
@@ -2169,6 +2178,15 @@ void translation_unit_visitor::add_enum(std::unique_ptr<enum_> &&e)
diagram().add(p, std::move(e));
}
else if ((config().generate_packages() &&
config().package_type() == config::package_type_t::kModule)) {
const auto module_path = config().make_module_relative(e->module());
common::model::path p{module_path, common::model::path_type::kModule};
diagram().add(p, std::move(e));
}
else {
diagram().add(e->path(), std::move(e));
}
@@ -2188,6 +2206,15 @@ void translation_unit_visitor::add_concept(std::unique_ptr<concept_> &&c)
diagram().add(p, std::move(c));
}
else if ((config().generate_packages() &&
config().package_type() == config::package_type_t::kModule)) {
const auto module_path = config().make_module_relative(c->module());
common::model::path p{module_path, common::model::path_type::kModule};
diagram().add(p, std::move(c));
}
else {
diagram().add(c->path(), std::move(c));
}