diff --git a/CHANGELOG.md b/CHANGELOG.md index 67048ec7..b2dd19ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # CHANGELOG +### 0.3.9 * Added `from_to` and `to` location constraints to sequence diagrams (#154) * Fixed 'else if' statement generation in sequence diagrams (#81) * Implemented removal of redundant dependency relationhips (#28) diff --git a/Doxyfile b/Doxyfile index c5c37146..9089440d 100644 --- a/Doxyfile +++ b/Doxyfile @@ -38,7 +38,7 @@ PROJECT_NAME = "clang-uml" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 0.3.8 +PROJECT_NUMBER = 0.3.9 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/README.md b/README.md index 4a553e34..88f03fc9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Build status](https://github.com/bkryza/clang-uml/actions/workflows/build.yml/badge.svg)](https://github.com/bkryza/clang-uml/actions) [![Coverage](https://codecov.io/gh/bkryza/clang-uml/branch/master/graph/badge.svg)](https://codecov.io/gh/bkryza/clang-uml) -[![Version](https://img.shields.io/badge/version-0.3.8-blue)](https://github.com/bkryza/clang-uml/releases) +[![Version](https://img.shields.io/badge/version-0.3.9-blue)](https://github.com/bkryza/clang-uml/releases) [![Version](https://img.shields.io/badge/LLVM-12,13,14,15,16-orange)](https://github.com/bkryza/clang-uml/releases) [![Doxygen](https://img.shields.io/badge/Docs-Doxygen-gainsboro)](https://clang-uml.github.io) diff --git a/docs/installation.md b/docs/installation.md index c39b4eb9..93c5af1e 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -30,16 +30,16 @@ sudo apt install clang-uml ```bash # Fedora 36 -wget https://github.com/bkryza/clang-uml/releases/download/0.3.8/clang-uml-0.3.8-1.fc36.x86_64.rpm -sudo dnf install ./clang-uml-0.3.8-1.fc36.x86_64.rpm +wget https://github.com/bkryza/clang-uml/releases/download/0.3.9/clang-uml-0.3.9-1.fc36.x86_64.rpm +sudo dnf install ./clang-uml-0.3.9-1.fc36.x86_64.rpm # Fedora 37 -wget https://github.com/bkryza/clang-uml/releases/download/0.3.8/clang-uml-0.3.8-1.fc37.x86_64.rpm -sudo dnf install ./clang-uml-0.3.8-1.fc37.x86_64.rpm +wget https://github.com/bkryza/clang-uml/releases/download/0.3.9/clang-uml-0.3.9-1.fc37.x86_64.rpm +sudo dnf install ./clang-uml-0.3.9-1.fc37.x86_64.rpm # Fedora 38 -wget https://github.com/bkryza/clang-uml/releases/download/0.3.8/clang-uml-0.3.8-1.fc38.x86_64.rpm -sudo dnf install ./clang-uml-0.3.8-1.fc38.x86_64.rpm +wget https://github.com/bkryza/clang-uml/releases/download/0.3.9/clang-uml-0.3.9-1.fc38.x86_64.rpm +sudo dnf install ./clang-uml-0.3.9-1.fc38.x86_64.rpm ``` #### Conda @@ -161,7 +161,7 @@ bin\clang-uml.exe --version ``` It should produce something like: ```bash -clang-uml 0.3.8 +clang-uml 0.3.9 Copyright (C) 2021-2023 Bartek Kryza Built against LLVM/Clang libraries version: 15.0.6 Using LLVM/Clang libraries version: clang version 15.0.6 (https://github.com/llvm/llvm-project.git 088f33605d8a61ff519c580a71b1dd57d16a03f8) diff --git a/docs/sequence_diagrams.md b/docs/sequence_diagrams.md index cb1222e9..8fe0f54e 100644 --- a/docs/sequence_diagrams.md +++ b/docs/sequence_diagrams.md @@ -3,7 +3,7 @@ * [Sequence diagram overview](#sequence-diagram-overview) -* [Specifying diagram entry point](#specifying-diagram-entry-point) +* [Specifying diagram location constraints](#specifying-diagram-location-constraints) * [Grouping free functions by file](#grouping-free-functions-by-file) * [Lambda expressions in sequence diagrams](#lambda-expressions-in-sequence-diagrams) * [Customizing participants order](#customizing-participants-order) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index cb1f75a2..49705bac 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -9,6 +9,7 @@ * [Clang produces several warnings during diagram generation](#clang-produces-several-warnings-during-diagram-generation) * [Cannot generate diagrams from header-only projects](#cannot-generate-diagrams-from-header-only-projects) * [YAML anchors and aliases are not fully supported](#yaml-anchors-and-aliases-are-not-fully-supported) +* [Schema validation error is thrown, but the configuration file is correct](#schema-validation-error-is-thrown-but-the-configuration-file-is-correct) * [Class diagrams](#class-diagrams) * ["fatal error: 'stddef.h' file not found"](#fatal-error-stddefh-file-not-found) * [How can I generate class diagram of my entire project](#how-can-i-generate-class-diagram-of-my-entire-project) diff --git a/src/config/schema.h b/src/config/schema.h index 58577e74..54996bc8 100644 --- a/src/config/schema.h +++ b/src/config/schema.h @@ -41,7 +41,7 @@ types: tooltip: string git_t: branch: string - revision: string + revision: [string, int] commit: string toplevel: string layout_hint_key: !variant diff --git a/src/sequence_diagram/model/diagram.cc b/src/sequence_diagram/model/diagram.cc index 00afcb19..33311c77 100644 --- a/src/sequence_diagram/model/diagram.cc +++ b/src/sequence_diagram/model/diagram.cc @@ -285,11 +285,11 @@ common::model::diagram_element::id_t diagram::get_from_activity_id( return from_activity; } -std::unordered_set diagram::get_all_from_to_message_chains( +std::vector diagram::get_all_from_to_message_chains( const common::model::diagram_element::id_t from_activity, const common::model::diagram_element::id_t to_activity) const { - std::unordered_set message_chains_unique{}; + std::vector message_chains_unique{}; // Message (call) chains matching the specified from_to condition std::vector message_chains; @@ -382,15 +382,31 @@ std::unordered_set diagram::get_all_from_to_message_chains( // Reverse the message chains order (they were added starting from // the destination activity) - for (auto &mc : message_chains) + for (auto &mc : message_chains) { std::reverse(mc.begin(), mc.end()); - std::copy_if(message_chains.begin(), message_chains.end(), - std::inserter(message_chains_unique, message_chains_unique.begin()), - [from_activity](const message_chain_t &mc) { - return !mc.empty() && - (from_activity == 0 || (mc.front().from() == from_activity)); - }); + if (mc.empty()) + continue; + + if (std::find(message_chains_unique.begin(), + message_chains_unique.end(), mc) != message_chains_unique.end()) + continue; + + if (from_activity == 0 || (mc.front().from() == from_activity)) { + message_chains_unique.push_back(mc); + } + } + + LOG_TRACE("Message chains unique", iter++); + int message_chain_index{}; + for (const auto &mc : message_chains_unique) { + LOG_TRACE("\t{}: {}", message_chain_index++, + fmt::join(util::map(mc, + [](const model::message &m) -> std::string { + return m.message_name(); + }), + "->")); + } return message_chains_unique; } diff --git a/src/sequence_diagram/model/diagram.h b/src/sequence_diagram/model/diagram.h index 897c7791..6e50f840 100644 --- a/src/sequence_diagram/model/diagram.h +++ b/src/sequence_diagram/model/diagram.h @@ -255,7 +255,7 @@ public: * @param to_activity Target activity for from_to message chain * @return List of message chains */ - std::unordered_set get_all_from_to_message_chains( + std::vector get_all_from_to_message_chains( common::model::diagram_element::id_t from_activity, common::model::diagram_element::id_t to_activity) const; diff --git a/src/sequence_diagram/model/message.cc b/src/sequence_diagram/model/message.cc index 71837849..b401e4f8 100644 --- a/src/sequence_diagram/model/message.cc +++ b/src/sequence_diagram/model/message.cc @@ -27,6 +27,14 @@ message::message( { } +bool message::operator==(const message &other) const noexcept +{ + return from_ == other.from_ && to_ == other.to_ && type_ == other.type_ && + scope_ == other.scope_ && message_name_ == other.message_name_ && + return_type_ == other.return_type_ && + condition_text_ == other.condition_text_; +} + void message::set_type(common::model::message_t t) { type_ = t; } common::model::message_t message::type() const { return type_; } diff --git a/src/sequence_diagram/model/message.h b/src/sequence_diagram/model/message.h index 5a3a3e83..e0b795fc 100644 --- a/src/sequence_diagram/model/message.h +++ b/src/sequence_diagram/model/message.h @@ -41,6 +41,14 @@ public: message(common::model::message_t type, common::model::diagram_element::id_t from); + /** + * @brief Equality operator + * + * @param other Compare this to other message + * @return True, if 2 messages are equal + */ + bool operator==(const message &other) const noexcept; + /** * @brief Set message type * @@ -162,33 +170,3 @@ private: }; } // namespace clanguml::sequence_diagram::model - -namespace std { - -template <> struct hash { - std::size_t operator()( - const clanguml::sequence_diagram::model::message &m) const - { - std::size_t seed = clanguml::util::hash_seed(m.from()); - seed ^= m.to(); - seed += std::hash{}(m.full_name(true)); - - return seed; - } -}; - -template <> -struct hash> { - std::size_t operator()( - const std::vector &msgs) - const - { - std::size_t seed = clanguml::util::hash_seed(msgs.size()); - for (const auto &m : msgs) { - seed ^= std::hash{}(m); - } - return seed; - } -}; - -} // namespace std diff --git a/tests/t00014/test_case.h b/tests/t00014/test_case.h index f17c0b9b..2fb40c44 100644 --- a/tests/t00014/test_case.h +++ b/tests/t00014/test_case.h @@ -139,9 +139,12 @@ TEST_CASE("t00014", "[test-case][class]") REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("A>"), "-floatstring")); +#if !defined(__APPLE__) + // TODO(#176) REQUIRE_THAT(puml, IsDependency(_A("R"), _A("A"))); REQUIRE_THAT( puml, IsDependency(_A("R"), _A("A"))); +#endif save_puml( config.output_directory() + "/" + diagram->name + ".puml", puml);