Skip to content

Commit

Permalink
Merge pull request #302 from bkryza/refactor-filters-config
Browse files Browse the repository at this point in the history
Refactor filters config
  • Loading branch information
bkryza authored Aug 8, 2024
2 parents b603925 + 6b29d07 commit 7df74e7
Show file tree
Hide file tree
Showing 394 changed files with 28,361 additions and 21,534 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/tmp
.gdb_history
CMakeLists.txt.user
CMakeCache.txt
Expand Down Expand Up @@ -43,3 +44,6 @@ result
cmake-build-
cmake-build-*
.run/

# VSCode
/.vscode/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

* Added regular expression support to glob patterns (#299)
* Enabled relative link patterns in generate_links option (#297)
* Added advanced diagram filter config with anyof and allof operators (#289)
* Added CLANG_UML_ENABLE_BACKTRACE CMake option (#292)

### 0.5.3
* Added context filter direction and relationships options (#274)
* Improved test coverage (#287)
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ option(ENABLE_CUDA_TEST_CASES "" OFF)
if(ENABLE_CUDA_TEST_CASES)
include(CheckLanguage)
check_language(CUDA)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_ARCHITECTURES 75)
enable_language(CUDA)
endif(ENABLE_CUDA_TEST_CASES)

if(BUILD_TESTS)
Expand Down
8 changes: 8 additions & 0 deletions docs/common_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ configuration file as follows:
glob:
- src/dir1/*.cc
- src/dir3/*.cc
- r: ".*test.*cpp$"
```
The glob patterns only need to match the translation units, which are also in
Expand All @@ -79,6 +80,13 @@ but are not in `compile_commands.json` will be ignored. In case the `glob`
pattern set does not match any translation units an error will be printed on
the standard output.

For more advanced control over the `glob` pattern, instead of simple glob style
pattern, a full regular expression can be provided as an object with a single
key `r`. In such case, the pattern will not be checked against file system at
all but will only filter the compile commands database entries. This can
significantly improve performance on projects with tens of thousands of
translation units.

For small projects, the `glob` property can be omitted, which will result in
`clang-uml` parsing all translation units from `compile_commands.json` for
the diagram. However, for large projects, constraining the number of translation
Expand Down
4 changes: 3 additions & 1 deletion docs/configuration_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ diagrams:
# Generate packages from the namespaces
generate_packages: true
package_type: namespace # or 'directory' to generate from projects subdirectories
# Limiting the number of files to include can significantly
# Limiting the number of files to include can significantly improve
# diagram generation times
glob:
- src/common/model/*.h
- src/common/model/*.cc
- src/class_diagram/model/*.h
- src/class_diagram/model/*.cc
- r: ".*test.*\\.cpp$
include:
# Only include entities from the following namespaces
namespaces:
Expand Down
61 changes: 60 additions & 1 deletion docs/diagram_filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* [method_types](#method_types)
* [callee_types](#callee_types)
* [dependants and dependencies](#dependants-and-dependencies)
* [anyof](#anyof)
* [allof](#allof)

<!-- tocstop -->

Expand Down Expand Up @@ -72,11 +74,13 @@ The following table specifies the values allowed in each filter:
| `parents` | Qualified name or regex | ```ns1::ns2::ClassA```, ```r: 'ns1::ns2::ClassA.+'``` |
| `specializations` | Qualified name or regex | ```ns1::ns2::ClassA```, ```r: 'ns1::ns2::ClassA.+'``` |
| `access` | Method or member access scope | ```public```, ```protected```, ```private``` |
| `module_access` | Module access scope | ```public```, ```private``` |
| `module_access` | Module access scope | ```public```, ```private``` |
| `method_types` | Type of class method | ```constructor```, ```destructor```, ```assignment```, ```operator```, ```defaulted```, ```deleted```, ```static``` |
| `dependants` | Qualified name or regex | ```ns1::ns2::ClassA```, ```r: 'ns1::ns2::ClassA.+'``` |
| `dependencies` | Qualified name or regex | ```ns1::ns2::ClassA```, ```r: 'ns1::ns2::ClassA.+'``` |
| `callee_types` | Callee types in sequence diagrams | ```constructor```, ```assignment```, ```operator```, ```defaulted```, ```static```, ```method```, ```function```, ```function_template```, ```lambda``` |
| `anyof` | Match any of the nested filters | Logical operator, which returns true if any of its nested filters match (requires `filter_mode: advanced` option) |
| `allof` | Match all of the nested filters | Logical operator, which returns true if all of its nested filters match (requires `filter_mode: advanced` option) |

The following filters are available:

Expand Down Expand Up @@ -385,3 +389,58 @@ and the following filter:
results in the following diagram:

![t00043_class](./test_cases/t00043_class.svg)

## anyof

> Requires setting `filter_mode: advanced` in diagram config

This filter is in fact a logical operator, which allows to gain more control
over how the specific diagram filters are combined. Consider for instance a
case where you want to include all elements from a specific namespace, as well
as some other elements from another namespace. With basic filter this is not
possible, as the `namespaces` filter will only allow elements from the
namespaces lister. However when using `anyof` it's possible to specify them
as an alternative, i.e. any element matching any of the `anyof` subfilters
will be included. For example:

```yaml
include:
anyof:
subclasses:
- ns1::nsA::A1
namespaces:
- ns2::nsB
context:
- ns3::nsC::B3
```

will include all subclasses of `ns1::nsA::A1`, all elements in the `ns2::nsB`
namespace as well as all elements in the context of element `ns3::nsC::B3`.

For more examples of this checkout test cases
[t00082](./test_cases/t00082_class.md) and
[t00083](./test_cases/t00083_class.md).

## allof

> Requires setting `filter_mode: advanced` in diagram config

This filter logical operator is complementary to the `anyof`. It matches all
diagram elements, which match all of it's subfilters. For instance the following
filter:

```yaml
include:
allof:
namespaces:
- clanguml
- std
context:
- match:
radius: 2
pattern: clanguml::A
```

which will include all elements that are in the context of element `clanguml::A`
not farther than 2 relationships away and also they belong to either `clanguml`
or `std` namespace.
5 changes: 5 additions & 0 deletions docs/test_cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
* [t00077](./test_cases/t00077.md) - Test case for context diagram with outward direction flag
* [t00078](./test_cases/t00078.md) - Test case for context diagram with relationships option
* [t00079](./test_cases/t00079.md) - Test case for context diagram exclude filter with relationships option
* [t00080](./test_cases/t00080.md) - Test case for including elements from system headers
* [t00081](./test_cases/t00081.md) - Test case for class members relationships to std types
* [t00082](./test_cases/t00082.md) - Test case for advanced diagram filter inclusion test with subclasses and namespaces
* [t00083](./test_cases/t00083.md) - Test case for advanced diagram filter exclusion test with subclasses and namespaces
## Sequence diagrams
* [t20001](./test_cases/t20001.md) - Basic sequence diagram test case
* [t20002](./test_cases/t20002.md) - Free function sequence diagram test case
Expand Down Expand Up @@ -139,6 +143,7 @@
* [t20052](./test_cases/t20052.md) - Test case for inlining lambda operator calls
* [t20053](./test_cases/t20053.md) - Test case for inlining nested lambda operator calls
* [t20054](./test_cases/t20054.md) - Test case for sequence diagram with nested classes
* [t20055](./test_cases/t20055.md) - Test case for advanced filter in sequence diagram
## Package diagrams
* [t30001](./test_cases/t30001.md) - Basic package diagram test case
* [t30002](./test_cases/t30002.md) - Package dependency test case
Expand Down
Loading

0 comments on commit 7df74e7

Please sign in to comment.