Updated code for Doxygen documentation

This commit is contained in:
Bartek Kryza
2023-06-23 19:39:25 +02:00
parent d8ef12d1c6
commit 321fb177a9
148 changed files with 579 additions and 204 deletions

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/generators/json/class_diagram_generator.cc
* @file rc/class_diagram/generators/json/class_diagram_generator.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/generators/json/class_diagram_generator.h
* @file src/class_diagram/generators/json/class_diagram_generator.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/generators/plantuml/class_diagram_generator.cc
* @file src/class_diagram/generators/plantuml/class_diagram_generator.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*
@@ -813,10 +813,9 @@ void generator::generate(const package &p, std::ostream &ostr) const
// using_namespace
if (!uns.starts_with({p.full_name(false)})) {
ostr << "}" << '\n';
}
}
generate_notes(ostr, p);
}
}
}
void generator::generate_relationships(

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/generators/plantuml/class_diagram_generator.h
* @file src/class_diagram/generators/plantuml/class_diagram_generator.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/class.cc
* @file src/class_diagram/model/class.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*
@@ -37,6 +37,10 @@ bool class_::is_template() const { return is_template_; }
void class_::is_template(bool is_template) { is_template_ = is_template; }
bool class_::is_union() const { return is_union_; }
void class_::is_union(bool is_union) { is_union_ = is_union; }
void class_::add_member(class_member &&member)
{
members_.emplace_back(std::move(member));
@@ -121,4 +125,24 @@ int class_::calculate_template_specialization_match(const class_ &other) const
return template_trait::calculate_template_specialization_match(other);
}
void class_::template_specialization_found(bool found)
{
template_specialization_found_ = found;
}
bool class_::template_specialization_found() const
{
return template_specialization_found_;
}
std::optional<std::string> class_::doxygen_link() const
{
auto type = is_struct() ? "struct" : "class";
auto name = name_and_ns();
util::replace_all(name, "_", "__");
util::replace_all(name, "::", "_1_1");
return fmt::format("{}{}.html", type, name);
}
} // namespace clanguml::class_diagram::model

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/class.h
* @file src/class_diagram/model/class.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*
@@ -32,6 +32,9 @@
namespace clanguml::class_diagram::model {
/**
* @brief Diagram element representing a class or class template.
*/
class class_ : public common::model::element,
public common::model::stylable_element,
public template_trait {
@@ -43,44 +46,165 @@ public:
class_ &operator=(const class_ &) = delete;
class_ &operator=(class_ &&) = delete;
std::string type_name() const override { return "class"; }
bool is_struct() const;
void is_struct(bool is_struct);
bool is_template() const;
void is_template(bool is_template);
bool is_union() const { return is_union_; }
void is_union(bool u) { is_union_ = u; }
void add_member(class_member &&member);
void add_method(class_method &&method);
void add_parent(class_parent &&parent);
const std::vector<class_member> &members() const;
const std::vector<class_method> &methods() const;
const std::vector<class_parent> &parents() const;
friend bool operator==(const class_ &l, const class_ &r);
/**
* Get the type name of the diagram element.
*
* @return Type name of the diagram element.
*/
std::string type_name() const override { return "class"; }
/**
* Whether or not the class was declared in the code as 'struct'.
*
* @return True, if the class was declared as 'struct'
*/
bool is_struct() const;
/**
* Set, whether the class was declared as 'struct'.
*
* @param is_struct True, if the class was declared as 'struct'
*/
void is_struct(bool is_struct);
/**
* Whether or not the class is a template.
*
* @return True, if the class is a template.
*/
bool is_template() const;
/**
* Set, whether the class is a template.
*
* @param is_struct True, if the class is a template.
*/
void is_template(bool is_template);
/**
* Whether or not the class is a union.
*
* @return True, if the class is a union.
*/
bool is_union() const;
/**
* Set, whether the class is a union.
*
* @param u True, if the class is a union.
*/
void is_union(bool is_union);
/**
* Add a data member to the class.
*
* @param member Class data member.
*/
void add_member(class_member &&member);
/**
* Add a method to the class.
*
* @param method Class method.
*/
void add_method(class_method &&method);
/**
* Add class parent (inheritance relationship).
*
* @todo Maybe it would be good to refactor this into a regular
* relationship. We could drop the 'class_parent' class completely...
*
* @param parent Class parent.
*/
void add_parent(class_parent &&parent);
/**
* Get reference to class member list.
*
* @return Reference to class members.
*/
const std::vector<class_member> &members() const;
/**
* Get reference to class method list.
*
* @return Reference to class methods.
*/
const std::vector<class_method> &methods() const;
/**
* Get reference to class parent list.
*
* @return Reference to class parents.
*/
const std::vector<class_parent> &parents() const;
/**
* @brief Get class full name.
*
* This method renders the entire class name including all template
* parameters and/or arguments.
*
* @param relative Whether the class name should be relative to
* using_namespace
* @return Full class name.
*/
std::string full_name(bool relative = true) const override;
/**
* @brief Get unqualified class ful name.
*
* This method returns the class full name but without any namespace
* qualifier.
*
* @return Full class name without namespace.
*/
std::string full_name_no_ns() const override;
/**
* Whether the class is abstract.
*
* @return True, if at least one method is abstract (=0).
*/
bool is_abstract() const;
/**
* @brief Calculate template specialization match with other class.
*
* This method is a wrapper over
* @ref template_trait::calculate_template_specialization_match()
*
* @param other
* @return
*/
int calculate_template_specialization_match(const class_ &other) const;
void template_specialization_found(bool found)
{
template_specialization_found_ = found;
}
/**
* Whether, a template specialization has already been found for this class.
* @return True, if a template specialization has already been found.
*/
bool template_specialization_found() const;
bool template_specialization_found() const
{
return template_specialization_found_;
}
/**
* Set, whether a template specialization has already been found for this
* class.
*
* @param found True, if a template specialization has already been found.
*/
void template_specialization_found(bool found);
/**
* @brief Generate Doxygen style HTML link for the class.
*
* This method generates a link, which can be used in SVG diagrams to
* create links from classes to Doxygen documentation pages.
*
* @return Doxygen-style HTML link for the class.
*/
std::optional<std::string> doxygen_link() const override;
private:
bool is_struct_{false};
@@ -90,7 +214,6 @@ private:
std::vector<class_method> methods_;
std::vector<class_parent> bases_;
std::string base_template_full_name_;
std::string full_name_;
bool template_specialization_found_{false};

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/class_element.cc
* @file src/class_diagram/model/class_element.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/class_element.h
* @file src/class_diagram/model/class_element.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/class_member.cc
* @file src/class_diagram/model/class_member.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/class_member.h
* @file src/class_diagram/model/class_member.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/class_method.cc
* @file src/class_diagram/model/class_method.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/class_method.h
* @file src/class_diagram/model/class_method.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/class_parent.cc
* @file src/class_diagram/model/class_parent.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/class_parent.h
* @file src/class_diagram/model/class_parent.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/concept.cc
* @file src/class_diagram/model/concept.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/concept.h
* @file src/class_diagram/model/concept.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/diagram.cc
* @file src/class_diagram/model/diagram.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*
@@ -198,6 +198,11 @@ inja::json diagram::context() const
elements.emplace_back(e.get().context());
}
// Add enums
for (const auto &c : concepts()) {
elements.emplace_back(c.get().context());
}
ctx["elements"] = elements;
return ctx;

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/diagram.h
* @file src/class_diagram/model/diagram.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/enum.cc
* @file src/class_diagram/model/enum.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*
@@ -54,4 +54,11 @@ std::vector<std::string> &enum_::constants() { return constants_; }
const std::vector<std::string> &enum_::constants() const { return constants_; }
std::optional<std::string> enum_::doxygen_link() const
{
auto name = name_and_ns();
util::replace_all(name, "_", "__");
util::replace_all(name, "::", "_1_1");
return fmt::format("enum{}.html", name);
}
} // namespace clanguml::class_diagram::model

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/enum.h
* @file src/class_diagram/model/enum.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*
@@ -45,6 +45,8 @@ public:
const std::vector<std::string> &constants() const;
std::optional<std::string> doxygen_link() const override;
private:
std::vector<std::string> constants_;
};

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/method_parameter.cc
* @file src/class_diagram/model/method_parameter.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/model/method_parameter.h
* @file src/class_diagram/model/method_parameter.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*
@@ -31,6 +31,8 @@ public:
method_parameter(
std::string type, std::string name, std::string default_value = {});
virtual ~method_parameter() = default;
void set_type(const std::string &type);
std::string type() const;

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/visitor/template_builder.cc
* @file src/class_diagram/visitor/template_builder.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/visitor/template_builder.h
* @file src/class_diagram/visitor/template_builder.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/visitor/translation_unit_visitor.cc
* @file src/class_diagram/visitor/translation_unit_visitor.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/class_diagram/visitor/translation_unit_visitor.h
* @file src/class_diagram/visitor/translation_unit_visitor.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/options/cli_handler.cc
* @file src/options/cli_handler.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/*
* src/options/cli_handler.h
* @file src/options/cli_handler.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -90,4 +90,10 @@ void decorated_element::append(const decorated_element &de)
std::optional<comment_t> decorated_element::comment() const { return comment_; }
void decorated_element::set_comment(const comment_t &c) { comment_ = c; }
std::optional<std::string> decorated_element::doxygen_link() const
{
return std::nullopt;
}
} // namespace clanguml::common::model

View File

@@ -47,6 +47,8 @@ using comment_t = inja::json;
*/
class decorated_element {
public:
virtual ~decorated_element() = default;
/**
* Whether this element should be skipped from the diagram.
*
@@ -125,6 +127,13 @@ public:
*/
void set_comment(const comment_t &c);
/**
* Return Doxygen HTML documentation link for the element.
*
* @return Element context.
*/
virtual std::optional<std::string> doxygen_link() const;
private:
std::vector<std::shared_ptr<decorators::decorator>> decorators_;
std::optional<comment_t> comment_;

View File

@@ -68,12 +68,12 @@ bool diagram::should_include(const element &e) const
filter_->should_include(dynamic_cast<const source_location &>(e));
}
bool diagram::should_include(const std::string &name) const
bool diagram::should_include(const namespace_ &ns) const
{
if (filter_.get() == nullptr)
return true;
return filter_->should_include(name);
return filter_->should_include(ns);
}
bool diagram::should_include(const relationship_t r) const

