Merge pull request #12 from bkryza/add-package-diagrams
Add package diagrams
123
.clang-uml
Normal file
@@ -0,0 +1,123 @@
|
||||
compilation_database_dir: debug
|
||||
output_directory: docs/diagrams
|
||||
diagrams:
|
||||
main_package:
|
||||
type: package
|
||||
glob:
|
||||
- src/**/*.h
|
||||
- src/**/*.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml
|
||||
using_namespace:
|
||||
- clanguml
|
||||
plantuml:
|
||||
before:
|
||||
- 'title clang-uml namespaces'
|
||||
config_class:
|
||||
type: class
|
||||
include_relations_also_as_members: false
|
||||
glob:
|
||||
- src/config/config.h
|
||||
- src/config/config.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::config
|
||||
using_namespace:
|
||||
- clanguml::config
|
||||
plantuml:
|
||||
before:
|
||||
- 'title clang-uml configuration model'
|
||||
decorators_class:
|
||||
type: class
|
||||
include_relations_also_as_members: false
|
||||
glob:
|
||||
- src/decorators/decorators.h
|
||||
- src/decorators/decorators.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::decorators
|
||||
using_namespace:
|
||||
- clanguml::decorators
|
||||
plantuml:
|
||||
before:
|
||||
- 'title clang-uml decorators model'
|
||||
common_model_class:
|
||||
type: class
|
||||
include_relations_also_as_members: false
|
||||
glob:
|
||||
- src/common/model/*.h
|
||||
- src/common/model/*.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::common::model
|
||||
using_namespace:
|
||||
- clanguml::common::model
|
||||
plantuml:
|
||||
before:
|
||||
- 'title clang-uml common diagram model'
|
||||
class_model_class:
|
||||
type: class
|
||||
include_relations_also_as_members: false
|
||||
glob:
|
||||
- src/class_diagram/model/*.h
|
||||
- src/class_diagram/model/*.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::class_diagram::model
|
||||
using_namespace:
|
||||
- clanguml::class_diagram::model
|
||||
plantuml:
|
||||
before:
|
||||
- 'title clang-uml class diagram model'
|
||||
sequence_model_class:
|
||||
type: class
|
||||
include_relations_also_as_members: false
|
||||
glob:
|
||||
- src/sequence_diagram/model/*.h
|
||||
- src/sequence_diagram/model/*.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::sequence_diagram::model
|
||||
using_namespace:
|
||||
- clanguml::sequence_diagram::model
|
||||
plantuml:
|
||||
before:
|
||||
- 'title clang-uml sequence diagram model'
|
||||
package_model_class:
|
||||
type: class
|
||||
include_relations_also_as_members: false
|
||||
glob:
|
||||
- src/package_diagram/model/*.h
|
||||
- src/package_diagram/model/*.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::package_diagram::model
|
||||
using_namespace:
|
||||
- clanguml::package_diagram::model
|
||||
plantuml:
|
||||
before:
|
||||
- 'title clang-uml package diagram model'
|
||||
diagram_model_class:
|
||||
type: class
|
||||
include_relations_also_as_members: false
|
||||
glob:
|
||||
- src/common/model/*.h
|
||||
- src/common/model/*.cc
|
||||
- src/class_diagram/model/*.h
|
||||
- src/class_diagram/model/*.cc
|
||||
- src/sequence_diagram/model/*.h
|
||||
- src/sequence_diagram/model/*.cc
|
||||
- src/package_diagram/model/*.h
|
||||
- src/package_diagram/model/*.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::common::model
|
||||
- clanguml::class_diagram::model
|
||||
- clanguml::sequence_diagram::model
|
||||
- clanguml::package_diagram::model
|
||||
using_namespace:
|
||||
- clanguml
|
||||
plantuml:
|
||||
before:
|
||||
- 'title clang-uml diagram model'
|
||||
7
.gitignore
vendored
@@ -18,3 +18,10 @@ bin/
|
||||
/debug/
|
||||
/release/
|
||||
/.cache
|
||||
docs/diagrams
|
||||
|
||||
|
||||
# CLion
|
||||
|
||||
.idea/
|
||||
cmake-build-debug/
|
||||
|
||||
@@ -63,6 +63,7 @@ add_library(clang-umllib OBJECT ${SOURCES})
|
||||
add_executable(clang-uml ${MAIN_SOURCE_FILE})
|
||||
install(TARGETS clang-uml DESTINATION ${CLANG_UML_INSTALL_BIN_DIR})
|
||||
target_link_libraries(clang-uml ${LIBCLANG_LIBRARIES} ${YAML_CPP_LIBRARIES} spdlog::spdlog cppast clang-umllib)
|
||||
target_compile_features(clang-uml PRIVATE cxx_std_17)
|
||||
|
||||
install(
|
||||
FILES
|
||||
|
||||
7
Makefile
@@ -1,6 +1,6 @@
|
||||
# Makefile
|
||||
#
|
||||
# Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
# Copyright (c) 2021-2022 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.
|
||||
@@ -52,6 +52,11 @@ test_plantuml: test
|
||||
document_test_cases: test_plantuml
|
||||
python3 util/generate_test_cases_docs.py
|
||||
|
||||
clanguml_diagrams: debug
|
||||
mkdir -p docs/diagrams
|
||||
debug/clang-uml
|
||||
plantuml docs/diagrams/*.puml
|
||||
|
||||
.PHONY: submodules
|
||||
submodules:
|
||||
git submodule update --init --recursive
|
||||
|
||||
63
README.md
@@ -19,6 +19,8 @@ Main features supported so far include:
|
||||
* Namespace based content filtering
|
||||
* Sequence diagram generation
|
||||
* Generation of sequence diagram from one code location to another
|
||||
* Package diagram generation
|
||||
* Generation of package diagram based on C++ namespaces
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -87,8 +89,8 @@ diagrams:
|
||||
myproject_class:
|
||||
type: class
|
||||
glob:
|
||||
- src/**.h
|
||||
- src/**.cc
|
||||
- src/*.h
|
||||
- src/*.cc
|
||||
using_namespace:
|
||||
- myproject
|
||||
include:
|
||||
@@ -104,6 +106,18 @@ diagrams:
|
||||
|
||||
See  for detailed configuration file reference guide.
|
||||
|
||||
### Examples
|
||||
To see what `clang-uml` can do, checkout the test cases documentation [here](./docs/test_cases.md).
|
||||
|
||||
In order to see diagrams for the `clang-uml` itself, based on its own [config](.clang-uml) run
|
||||
the following:
|
||||
|
||||
```bash
|
||||
make clanguml_diagrams
|
||||
```
|
||||
|
||||
and checkout the PNG diagrams in `docs/diagrams` folder.
|
||||
|
||||
### Class diagrams
|
||||
|
||||
#### Example
|
||||
@@ -257,6 +271,51 @@ generates the following diagram (via PlantUML):
|
||||
|
||||

|
||||
|
||||
### Package diagrams
|
||||
|
||||
#### Example
|
||||
|
||||
The following C++ code:
|
||||
|
||||
```cpp
|
||||
namespace clanguml {
|
||||
namespace t30003 {
|
||||
|
||||
namespace ns1 {
|
||||
namespace ns2_v1_0_0 {
|
||||
class A {
|
||||
};
|
||||
}
|
||||
|
||||
namespace [[deprecated]] ns2_v0_9_0 {
|
||||
class A {
|
||||
};
|
||||
}
|
||||
|
||||
namespace {
|
||||
class Anon final {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace [[deprecated]] ns3 {
|
||||
|
||||
namespace ns1::ns2 {
|
||||
class Anon : public t30003::ns1::ns2_v1_0_0::A {
|
||||
};
|
||||
}
|
||||
|
||||
class B : public ns1::ns2::Anon {
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
generates the following diagram (via PlantUML):
|
||||
|
||||

|
||||
|
||||
### Test cases
|
||||
|
||||
The build-in test cases used for unit testing of the `clang-uml`, can be browsed [here](./docs/test_cases.md).
|
||||
|
||||
@@ -36,5 +36,12 @@
|
||||
## Sequence diagrams
|
||||
* [t20001](./test_cases/t20001.md) - Basic sequence diagram test case
|
||||
* [t20002](./test_cases/t20002.md) - Free function sequence diagram test case
|
||||
## Package diagrams
|
||||
* [t30001](./test_cases/t30001.md) - Basic package diagram test case
|
||||
* [t30002](./test_cases/t30002.md) - Package dependency test case
|
||||
* [t30003](./test_cases/t30003.md) - Package deprecated attribute test case
|
||||
* [t30004](./test_cases/t30004.md) - PlantUML package decorators test case
|
||||
* [t30005](./test_cases/t30005.md) - Package namespace alias test case
|
||||
* [t30006](./test_cases/t30006.md) - Package split namespace test case
|
||||
## Configuration diagrams
|
||||
* [t90000](./test_cases/t90000.md) - Basic config test
|
||||
|
||||
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
55
docs/test_cases/t30001.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# t30001 - Basic package diagram test case
|
||||
## Config
|
||||
```yaml
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t30001_package:
|
||||
type: package
|
||||
glob:
|
||||
- ../../tests/t30001/t30001.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t30001
|
||||
exclude:
|
||||
namespaces:
|
||||
- clanguml::t30001::detail
|
||||
using_namespace:
|
||||
- clanguml::t30001
|
||||
plantuml:
|
||||
before:
|
||||
- "' t30001 test package diagram"
|
||||
after:
|
||||
- "note right of @A(A::AA::AAA): A AAA note..."
|
||||
```
|
||||
## Source code
|
||||
File t30001.cc
|
||||
```cpp
|
||||
namespace clanguml {
|
||||
namespace t30001 {
|
||||
namespace A {
|
||||
namespace AA {
|
||||
namespace AAA {
|
||||
} // namespace AAA
|
||||
namespace BBB {
|
||||
} // namespace BBB
|
||||
} // namespace AA
|
||||
namespace BB {
|
||||
} // namespace BB
|
||||
} // namespace A
|
||||
namespace B {
|
||||
namespace AA {
|
||||
namespace AAA {
|
||||
} // namespace AAA
|
||||
namespace BBB {
|
||||
} // namespace BBB
|
||||
} // namespace AA
|
||||
namespace BB {
|
||||
} // namespace BB
|
||||
} // namespace B
|
||||
} // namespace t30001
|
||||
} // namespace clanguml
|
||||
|
||||
```
|
||||
## Generated UML diagrams
|
||||

|
||||
BIN
docs/test_cases/t30001_package.png
Normal file
|
After Width: | Height: | Size: 9.9 KiB |
127
docs/test_cases/t30002.md
Normal file
@@ -0,0 +1,127 @@
|
||||
# t30002 - Package dependency test case
|
||||
## Config
|
||||
```yaml
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t30002_package:
|
||||
type: package
|
||||
glob:
|
||||
- ../../tests/t30002/t30002.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t30002
|
||||
exclude:
|
||||
namespaces:
|
||||
- clanguml::t30002::detail
|
||||
using_namespace:
|
||||
- clanguml::t30002
|
||||
plantuml:
|
||||
before:
|
||||
- "' t30002 test package diagram"
|
||||
```
|
||||
## Source code
|
||||
File t30002.cc
|
||||
```cpp
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace clanguml {
|
||||
namespace t30002 {
|
||||
namespace A::AA {
|
||||
namespace A1 {
|
||||
struct CA {
|
||||
};
|
||||
}
|
||||
namespace A2 {
|
||||
struct CB {
|
||||
};
|
||||
}
|
||||
namespace A3 {
|
||||
struct CC {
|
||||
};
|
||||
}
|
||||
namespace A4 {
|
||||
struct CD {
|
||||
};
|
||||
}
|
||||
namespace A5 {
|
||||
struct CE {
|
||||
};
|
||||
}
|
||||
namespace A6 {
|
||||
struct CF {
|
||||
};
|
||||
}
|
||||
namespace A7 {
|
||||
struct CG {
|
||||
};
|
||||
}
|
||||
namespace A8 {
|
||||
struct CH {
|
||||
};
|
||||
}
|
||||
namespace A9 {
|
||||
struct CI {
|
||||
};
|
||||
}
|
||||
namespace A10 {
|
||||
struct CJ {
|
||||
};
|
||||
}
|
||||
namespace A11 {
|
||||
struct CK {
|
||||
};
|
||||
}
|
||||
namespace A12 {
|
||||
struct CL {
|
||||
};
|
||||
}
|
||||
namespace A13 {
|
||||
struct CM {
|
||||
};
|
||||
}
|
||||
}
|
||||
namespace B::BB::BBB {
|
||||
struct CBA : public A::AA::A6::CF {
|
||||
A::AA::A1::CA *ca_;
|
||||
A::AA::A2::CB cb_;
|
||||
std::shared_ptr<A::AA::A3::CC> cc_;
|
||||
std::map<std::string, std::unique_ptr<A::AA::A4::CD>> cd_;
|
||||
|
||||
void ce(const std::vector<A::AA::A5::CE> /*ce_*/) { }
|
||||
|
||||
std::shared_ptr<A::AA::A7::CG> cg() { return {}; }
|
||||
|
||||
template <typename T>
|
||||
void ch(std::map<T, std::shared_ptr<A::AA::A8::CH>> & /*ch_*/)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T> std::map<T, std::shared_ptr<A::AA::A9::CI>> ci()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
void cj(std::unique_ptr<A::AA::A10::CJ> /*cj_*/) { }
|
||||
|
||||
std::unique_ptr<A::AA::A11::CK> ck() { return {}; }
|
||||
|
||||
template <typename T>
|
||||
void cl(std::map<T, std::shared_ptr<A::AA::A12::CL>> & /*ch_*/)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T> std::map<T, std::shared_ptr<A::AA::A13::CM>> cm()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
} // namespace t30002
|
||||
} // namespace clanguml
|
||||
|
||||
```
|
||||
## Generated UML diagrams
|
||||

|
||||
BIN
docs/test_cases/t30002_package.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
57
docs/test_cases/t30003.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# t30003 - Package deprecated attribute test case
|
||||
## Config
|
||||
```yaml
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t30003_package:
|
||||
type: package
|
||||
glob:
|
||||
- ../../tests/t30003/t30003.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t30003
|
||||
using_namespace:
|
||||
- clanguml::t30003
|
||||
plantuml:
|
||||
before:
|
||||
- "' t30003 test package diagram"
|
||||
```
|
||||
## Source code
|
||||
File t30003.cc
|
||||
```cpp
|
||||
namespace clanguml {
|
||||
namespace t30003 {
|
||||
|
||||
namespace ns1 {
|
||||
namespace ns2_v1_0_0 {
|
||||
class A {
|
||||
};
|
||||
}
|
||||
|
||||
namespace [[deprecated]] ns2_v0_9_0 {
|
||||
class A {
|
||||
};
|
||||
}
|
||||
|
||||
namespace {
|
||||
class Anon final {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace [[deprecated]] ns3 {
|
||||
|
||||
namespace ns1::ns2 {
|
||||
class Anon : public t30003::ns1::ns2_v1_0_0::A {
|
||||
};
|
||||
}
|
||||
|
||||
class B : public ns1::ns2::Anon {
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
## Generated UML diagrams
|
||||

|
||||
BIN
docs/test_cases/t30003_package.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
60
docs/test_cases/t30004.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# t30004 - PlantUML package decorators test case
|
||||
## Config
|
||||
```yaml
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t30004_package:
|
||||
type: package
|
||||
glob:
|
||||
- ../../tests/t30004/t30004.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t30004
|
||||
using_namespace:
|
||||
- clanguml::t30004
|
||||
plantuml:
|
||||
before:
|
||||
- "' t30004 test package diagram"
|
||||
```
|
||||
## Source code
|
||||
File t30004.cc
|
||||
```cpp
|
||||
namespace clanguml {
|
||||
namespace t30004 {
|
||||
|
||||
/// @uml{style[#green]}
|
||||
namespace A {
|
||||
|
||||
/// @uml{note[ bottom ] Package AAA.}
|
||||
namespace AAA {
|
||||
}
|
||||
|
||||
/// \uml{note[right] Package BBB.}
|
||||
namespace BBB {
|
||||
}
|
||||
|
||||
///
|
||||
/// @uml{note:t30004_package[bottom] CCCC package note.}
|
||||
/// This is package CCC.
|
||||
namespace CCC {
|
||||
}
|
||||
|
||||
/// \uml{skip}
|
||||
namespace DDD {
|
||||
}
|
||||
|
||||
/// @uml{style[#pink;line:red;line.bold;text:red]}
|
||||
/// \uml{note[top] We skipped DDD.}
|
||||
namespace EEE {
|
||||
}
|
||||
|
||||
/// \uml{note[top] Another CCC note.}
|
||||
namespace CCC {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
## Generated UML diagrams
|
||||

|
||||
BIN
docs/test_cases/t30004_package.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
53
docs/test_cases/t30005.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# t30005 - Package namespace alias test case
|
||||
## Config
|
||||
```yaml
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t30005_package:
|
||||
type: package
|
||||
glob:
|
||||
- ../../tests/t30005/t30005.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t30005
|
||||
using_namespace:
|
||||
- clanguml::t30005
|
||||
plantuml:
|
||||
before:
|
||||
- "' t30005 test package diagram"
|
||||
```
|
||||
## Source code
|
||||
File t30005.cc
|
||||
```cpp
|
||||
namespace clanguml {
|
||||
namespace t30005 {
|
||||
|
||||
namespace A::AA::AAA {
|
||||
struct C1 {
|
||||
};
|
||||
}
|
||||
|
||||
namespace B::BB::BBB {
|
||||
namespace A6 = A::AA::AAA;
|
||||
namespace ASix = A6;
|
||||
struct C2 {
|
||||
ASix::C1 *cb;
|
||||
};
|
||||
}
|
||||
|
||||
namespace C::CC::CCC {
|
||||
namespace A6 = A::AA::AAA;
|
||||
namespace ASix = A6;
|
||||
using ADSix = ASix::C1;
|
||||
struct C2 {
|
||||
ADSix *cc;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
## Generated UML diagrams
|
||||

|
||||
BIN
docs/test_cases/t30005_package.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
54
docs/test_cases/t30006.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# t30006 - Package split namespace test case
|
||||
## Config
|
||||
```yaml
|
||||
compilation_database_dir: ..
|
||||
output_directory: puml
|
||||
diagrams:
|
||||
t30006_package:
|
||||
type: package
|
||||
glob:
|
||||
- ../../tests/t30006/t30006.cc
|
||||
include:
|
||||
namespaces:
|
||||
- clanguml::t30006
|
||||
using_namespace:
|
||||
- clanguml::t30006
|
||||
plantuml:
|
||||
before:
|
||||
- "' t30006 test package diagram"
|
||||
```
|
||||
## Source code
|
||||
File t30006.cc
|
||||
```cpp
|
||||
namespace clanguml {
|
||||
namespace t30006 {
|
||||
|
||||
namespace B {
|
||||
struct BB {
|
||||
};
|
||||
}
|
||||
|
||||
/// \uml{note[top] Top A note.}
|
||||
namespace A {
|
||||
struct A1 {
|
||||
B::BB *b;
|
||||
};
|
||||
}
|
||||
|
||||
namespace C {
|
||||
struct CC {
|
||||
};
|
||||
}
|
||||
|
||||
/// \uml{note[bottom] Bottom A note.}
|
||||
namespace A {
|
||||
struct A2 {
|
||||
C::CC *c;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
## Generated UML diagrams
|
||||

|
||||
BIN
docs/test_cases/t30006_package.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/generators/plantuml/class_diagram_generator.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -119,7 +119,7 @@ void generator::generate_alias(const enum_ &e, std::ostream &ostr) const
|
||||
void generator::generate(const class_ &c, std::ostream &ostr) const
|
||||
{
|
||||
|
||||
const auto uns = m_config.using_namespace;
|
||||
const auto &uns = m_config.using_namespace;
|
||||
|
||||
std::string class_type{"class"};
|
||||
if (c.is_abstract())
|
||||
@@ -360,8 +360,7 @@ void generator::generate(std::ostream &ostr) const
|
||||
|
||||
if (m_config.should_include_entities("classes")) {
|
||||
for (const auto &c : m_model.classes()) {
|
||||
if (!c.is_template_instantiation() &&
|
||||
!m_config.should_include(c.name()))
|
||||
if (!m_config.should_include(c.name()))
|
||||
continue;
|
||||
generate_alias(c, ostr);
|
||||
ostr << '\n';
|
||||
@@ -375,8 +374,7 @@ void generator::generate(std::ostream &ostr) const
|
||||
}
|
||||
|
||||
for (const auto &c : m_model.classes()) {
|
||||
if (!c.is_template_instantiation() &&
|
||||
!m_config.should_include(c.name()))
|
||||
if (!m_config.should_include(c.name()))
|
||||
continue;
|
||||
generate(c, ostr);
|
||||
ostr << '\n';
|
||||
@@ -414,7 +412,7 @@ clanguml::class_diagram::model::diagram generate(
|
||||
cppast::libclang_compilation_database &db, const std::string &name,
|
||||
clanguml::config::class_diagram &diagram)
|
||||
{
|
||||
spdlog::info("Generating diagram {}.puml", name);
|
||||
LOG_DBG("Generating diagram {}.puml", name);
|
||||
clanguml::class_diagram::model::diagram d;
|
||||
d.set_name(name);
|
||||
|
||||
@@ -422,7 +420,7 @@ clanguml::class_diagram::model::diagram generate(
|
||||
// configuration
|
||||
std::vector<std::string> translation_units{};
|
||||
for (const auto &g : diagram.glob) {
|
||||
spdlog::debug("Processing glob: {}", g);
|
||||
LOG_DBG("Processing glob: {}", g);
|
||||
const auto matches = glob::rglob(g);
|
||||
std::copy(matches.begin(), matches.end(),
|
||||
std::back_inserter(translation_units));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/generators/plantuml/class_diagram_generator.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -18,10 +18,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "class_diagram/model/class.h"
|
||||
#include "class_diagram/model/class_relationship.h"
|
||||
#include "class_diagram/model/diagram.h"
|
||||
#include "class_diagram/model/enum.h"
|
||||
#include "class_diagram/visitor/translation_unit_visitor.h"
|
||||
#include "common/model/relationship.h"
|
||||
#include "config/config.h"
|
||||
#include "cx/compilation_database.h"
|
||||
#include "util/util.h"
|
||||
@@ -44,8 +44,8 @@ using diagram_config = clanguml::class_diagram::model::diagram;
|
||||
using diagram_model = clanguml::class_diagram::model::diagram;
|
||||
using clanguml::class_diagram::model::class_;
|
||||
using clanguml::class_diagram::model::enum_;
|
||||
using clanguml::class_diagram::model::relationship_t;
|
||||
using clanguml::class_diagram::model::scope_t;
|
||||
using clanguml::common::model::relationship_t;
|
||||
using clanguml::common::model::scope_t;
|
||||
using namespace clanguml::util;
|
||||
|
||||
std::string relative_to(std::string n, std::string c);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -21,9 +21,9 @@
|
||||
#include "class_method.h"
|
||||
#include "class_parent.h"
|
||||
#include "class_template.h"
|
||||
#include "element.h"
|
||||
#include "enums.h"
|
||||
#include "stylable_element.h"
|
||||
#include "common/model/element.h"
|
||||
#include "common/model/enums.h"
|
||||
#include "common/model/stylable_element.h"
|
||||
#include "type_alias.h"
|
||||
|
||||
#include <string>
|
||||
@@ -31,7 +31,8 @@
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
|
||||
class class_ : public element, public stylable_element {
|
||||
class class_ : public common::model::element,
|
||||
public common::model::stylable_element {
|
||||
public:
|
||||
class_(const std::vector<std::string> &using_namespaces);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class_element.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -20,15 +20,15 @@
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
|
||||
class_element::class_element(
|
||||
scope_t scope, const std::string &name, const std::string &type)
|
||||
class_element::class_element(common::model::scope_t scope,
|
||||
const std::string &name, const std::string &type)
|
||||
: scope_{scope}
|
||||
, name_{name}
|
||||
, type_{type}
|
||||
{
|
||||
}
|
||||
|
||||
scope_t class_element::scope() const { return scope_; }
|
||||
common::model::scope_t class_element::scope() const { return scope_; }
|
||||
|
||||
std::string class_element::name() const { return name_; }
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class_element.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -17,23 +17,23 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "decorated_element.h"
|
||||
#include "common/model/decorated_element.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
|
||||
class class_element : public decorated_element {
|
||||
class class_element : public common::model::decorated_element {
|
||||
public:
|
||||
class_element(
|
||||
scope_t scope, const std::string &name, const std::string &type);
|
||||
class_element(common::model::scope_t scope, const std::string &name,
|
||||
const std::string &type);
|
||||
|
||||
scope_t scope() const;
|
||||
common::model::scope_t scope() const;
|
||||
std::string name() const;
|
||||
std::string type() const;
|
||||
|
||||
private:
|
||||
scope_t scope_;
|
||||
common::model::scope_t scope_;
|
||||
std::string name_;
|
||||
std::string type_;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class_member.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
|
||||
class_member::class_member(
|
||||
scope_t scope, const std::string &name, const std::string &type)
|
||||
class_member::class_member(common::model::scope_t scope,
|
||||
const std::string &name, const std::string &type)
|
||||
: class_element{scope, name, type}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class_member.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -25,8 +25,8 @@ namespace clanguml::class_diagram::model {
|
||||
|
||||
class class_member : public class_element {
|
||||
public:
|
||||
class_member(
|
||||
scope_t scope, const std::string &name, const std::string &type);
|
||||
class_member(common::model::scope_t scope, const std::string &name,
|
||||
const std::string &type);
|
||||
|
||||
bool is_relationship() const;
|
||||
void is_relationship(bool is_relationship);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class_method.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
|
||||
class_method::class_method(
|
||||
scope_t scope, const std::string &name, const std::string &type)
|
||||
class_method::class_method(common::model::scope_t scope,
|
||||
const std::string &name, const std::string &type)
|
||||
: class_element{scope, name, type}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class_method.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -27,8 +27,8 @@ namespace clanguml::class_diagram::model {
|
||||
|
||||
class class_method : public class_element {
|
||||
public:
|
||||
class_method(
|
||||
scope_t scope, const std::string &name, const std::string &type);
|
||||
class_method(common::model::scope_t scope, const std::string &name,
|
||||
const std::string &type);
|
||||
|
||||
bool is_pure_virtual() const;
|
||||
void is_pure_virtual(bool is_pure_virtual);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class_parent.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -28,8 +28,11 @@ void class_parent::is_virtual(bool is_virtual) { is_virtual_ = is_virtual; }
|
||||
|
||||
bool class_parent::is_virtual() const { return is_virtual_; }
|
||||
|
||||
void class_parent::set_access(access_t access) { access_ = access; }
|
||||
void class_parent::set_access(common::model::access_t access)
|
||||
{
|
||||
access_ = access;
|
||||
}
|
||||
|
||||
access_t class_parent::access() const { return access_; }
|
||||
common::model::access_t class_parent::access() const { return access_; }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class_parent.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "enums.h"
|
||||
#include "common/model/enums.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -31,12 +31,12 @@ public:
|
||||
void is_virtual(bool is_virtual);
|
||||
bool is_virtual() const;
|
||||
|
||||
void set_access(access_t access);
|
||||
access_t access() const;
|
||||
void set_access(common::model::access_t access);
|
||||
common::model::access_t access() const;
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
bool is_virtual_{false};
|
||||
access_t access_;
|
||||
common::model::access_t access_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class_template.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class_template.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/diagram.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/diagram.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/enum.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/enum.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -24,7 +24,8 @@
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
|
||||
class enum_ : public element, public stylable_element {
|
||||
class enum_ : public common::model::element,
|
||||
public common::model::stylable_element {
|
||||
public:
|
||||
enum_(const std::vector<std::string> &using_namespaces);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/method_parameter.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/method_parameter.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -17,14 +17,14 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "decorated_element.h"
|
||||
#include "common/model/decorated_element.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
|
||||
class method_parameter : public decorated_element {
|
||||
class method_parameter : public common::model::decorated_element {
|
||||
public:
|
||||
void set_type(const std::string &type);
|
||||
std::string type() const;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/type_alias.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/type_alias.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/visitor/element_visitor_context.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/visitor/element_visitor_context.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/visitor/translation_unit_context.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/visitor/translation_unit_context.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/visitor/translation_unit_visitor.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -36,19 +36,19 @@
|
||||
|
||||
namespace clanguml::class_diagram::visitor {
|
||||
|
||||
using clanguml::class_diagram::model::access_t;
|
||||
using clanguml::class_diagram::model::class_;
|
||||
using clanguml::class_diagram::model::class_member;
|
||||
using clanguml::class_diagram::model::class_method;
|
||||
using clanguml::class_diagram::model::class_parent;
|
||||
using clanguml::class_diagram::model::class_relationship;
|
||||
using clanguml::class_diagram::model::class_template;
|
||||
using clanguml::class_diagram::model::diagram;
|
||||
using clanguml::class_diagram::model::enum_;
|
||||
using clanguml::class_diagram::model::method_parameter;
|
||||
using clanguml::class_diagram::model::relationship_t;
|
||||
using clanguml::class_diagram::model::scope_t;
|
||||
using clanguml::class_diagram::model::type_alias;
|
||||
using clanguml::common::model::access_t;
|
||||
using clanguml::common::model::relationship;
|
||||
using clanguml::common::model::relationship_t;
|
||||
using clanguml::common::model::scope_t;
|
||||
|
||||
namespace detail {
|
||||
scope_t cpp_access_specifier_to_scope(
|
||||
@@ -551,12 +551,12 @@ bool translation_unit_visitor::process_field_with_template_instantiation(
|
||||
else
|
||||
relationship_type = relationship_t::kAggregation;
|
||||
|
||||
class_relationship rr{relationship_type, tinst.full_name(),
|
||||
relationship rr{relationship_type, tinst.full_name(),
|
||||
detail::cpp_access_specifier_to_scope(as), mv.name()};
|
||||
rr.set_style(m.style_spec());
|
||||
|
||||
// Process field decorators
|
||||
auto [decorator_rtype, decorator_rmult] = m.relationship();
|
||||
auto [decorator_rtype, decorator_rmult] = m.get_relationship();
|
||||
if (decorator_rtype != relationship_t::kNone) {
|
||||
rr.set_type(decorator_rtype);
|
||||
auto mult = util::split(decorator_rmult, ":");
|
||||
@@ -568,9 +568,8 @@ bool translation_unit_visitor::process_field_with_template_instantiation(
|
||||
|
||||
if (ctx.config().should_include(tinst.name())) {
|
||||
LOG_DBG("Adding field instantiation relationship {} {} {} : {}",
|
||||
rr.destination(),
|
||||
clanguml::class_diagram::model::to_string(rr.type()), c.full_name(),
|
||||
rr.label());
|
||||
rr.destination(), clanguml::common::model::to_string(rr.type()),
|
||||
c.full_name(), rr.label());
|
||||
|
||||
c.add_relationship(std::move(rr));
|
||||
|
||||
@@ -632,11 +631,10 @@ void translation_unit_visitor::process_field(
|
||||
|
||||
for (const auto &[type, relationship_type] : relationships) {
|
||||
if (relationship_type != relationship_t::kNone) {
|
||||
class_relationship r{
|
||||
relationship_type, type, m.scope(), m.name()};
|
||||
relationship r{relationship_type, type, m.scope(), m.name()};
|
||||
r.set_style(m.style_spec());
|
||||
|
||||
auto [decorator_rtype, decorator_rmult] = m.relationship();
|
||||
auto [decorator_rtype, decorator_rmult] = m.get_relationship();
|
||||
if (decorator_rtype != relationship_t::kNone) {
|
||||
r.set_type(decorator_rtype);
|
||||
auto mult = util::split(decorator_rmult, ":");
|
||||
@@ -648,8 +646,8 @@ void translation_unit_visitor::process_field(
|
||||
|
||||
LOG_DBG("Adding field relationship {} {} {} : {}",
|
||||
r.destination(),
|
||||
clanguml::class_diagram::model::to_string(r.type()),
|
||||
c.full_name(), r.label());
|
||||
clanguml::common::model::to_string(r.type()), c.full_name(),
|
||||
r.label());
|
||||
|
||||
c.add_relationship(std::move(r));
|
||||
}
|
||||
@@ -874,12 +872,12 @@ void translation_unit_visitor::process_function_parameter(
|
||||
for (const auto &[type, relationship_type] : relationships) {
|
||||
if ((relationship_type != relationship_t::kNone) &&
|
||||
(type != c.name())) {
|
||||
class_relationship r{relationship_t::kDependency, type};
|
||||
relationship r{relationship_t::kDependency, type};
|
||||
|
||||
LOG_DBG("Adding field relationship {} {} {} : {}",
|
||||
r.destination(),
|
||||
clanguml::class_diagram::model::to_string(r.type()),
|
||||
c.full_name(), r.label());
|
||||
clanguml::common::model::to_string(r.type()), c.full_name(),
|
||||
r.label());
|
||||
|
||||
c.add_relationship(std::move(r));
|
||||
}
|
||||
@@ -940,15 +938,14 @@ void translation_unit_visitor::process_function_parameter(
|
||||
"only adding reference to template {}",
|
||||
cx::util::full_name(cppast::remove_cv(t),
|
||||
ctx.entity_index(), false));
|
||||
class_relationship rr{relationship_t::kDependency,
|
||||
relationship rr{relationship_t::kDependency,
|
||||
cx::util::full_name(cppast::remove_cv(t),
|
||||
ctx.entity_index(), false)};
|
||||
LOG_DBG("Adding field template dependency relationship "
|
||||
"{} {} {} "
|
||||
": {}",
|
||||
rr.destination(),
|
||||
clanguml::class_diagram::model::to_string(
|
||||
rr.type()),
|
||||
clanguml::common::model::to_string(rr.type()),
|
||||
c.full_name(), rr.label());
|
||||
c.add_relationship(std::move(rr));
|
||||
}
|
||||
@@ -957,14 +954,13 @@ void translation_unit_visitor::process_function_parameter(
|
||||
class_ tinst = build_template_instantiation(
|
||||
template_instantiation_type);
|
||||
|
||||
class_relationship rr{
|
||||
relationship rr{
|
||||
relationship_t::kDependency, tinst.full_name()};
|
||||
|
||||
LOG_DBG("Adding field dependency relationship {} {} {} "
|
||||
": {}",
|
||||
rr.destination(),
|
||||
clanguml::class_diagram::model::to_string(
|
||||
rr.type()),
|
||||
clanguml::common::model::to_string(rr.type()),
|
||||
c.full_name(), rr.label());
|
||||
|
||||
c.add_relationship(std::move(rr));
|
||||
@@ -1008,7 +1004,7 @@ void translation_unit_visitor::process_friend(
|
||||
cppast::cpp_entity_kind::class_template_t))
|
||||
return;
|
||||
|
||||
class_relationship r{
|
||||
relationship r{
|
||||
relationship_t::kFriendship, "", scope_t::kNone, "<<friend>>"};
|
||||
|
||||
if (f.comment().has_value())
|
||||
@@ -1355,7 +1351,7 @@ class_ translation_unit_visitor::build_template_instantiation(
|
||||
? std::make_optional(&tinst)
|
||||
: parent);
|
||||
|
||||
class_relationship tinst_dependency{
|
||||
relationship tinst_dependency{
|
||||
relationship_t::kDependency, nested_tinst.full_name()};
|
||||
|
||||
auto nested_tinst_full_name = nested_tinst.full_name();
|
||||
@@ -1392,8 +1388,7 @@ class_ translation_unit_visitor::build_template_instantiation(
|
||||
}
|
||||
else if (targ.type().value().kind() ==
|
||||
cppast::cpp_type_kind::user_defined_t) {
|
||||
class_relationship tinst_dependency{
|
||||
relationship_t::kDependency,
|
||||
relationship tinst_dependency{relationship_t::kDependency,
|
||||
cx::util::full_name(
|
||||
cppast::remove_cv(
|
||||
cx::util::unreferenced(targ.type().value())),
|
||||
@@ -1478,7 +1473,7 @@ class_ translation_unit_visitor::build_template_instantiation(
|
||||
// Otherwise point to the base template
|
||||
destination = tinst.base_template();
|
||||
}
|
||||
class_relationship r{relationship_t::kInstantiation, destination};
|
||||
relationship r{relationship_t::kInstantiation, destination};
|
||||
tinst.add_relationship(std::move(r));
|
||||
|
||||
return tinst;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/visitor/translation_unit_visitor.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -100,9 +100,9 @@ public:
|
||||
|
||||
bool find_relationships(const cppast::cpp_type &t,
|
||||
std::vector<std::pair<std::string,
|
||||
clanguml::class_diagram::model::relationship_t>> &relationships,
|
||||
clanguml::class_diagram::model::relationship_t relationship_hint =
|
||||
clanguml::class_diagram::model::relationship_t::kNone);
|
||||
clanguml::common::model::relationship_t>> &relationships,
|
||||
clanguml::common::model::relationship_t relationship_hint =
|
||||
clanguml::common::model::relationship_t::kNone);
|
||||
|
||||
void process_template_type_parameter(
|
||||
const cppast::cpp_template_type_parameter &t,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/decorated_element.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "decorated_element.h"
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
namespace clanguml::common::model {
|
||||
|
||||
bool decorated_element::skip() const
|
||||
{
|
||||
@@ -38,7 +38,8 @@ bool decorated_element::skip_relationship() const
|
||||
return false;
|
||||
}
|
||||
|
||||
std::pair<relationship_t, std::string> decorated_element::relationship() const
|
||||
std::pair<relationship_t, std::string>
|
||||
decorated_element::get_relationship() const
|
||||
{
|
||||
for (auto &d : decorators_)
|
||||
if (std::dynamic_pointer_cast<decorators::association>(d))
|
||||
@@ -79,4 +80,11 @@ void decorated_element::add_decorators(
|
||||
decorators_.push_back(d);
|
||||
}
|
||||
}
|
||||
|
||||
void decorated_element::append(const decorated_element &de)
|
||||
{
|
||||
for (auto d : de.decorators()) {
|
||||
decorators_.push_back(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/decorated_element.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
namespace clanguml::common::model {
|
||||
|
||||
class decorated_element {
|
||||
public:
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
bool skip_relationship() const;
|
||||
|
||||
std::pair<relationship_t, std::string> relationship() const;
|
||||
std::pair<relationship_t, std::string> get_relationship() const;
|
||||
|
||||
std::string style_spec();
|
||||
|
||||
@@ -43,6 +43,8 @@ public:
|
||||
void add_decorators(
|
||||
const std::vector<std::shared_ptr<decorators::decorator>> &decorators);
|
||||
|
||||
void append(const decorated_element &de);
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<decorators::decorator>> decorators_;
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/element.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "util/util.h"
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
namespace clanguml::common::model {
|
||||
|
||||
std::atomic_uint64_t element::m_nextId = 1;
|
||||
|
||||
@@ -32,7 +32,7 @@ element::element(const std::vector<std::string> &using_namespaces)
|
||||
|
||||
std::string element::alias() const { return fmt::format("C_{:010}", m_id); }
|
||||
|
||||
void element::add_relationship(class_relationship &&cr)
|
||||
void element::add_relationship(relationship &&cr)
|
||||
{
|
||||
if (cr.destination().empty()) {
|
||||
LOG_WARN("Skipping relationship '{}' - {} - '{}' due empty "
|
||||
@@ -41,8 +41,10 @@ void element::add_relationship(class_relationship &&cr)
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = std::find(relationships_.begin(), relationships_.end(), cr);
|
||||
if (it == relationships_.end())
|
||||
LOG_DBG("Adding relationship: '{}' - {} - '{}'", cr.destination(),
|
||||
to_string(cr.type()), full_name(true));
|
||||
|
||||
if (!util::contains(relationships_, cr))
|
||||
relationships_.emplace_back(std::move(cr));
|
||||
}
|
||||
|
||||
@@ -56,13 +58,12 @@ const std::vector<std::string> &element::using_namespaces() const
|
||||
return using_namespaces_;
|
||||
}
|
||||
|
||||
std::vector<class_relationship> &element::relationships()
|
||||
std::vector<relationship> &element::relationships() { return relationships_; }
|
||||
|
||||
const std::vector<relationship> &element::relationships() const
|
||||
{
|
||||
return relationships_;
|
||||
}
|
||||
|
||||
const std::vector<class_relationship> &element::relationships() const
|
||||
{
|
||||
return relationships_;
|
||||
}
|
||||
void element::append(const element &e) { decorated_element::append(e); }
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/element.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -17,14 +17,14 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "class_relationship.h"
|
||||
#include "decorated_element.h"
|
||||
#include "relationship.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
namespace clanguml::common::model {
|
||||
|
||||
class element : public decorated_element {
|
||||
public:
|
||||
@@ -46,11 +46,13 @@ public:
|
||||
|
||||
const std::vector<std::string> &using_namespaces() const;
|
||||
|
||||
std::vector<class_relationship> &relationships();
|
||||
std::vector<relationship> &relationships();
|
||||
|
||||
const std::vector<class_relationship> &relationships() const;
|
||||
const std::vector<relationship> &relationships() const;
|
||||
|
||||
void add_relationship(class_relationship &&cr);
|
||||
void add_relationship(relationship &&cr);
|
||||
|
||||
void append(const element &e);
|
||||
|
||||
protected:
|
||||
const uint64_t m_id{0};
|
||||
@@ -59,7 +61,7 @@ private:
|
||||
std::string name_;
|
||||
std::vector<std::string> namespace_;
|
||||
std::vector<std::string> using_namespaces_;
|
||||
std::vector<class_relationship> relationships_;
|
||||
std::vector<relationship> relationships_;
|
||||
|
||||
static std::atomic_uint64_t m_nextId;
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/enums.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
namespace clanguml::common::model {
|
||||
|
||||
enum class access_t { kPublic, kProtected, kPrivate };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class_relationship.cc
|
||||
* src/common/model/class_relationship.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -16,9 +16,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "class_relationship.h"
|
||||
#include "relationship.h"
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
namespace clanguml::common::model {
|
||||
|
||||
std::string to_string(relationship_t r)
|
||||
{
|
||||
@@ -48,8 +48,8 @@ std::string to_string(relationship_t r)
|
||||
}
|
||||
}
|
||||
|
||||
class_relationship::class_relationship(relationship_t type,
|
||||
const std::string &destination, scope_t scope, const std::string &label,
|
||||
relationship::relationship(relationship_t type, const std::string &destination,
|
||||
scope_t scope, const std::string &label,
|
||||
const std::string &multiplicity_source,
|
||||
const std::string &multiplicity_destination)
|
||||
: type_{type}
|
||||
@@ -61,51 +61,48 @@ class_relationship::class_relationship(relationship_t type,
|
||||
{
|
||||
}
|
||||
|
||||
void class_relationship::set_type(relationship_t type) noexcept
|
||||
{
|
||||
type_ = type;
|
||||
}
|
||||
void relationship::set_type(relationship_t type) noexcept { type_ = type; }
|
||||
|
||||
relationship_t class_relationship::type() const noexcept { return type_; }
|
||||
relationship_t relationship::type() const noexcept { return type_; }
|
||||
|
||||
void class_relationship::set_destination(const std::string &destination)
|
||||
void relationship::set_destination(const std::string &destination)
|
||||
{
|
||||
destination_ = destination;
|
||||
}
|
||||
|
||||
std::string class_relationship::destination() const { return destination_; }
|
||||
std::string relationship::destination() const { return destination_; }
|
||||
|
||||
void class_relationship::set_multiplicity_source(
|
||||
void relationship::set_multiplicity_source(
|
||||
const std::string &multiplicity_source)
|
||||
{
|
||||
multiplicity_source_ = multiplicity_source;
|
||||
}
|
||||
|
||||
std::string class_relationship::multiplicity_source() const
|
||||
std::string relationship::multiplicity_source() const
|
||||
{
|
||||
return multiplicity_source_;
|
||||
}
|
||||
|
||||
void class_relationship::set_multiplicity_destination(
|
||||
void relationship::set_multiplicity_destination(
|
||||
const std::string &multiplicity_destination)
|
||||
{
|
||||
multiplicity_destination_ = multiplicity_destination;
|
||||
}
|
||||
|
||||
std::string class_relationship::multiplicity_destination() const
|
||||
std::string relationship::multiplicity_destination() const
|
||||
{
|
||||
return multiplicity_destination_;
|
||||
}
|
||||
|
||||
void class_relationship::set_label(const std::string &label) { label_ = label; }
|
||||
void relationship::set_label(const std::string &label) { label_ = label; }
|
||||
|
||||
std::string class_relationship::label() const { return label_; }
|
||||
std::string relationship::label() const { return label_; }
|
||||
|
||||
void class_relationship::set_scope(scope_t scope) noexcept { scope_ = scope; }
|
||||
void relationship::set_scope(scope_t scope) noexcept { scope_ = scope; }
|
||||
|
||||
scope_t class_relationship::scope() const noexcept { return scope_; }
|
||||
scope_t relationship::scope() const noexcept { return scope_; }
|
||||
|
||||
bool operator==(const class_relationship &l, const class_relationship &r)
|
||||
bool operator==(const relationship &l, const relationship &r)
|
||||
{
|
||||
return l.type() == r.type() && l.destination() == r.destination() &&
|
||||
l.label() == r.label();
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/class_relationship.h
|
||||
* src/common/model/relationship.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -17,23 +17,24 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "decorated_element.h"
|
||||
#include "stylable_element.h"
|
||||
#include "common/model/decorated_element.h"
|
||||
#include "common/model/stylable_element.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
namespace clanguml::common::model {
|
||||
|
||||
std::string to_string(relationship_t r);
|
||||
|
||||
class class_relationship : public decorated_element, public stylable_element {
|
||||
class relationship : public common::model::decorated_element,
|
||||
public common::model::stylable_element {
|
||||
public:
|
||||
class_relationship(relationship_t type, const std::string &destination,
|
||||
relationship(relationship_t type, const std::string &destination,
|
||||
scope_t scope = scope_t::kNone, const std::string &label = "",
|
||||
const std::string &multiplicity_source = "",
|
||||
const std::string &multiplicity_destination = "");
|
||||
|
||||
virtual ~class_relationship() = default;
|
||||
virtual ~relationship() = default;
|
||||
|
||||
void set_type(relationship_t type) noexcept;
|
||||
relationship_t type() const noexcept;
|
||||
@@ -54,8 +55,7 @@ public:
|
||||
void set_scope(scope_t scope) noexcept;
|
||||
scope_t scope() const noexcept;
|
||||
|
||||
friend bool operator==(
|
||||
const class_relationship &l, const class_relationship &r);
|
||||
friend bool operator==(const relationship &l, const relationship &r);
|
||||
|
||||
private:
|
||||
relationship_t type_{relationship_t::kAssociation};
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/stylable_element.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "stylable_element.h"
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
namespace clanguml::common::model {
|
||||
|
||||
void stylable_element::set_style(const std::string &style) { style_ = style; }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/class_diagram/model/stylable_element.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace clanguml::class_diagram::model {
|
||||
namespace clanguml::common::model {
|
||||
|
||||
class stylable_element {
|
||||
public:
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/config/config.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -69,7 +69,7 @@ bool diagram::should_include(const std::string &name_) const
|
||||
|
||||
for (const auto &ex : exclude.namespaces) {
|
||||
if (name.find(ex) == 0) {
|
||||
spdlog::debug("Skipping from diagram: {}", name);
|
||||
LOG_DBG("Skipping from diagram: {}", name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -89,8 +89,7 @@ bool diagram::should_include(const std::string &name_) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool diagram::should_include(
|
||||
const clanguml::class_diagram::model::scope_t scope) const
|
||||
bool diagram::should_include(const clanguml::common::model::scope_t scope) const
|
||||
{
|
||||
for (const auto &s : exclude.scopes) {
|
||||
if (s == scope)
|
||||
@@ -128,10 +127,11 @@ bool class_diagram::has_class(std::string clazz)
|
||||
}
|
||||
|
||||
namespace YAML {
|
||||
using clanguml::class_diagram::model::scope_t;
|
||||
using clanguml::common::model::scope_t;
|
||||
using clanguml::config::class_diagram;
|
||||
using clanguml::config::config;
|
||||
using clanguml::config::filter;
|
||||
using clanguml::config::package_diagram;
|
||||
using clanguml::config::plantuml;
|
||||
using clanguml::config::sequence_diagram;
|
||||
using clanguml::config::source_location;
|
||||
@@ -282,6 +282,19 @@ template <> struct convert<sequence_diagram> {
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// class_diagram Yaml decoder
|
||||
//
|
||||
template <> struct convert<package_diagram> {
|
||||
static bool decode(const Node &node, package_diagram &rhs)
|
||||
{
|
||||
if (!decode_diagram(node, rhs))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// config Yaml decoder
|
||||
//
|
||||
@@ -313,8 +326,12 @@ template <> struct convert<config> {
|
||||
rhs.diagrams[name] = std::make_shared<sequence_diagram>(
|
||||
d.second.as<sequence_diagram>());
|
||||
}
|
||||
else if (diagram_type == "package") {
|
||||
rhs.diagrams[name] = std::make_shared<package_diagram>(
|
||||
d.second.as<package_diagram>());
|
||||
}
|
||||
else {
|
||||
spdlog::warn(
|
||||
LOG_WARN(
|
||||
"Diagrams of type {} are not supported at the moment... ",
|
||||
diagram_type);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/config/config.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -18,7 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "class_diagram/model/diagram.h"
|
||||
#include "class_diagram/model/enums.h"
|
||||
#include "common/model/enums.h"
|
||||
#include "util/util.h"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
@@ -56,7 +56,7 @@ struct filter {
|
||||
// E.g.:
|
||||
// - public
|
||||
// - private
|
||||
std::vector<class_diagram::model::scope_t> scopes;
|
||||
std::vector<common::model::scope_t> scopes;
|
||||
};
|
||||
|
||||
struct diagram {
|
||||
@@ -77,7 +77,7 @@ struct diagram {
|
||||
|
||||
bool should_include(const std::string &name_) const;
|
||||
|
||||
bool should_include(const class_diagram::model::scope_t scope) const;
|
||||
bool should_include(const common::model::scope_t scope) const;
|
||||
};
|
||||
|
||||
struct source_location {
|
||||
@@ -101,6 +101,10 @@ struct sequence_diagram : public diagram {
|
||||
std::vector<source_location> start_from;
|
||||
};
|
||||
|
||||
struct package_diagram : public diagram {
|
||||
virtual ~package_diagram() = default;
|
||||
};
|
||||
|
||||
struct config {
|
||||
// the glob list is additive and relative to the current
|
||||
// directory
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/cx/compilation_database.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "compilation_database.h"
|
||||
#include "util/util.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <spdlog/fmt/fmt.h>
|
||||
@@ -73,7 +74,7 @@ CXTranslationUnit compilation_database::parse_translation_unit(
|
||||
clang_CompileCommands_getCommand(compile_commands, 0);
|
||||
|
||||
auto cc_filename = clang_CompileCommand_getFilename(compile_command);
|
||||
spdlog::debug(
|
||||
LOG_DBG(
|
||||
"Processing compile command file: {}", clang_getCString(cc_filename));
|
||||
|
||||
auto num_args = clang_CompileCommand_getNumArgs(compile_command);
|
||||
@@ -84,7 +85,7 @@ CXTranslationUnit compilation_database::parse_translation_unit(
|
||||
arguments = (char **)malloc(sizeof(char *) * num_args);
|
||||
for (j = 0; j < num_args; ++j) {
|
||||
CXString arg = clang_CompileCommand_getArg(compile_command, j);
|
||||
spdlog::debug("Processing argument: {}", clang_getCString(arg));
|
||||
LOG_DBG("Processing argument: {}", clang_getCString(arg));
|
||||
arguments[j] = strdup(clang_getCString(arg));
|
||||
clang_disposeString(arg);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/cx/compilation_database.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/cx/cursor.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/cx/cursor.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/cx/type.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/cx/type.h
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* src/cx/util.cc
|
||||
*
|
||||
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||
* Copyright (c) 2021-2022 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.
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <cppast/cpp_class.hpp>
|
||||
#include <cppast/cpp_entity_kind.hpp>
|
||||
#include <cppast/cpp_namespace.hpp>
|
||||
#include <cppast/cpp_template.hpp>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
@@ -92,6 +93,27 @@ std::string ns(const cppast::cpp_entity &e)
|
||||
return fmt::format("{}", fmt::join(res, "::"));
|
||||
}
|
||||
|
||||
type_safe::optional_ref<const cppast::cpp_namespace> entity_ns(
|
||||
const cppast::cpp_entity &e)
|
||||
{
|
||||
std::vector<std::string> res{};
|
||||
|
||||
if (e.kind() == cppast::cpp_entity_kind::namespace_t)
|
||||
return type_safe::optional_ref<const cppast::cpp_namespace>(
|
||||
static_cast<const cppast::cpp_namespace &>(e));
|
||||
|
||||
auto it = e.parent();
|
||||
while (it) {
|
||||
if (it.value().kind() == cppast::cpp_entity_kind::namespace_t) {
|
||||
return type_safe::optional_ref<const cppast::cpp_namespace>(
|
||||
static_cast<const cppast::cpp_namespace &>(it.value()));
|
||||
}
|
||||
it = it.value().parent();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
bool is_inside_class(const cppast::cpp_entity &e)
|
||||
{
|
||||
auto it = e.parent();
|
||||
|
||||