View File

@@ -132,7 +132,7 @@ public:
// TODO: refactor to a template method
bool should_include(const element &e) const;
bool should_include(const std::string &e) const;
bool should_include(const namespace_ &ns) const;
bool should_include(const source_file &path) const;
bool should_include(relationship r) const;
bool should_include(relationship_t r) const;

View File

@@ -73,8 +73,12 @@ inja::json diagram_element::context() const
{
inja::json ctx;
ctx["name"] = name();
ctx["type"] = type_name();
ctx["alias"] = alias();
ctx["full_name"] = full_name(false);
auto maybe_doxygen_link = doxygen_link();
if (maybe_doxygen_link)
ctx["doxygen_link"] = maybe_doxygen_link.value();
return ctx;
}

View File

@@ -186,60 +186,100 @@ tvl::value_t namespace_filter::match(
if (ns.is_empty())
return {};
return tvl::any_of(
namespaces_.begin(), namespaces_.end(), [&ns](const auto &nsit) {
return tvl::any_of(namespaces_.begin(), namespaces_.end(),
[&ns, is_inclusive = is_inclusive()](const auto &nsit) {
if (std::holds_alternative<namespace_>(nsit.value())) {
const auto &ns_pattern = std::get<namespace_>(nsit.value());
return ns.starts_with(ns_pattern) || ns == ns_pattern;
if (is_inclusive)
return ns.starts_with(ns_pattern) ||
ns_pattern.starts_with(ns);
return ns.starts_with(ns_pattern);
}
const auto &regex = std::get<common::regex>(nsit.value());
return regex == ns.to_string();
return regex %= ns.to_string();
});
}
tvl::value_t namespace_filter::match(
const diagram & /*d*/, const element &e) const
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(),
if (d.type() != diagram_t::kPackage &&
dynamic_cast<const package *>(&e) != nullptr) {
auto result = tvl::any_of(namespaces_.begin(), namespaces_.end(),
[&e, is_inclusive = is_inclusive()](const auto &nsit) {
if (std::holds_alternative<namespace_>(nsit.value())) {
const auto &ns_pattern = std::get<namespace_>(nsit.value());
auto element_full_name_starts_with_namespace =
(e.get_namespace() | e.name()).starts_with(ns_pattern);
namespace_{e.name_and_ns()}.starts_with(ns_pattern);
auto element_full_name_equals_pattern =
(e.get_namespace() | e.name()) == ns_pattern;
namespace_{e.name_and_ns()} == ns_pattern;
auto namespace_starts_with_element_qualified_name =
ns_pattern.starts_with(e.get_namespace());
auto pattern_starts_with_element_full_name =
ns_pattern.starts_with(namespace_{e.name_and_ns()});
auto result = element_full_name_starts_with_namespace ||
element_full_name_equals_pattern;
if (is_inclusive)
result = result ||
namespace_starts_with_element_qualified_name;
result =
result || pattern_starts_with_element_full_name;
return result;
}
return std::get<common::regex>(nsit.value()) ==
return std::get<common::regex>(nsit.value()) %=
e.full_name(false);
});
if (tvl::is_false(result))
LOG_DBG("Element {} rejected by namespace_filter 1",
e.full_name(false));
return result;
}
return tvl::any_of(
if (d.type() == diagram_t::kPackage) {
auto result = tvl::any_of(namespaces_.begin(), namespaces_.end(),
[&e, is_inclusive = is_inclusive()](const auto &nsit) {
if (std::holds_alternative<namespace_>(nsit.value())) {
auto e_ns = namespace_{e.full_name(false)};
auto nsit_ns = std::get<namespace_>(nsit.value());
if (is_inclusive)
return e_ns.starts_with(nsit_ns) ||
nsit_ns.starts_with(e_ns) || e_ns == nsit_ns;
else
return e_ns.starts_with(nsit_ns) || e_ns == nsit_ns;
}
return std::get<common::regex>(nsit.value()) %=
e.full_name(false);
});
if (tvl::is_false(result))
LOG_DBG("Element {} rejected by namespace_filter (package diagram)",
e.full_name(false));
return result;
}
auto result = tvl::any_of(
namespaces_.begin(), namespaces_.end(), [&e](const auto &nsit) {
if (std::holds_alternative<namespace_>(nsit.value())) {
return e.get_namespace().starts_with(
std::get<namespace_>(nsit.value()));
}
return std::get<common::regex>(nsit.value()) == e.full_name(false);
return std::get<common::regex>(nsit.value()) %= e.full_name(false);
});
if (tvl::is_false(result))
LOG_DBG("Element {} rejected by namespace_filter", e.full_name(false));
return result;
}
element_filter::element_filter(
@@ -249,9 +289,12 @@ element_filter::element_filter(
{
}
tvl::value_t element_filter::match(
const diagram & /*d*/, const element &e) const
tvl::value_t element_filter::match(const diagram &d, const element &e) const
{
// Do not apply element filter to packages in class diagrams
if (d.type() == diagram_t::kClass && e.type_name() == "package")
return std::nullopt;
return tvl::any_of(
elements_.begin(), elements_.end(), [&e](const auto &el) {
return ((el == e.full_name(false)) ||

View File

@@ -34,11 +34,7 @@ const namespace_ &element::using_namespace() const { return using_namespace_; }
inja::json element::context() const
{
inja::json ctx;
ctx["name"] = name();
ctx["type"] = type_name();
ctx["alias"] = alias();
ctx["full_name"] = full_name(false);
inja::json ctx = diagram_element::context();
ctx["namespace"] = get_namespace().to_string();
if (const auto maybe_comment = comment(); maybe_comment.has_value()) {
ctx["comment"] = maybe_comment.value();

View File

@@ -40,4 +40,11 @@ bool package::is_deprecated() const { return is_deprecated_; }
void package::set_deprecated(bool deprecated) { is_deprecated_ = deprecated; }
std::optional<std::string> package::doxygen_link() const
{
auto name = full_name(false);
util::replace_all(name, "_", "__");
util::replace_all(name, "::", "_1_1");
return fmt::format("namespace{}.html", name);
}
} // namespace clanguml::common::model

View File

@@ -67,11 +67,14 @@ public:
void set_deprecated(bool deprecated);
/**
* Add subpackage.
* @brief Generate Doxygen style HTML link for the class.
*
* @param p Package.
* This method generates a link, which can be used in SVG diagrams to
* create links from classes to Doxygen documentation pages.
*
* @return Doxygen-style HTML link for the class.
*/
void add_package(std::unique_ptr<common::model::package> &&p);
std::optional<std::string> doxygen_link() const override;
private:
bool is_deprecated_{false};

View File

@@ -150,7 +150,7 @@ inline value_t any_of(InputIterator first, InputIterator last, Predicate pred)
if (m.has_value()) {
if (m.value()) {
res = true;
break;
return res;
}
res = false;
}

View File

@@ -194,7 +194,12 @@ struct regex {
{
}
[[nodiscard]] bool operator==(const std::string &v) const
/**
* @brief Regular expression match operator
* @param v Value to match against internal std::regex
* @return True, if the argument matches the regular expression
*/
[[nodiscard]] bool operator%=(const std::string &v) const
{
return std::regex_match(v, regexp);
}

View File

@@ -1,5 +1,5 @@
/**
* src/config/config.cc
* @file src/config/config.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/config/config.h
* @file src/config/config.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/config/diagram_templates.cc
* @file src/config/diagram_templates.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/config/diagram_templates.h
* @file src/config/diagram_templates.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/config/option.h
* @file src/config/option.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/config/yaml_decoders.cc
* @file src/config/yaml_decoders.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/config/yaml_emitters.cc
* @file src/config/yaml_emitters.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/decorators/decorators.cc
* @file src/decorators/decorators.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/decorators/decorators.h
* @file src/decorators/decorators.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

19
src/docs/architecture.cc Normal file
View File

@@ -0,0 +1,19 @@
/**
* @file docs/architecture.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "architecture.h"

73
src/docs/architecture.h Normal file
View File

@@ -0,0 +1,73 @@
/**
* @file docs/architecture.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "class_diagram/model/diagram.h"
#include "common/model/diagram.h"
#include "include_diagram/model/diagram.h"
#include "package_diagram/model/diagram.h"
#include "sequence_diagram/model/diagram.h"
#include "class_diagram/visitor/translation_unit_visitor.h"
#include "common/visitor/translation_unit_visitor.h"
#include "include_diagram/visitor/translation_unit_visitor.h"
#include "package_diagram/visitor/translation_unit_visitor.h"
#include "sequence_diagram/visitor/translation_unit_visitor.h"
#include "class_diagram/generators/json/class_diagram_generator.h"
#include "class_diagram/generators/plantuml/class_diagram_generator.h"
#include "common/generators/generators.h"
/*
* This file serves as an example how high-level documentation can be stored
* directly in the code.
*/
namespace clanguml {
/**
* This namespace provides common interfaces for all kinds of diagrams.
*
* The core diagram functionality is divided into 3 groups: visitor, model
* and generators.
*/
namespace common {
/**
* This namespace provides common interfaces for translation unit visitors,
* which are responsible for traversing the Clang's AST of the source code,
* and generating the intermedia diagram model.
*
* Each 'translation_unit_visitor' implements the Clang's
* 'RecursiveASTVisitor' interface.
*/
namespace visitor {
} // namespace visitor
/**
* This namespace provides common interfaces for diagram model, including
* various diagram elements and diagram filters.
*/
namespace model {
} // namespace model
/**
*
*/
namespace generators {
} // namespace generators
} // namespace common
} // namespace clanguml

View File

@@ -1,5 +1,5 @@
/**
* src/include_diagram/generators/json/include_diagram_generator.cc
* @file src/include_diagram/generators/json/include_diagram_generator.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/include_diagram/generators/json/include_diagram_generator.h
* @file src/include_diagram/generators/json/include_diagram_generator.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/include_diagram/generators/plantuml/include_diagram_generator.cc
* @file src/include_diagram/generators/plantuml/include_diagram_generator.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/include_diagram/generators/plantuml/include_diagram_generator.h
* @file src/include_diagram/generators/plantuml/include_diagram_generator.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/include_diagram/model/diagram.cc
* @file src/include_diagram/model/diagram.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/include_diagram/model/diagram.h
* @file src/include_diagram/model/diagram.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/include_diagram/visitor/translation_unit_visitor.cc
* @file src/include_diagram/visitor/translation_unit_visitor.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/include_diagram/visitor/translation_unit_visitor.h
* @file src/include_diagram/visitor/translation_unit_visitor.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/main.cc
* @file src/main.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/package_diagram/generators/json/package_diagram_generator.cc
* @file src/package_diagram/generators/json/package_diagram_generator.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/package_diagram/generators/json/package_diagram_generator.h
* @file src/package_diagram/generators/json/package_diagram_generator.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/package_diagram/generators/plantuml/package_diagram_generator.cc
* @file src/package_diagram/generators/plantuml/package_diagram_generator.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/package_diagram/generators/plantuml/package_diagram_generator.h
* @file src/package_diagram/generators/plantuml/package_diagram_generator.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/package_diagram/model/diagram.cc
* @file src/package_diagram/model/diagram.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*
@@ -43,8 +43,6 @@ common::optional_ref<clanguml::common::model::diagram_element> diagram::get(
common::optional_ref<clanguml::common::model::diagram_element> diagram::get(
const clanguml::common::model::diagram_element::id_t id) const
{
LOG_DBG("Looking for package with id {}", id);
return find<package>(id);
}

View File

@@ -1,5 +1,5 @@
/**
* src/package_diagram/model/diagram.h
* @file src/package_diagram/model/diagram.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/package_diagram/visitor/translation_unit_visitor.cc
* @file src/package_diagram/visitor/translation_unit_visitor.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*
@@ -53,7 +53,7 @@ bool translation_unit_visitor::VisitNamespaceDecl(clang::NamespaceDecl *ns)
auto qualified_name = common::get_qualified_name(*ns);
if (!diagram().should_include(qualified_name))
if (!diagram().should_include(namespace_{qualified_name}))
return true;
LOG_DBG("Visiting namespace declaration: {}", qualified_name);
@@ -93,6 +93,8 @@ bool translation_unit_visitor::VisitNamespaceDecl(clang::NamespaceDecl *ns)
}
if (!p->skip()) {
LOG_DBG("Adding package {}", p->full_name(false));
diagram().add(p->path(), std::move(p));
}
}
@@ -213,6 +215,9 @@ void translation_unit_visitor::add_relationships(
if (config().package_type() == config::package_type_t::kDirectory) {
auto file = source_manager().getFilename(cls->getLocation()).str();
if (file.empty())
return;
auto relative_file = config().make_path_relative(file);
relative_file.make_preferred();

View File

@@ -1,5 +1,5 @@
/**
* src/package_diagram/visitor/translation_unit_visitor.h
* @file src/package_diagram/visitor/translation_unit_visitor.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/generators/json/sequence_diagram_generator.cc
* @file src/sequence_diagram/generators/json/sequence_diagram_generator.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/generators/json/sequence_diagram_generator.h
* @file src/sequence_diagram/generators/json/sequence_diagram_generator.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc
* @file src/sequence_diagram/generators/plantuml/sequence_diagram_generator.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/generators/plantuml/sequence_diagram_generator.h
* @file src/sequence_diagram/generators/plantuml/sequence_diagram_generator.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/model/activity.cc
* @file src/sequence_diagram/model/activity.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/model/activity.h
* @file src/sequence_diagram/model/activity.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/model/diagram.cc
* @file src/sequence_diagram/model/diagram.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/model/diagram.h
* @file src/sequence_diagram/model/diagram.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/model/message.cc
* @file src/sequence_diagram/model/message.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/model/message.h
* @file src/sequence_diagram/model/message.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/model/participant.cc
* @file src/sequence_diagram/model/participant.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/model/participant.h
* @file src/sequence_diagram/model/participant.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/visitor/call_expression_context.cc
* @file src/sequence_diagram/visitor/call_expression_context.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/visitor/call_expression_context.h
* @file src/sequence_diagram/visitor/call_expression_context.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/visitor/translation_unit_visitor.cc
* @file src/sequence_diagram/visitor/translation_unit_visitor.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/sequence_diagram/visitor/translation_unit_visitor.h
* @file src/sequence_diagram/visitor/translation_unit_visitor.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/util/error.h
* @file src/util/error.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/util/query_driver_include_extractor.cc
* @file src/util/query_driver_include_extractor.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/util/query_driver_include_extractor.h
* @file src/util/query_driver_include_extractor.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/util/thread_pool_executor.cc
* @file src/util/thread_pool_executor.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/util/thread_pool_executor.h
* @file src/util/thread_pool_executor.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/util/util.cc
* @file src/util/util.cc
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -1,5 +1,5 @@
/**
* src/util/util.h
* @file src/util/util.h
*
* Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
*

View File

@@ -30,10 +30,6 @@ TEST_CASE("t00004", "[test-case][class]")
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00004_class");
REQUIRE(!model->should_include("std::vector"));
REQUIRE(model->should_include("clanguml::t00004::A"));
REQUIRE(model->should_include("clanguml::t00004::A::AA"));
REQUIRE(model->should_include("clanguml::t00004::A:::AAA"));
{
auto puml = generate_class_puml(diagram, *model);

View File

@@ -27,10 +27,6 @@ TEST_CASE("t00005", "[test-case][class]")
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00005_class");
REQUIRE(model->should_include("clanguml::t00005::A"));
REQUIRE(model->should_include("clanguml::t00005::B"));
REQUIRE(model->should_include("clanguml::t00005::C"));
REQUIRE(model->should_include("clanguml::t00005::D"));
{
auto puml = generate_class_puml(diagram, *model);

View File

@@ -28,12 +28,6 @@ TEST_CASE("t00006", "[test-case][class]")
REQUIRE(model->name() == "t00006_class");
REQUIRE(model->should_include("clanguml::t00006::A"));
REQUIRE(model->should_include("clanguml::t00006::B"));
REQUIRE(model->should_include("clanguml::t00006::C"));
REQUIRE(model->should_include("clanguml::t00006::D"));
REQUIRE(model->should_include("clanguml::t00006::E"));
{
auto puml = generate_class_puml(diagram, *model);
AliasMatcher _A(puml);

View File

@@ -27,9 +27,6 @@ TEST_CASE("t00013", "[test-case][class]")
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00013_class");
REQUIRE(model->should_include("clanguml::t00013::A"));
REQUIRE(model->should_include("clanguml::t00013::B"));
REQUIRE(model->should_include("ABCD::F"));
{
auto puml = generate_class_puml(diagram, *model);

View File

@@ -27,7 +27,6 @@ TEST_CASE("t00014", "[test-case][class]")
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00014_class");
REQUIRE(model->should_include("clanguml::t00014::B"));
{
auto puml = generate_class_puml(diagram, *model);

View File

@@ -27,7 +27,6 @@ TEST_CASE("t00015", "[test-case][class]")
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00015_class");
REQUIRE(model->should_include("clanguml::t00015::ns1::ns2::A"));
{
auto puml = generate_class_puml(diagram, *model);

View File

@@ -27,7 +27,6 @@ TEST_CASE("t00016", "[test-case][class]")
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00016_class");
REQUIRE(model->should_include("clanguml::t00016::is_numeric"));
{
auto puml = generate_class_puml(diagram, *model);

View File

@@ -27,7 +27,7 @@ TEST_CASE("t00018", "[test-case][class]")
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00018_class");
REQUIRE(model->should_include("clanguml::t00018::widget"));
{
auto puml = generate_class_puml(diagram, *model);
AliasMatcher _A(puml);

View File

@@ -27,7 +27,6 @@ TEST_CASE("t00020", "[test-case][class]")
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00020_class");
REQUIRE(model->should_include("clanguml::t00020::ProductA"));
{
auto puml = generate_class_puml(diagram, *model);

View File

@@ -27,7 +27,6 @@ TEST_CASE("t00021", "[test-case][class]")
auto model = generate_class_diagram(*db, diagram);
REQUIRE(model->name() == "t00021_class");
REQUIRE(model->should_include("clanguml::t00021::Visitor"));
{
auto puml = generate_class_puml(diagram, *model);

Some files were not shown because too many files have changed in this diff Show More