diff --git a/CHANGELOG.md b/CHANGELOG.md
index d1aa6495..ce3bd1ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,7 @@
# CHANGELOG
+ * Added context filter direction and relationships options (#274)
+ * Improved test coverage (#287)
* Fixed handling of relationships to nested enums (#280)
* Improved handling of anonymous and multi-dimensions arrays in
class diagrams (#278)
diff --git a/docs/diagram_filters.md b/docs/diagram_filters.md
index d312ab7b..339b41d5 100644
--- a/docs/diagram_filters.md
+++ b/docs/diagram_filters.md
@@ -8,6 +8,9 @@
* [element_types](#element_types)
* [paths](#paths)
* [context](#context)
+ * [context radius](#context-radius)
+ * [context direction](#context-direction)
+ * [context relationships](#context-relationships)
* [relationships](#relationships)
* [subclasses](#subclasses)
* [parents](#parents)
@@ -152,7 +155,8 @@ paths to directories can be specified.
## context
This filter allows to limit the diagram elements only to classes which are in
-direct relationship (of any kind) with the specified class, enum or concept:
+direct relationship (of any kind) with the specified `class`, `enum` or
+`concept`:
```yaml
include:
@@ -160,6 +164,7 @@ direct relationship (of any kind) with the specified class, enum or concept:
- ns1::ns2::MyClass
```
+### context radius
By default, the filter will only include or exclude items in direct
relationship (radius 1). It is however possible to define the context filter
and provide a custom radius:
@@ -178,6 +183,46 @@ and provide a custom radius:
Please note that you can specify multiple context filters in a single diagram
with different radius. Radius set to 0 will match only the given element.
+### context direction
+Sometimes we may be interested only in relationships pointing outward from
+a specific element, or inward. For instance we may want to see which elements
+depend through any relationship on a specified element. For this purpose the
+context filter has a `direction` option, which can have one of 3 values:
+ * `any` (default)
+ * `inward` - only relationships pointing toward the specified class are
+ considered in calculating the context
+ * `outward` - only relationships pointing toward the specified class are
+ considered in calculating the context
+
+For example, the following filter:
+```yaml
+ context:
+ - match:
+ radius: 2
+ pattern: clanguml::t00076::B
+ direction: inward
+```
+will include all elements related to class `B` through relationships pointing
+toward `B` within a radius of maximum 2 relationships (see test case
+[t00076](./test_cases/t00076.md)).
+
+### context relationships
+Another way to customize the context of a specified element is to declare
+which relationships should be considered when calculating the elements' context.
+
+For example, the following filter:
+```yaml
+ context:
+ - match:
+ radius: 1
+ pattern: clanguml::t00078::A
+ relationships:
+ - inheritance
+ - aggregation
+```
+will only include elements related to class `A` through inheritance or
+aggregation relationship (see test case [t00076](./test_cases/t00078.md)).
+
## relationships
This filter allows to include or exclude specific types of relationships from the diagram, for instance to only
diff --git a/docs/test_cases.md b/docs/test_cases.md
index 08b1e655..337c40d0 100644
--- a/docs/test_cases.md
+++ b/docs/test_cases.md
@@ -80,6 +80,10 @@
* [t00073](./test_cases/t00073.md) - Class diagram for template overload pattern
* [t00074](./test_cases/t00074.md) - Test case for rendering concepts without requirements
* [t00075](./test_cases/t00075.md) - Test case for class diagram styles in config file
+ * [t00076](./test_cases/t00076.md) - Test case for context diagram with inward direction flag
+ * [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
## Sequence diagrams
* [t20001](./test_cases/t20001.md) - Basic sequence diagram test case
* [t20002](./test_cases/t20002.md) - Free function sequence diagram test case
@@ -134,6 +138,7 @@
* [t20051](./test_cases/t20051.md) - Test case for CUDA calls callee_type filter
* [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
## Package diagrams
* [t30001](./test_cases/t30001.md) - Basic package diagram test case
* [t30002](./test_cases/t30002.md) - Package dependency test case
diff --git a/docs/test_cases/t00002.md b/docs/test_cases/t00002.md
index dfad9b8e..be6d5333 100644
--- a/docs/test_cases/t00002.md
+++ b/docs/test_cases/t00002.md
@@ -140,7 +140,7 @@ private:
"text": "\n \n"
},
"display_name": "A",
- "id": "987634239855407298",
+ "id": "7901073918843258388",
"is_abstract": true,
"is_nested": false,
"is_struct": false,
@@ -236,7 +236,7 @@ private:
"bases": [
{
"access": "public",
- "id": "987634239855407298",
+ "id": "7901073918843258388",
"is_virtual": false,
"name": "clanguml::t00002::A"
}
@@ -253,7 +253,7 @@ private:
"text": "\n \n"
},
"display_name": "B",
- "id": "594234458687375950",
+ "id": "4753875669499007606",
"is_abstract": false,
"is_nested": false,
"is_struct": false,
@@ -305,7 +305,7 @@ private:
"bases": [
{
"access": "public",
- "id": "987634239855407298",
+ "id": "7901073918843258388",
"is_virtual": false,
"name": "clanguml::t00002::A"
}
@@ -323,7 +323,7 @@ private:
"text": "\n \n\n Vivamus integer non suscipit taciti mus etiam at primis tempor sagittis sit,\n euismod libero facilisi aptent elementum felis blandit cursus gravida sociis\n erat ante, eleifend lectus nullam dapibus netus feugiat curae curabitur est\n ad.\n"
},
"display_name": "C",
- "id": "1142499429598587507",
+ "id": "9139995436788700062",
"is_abstract": false,
"is_nested": false,
"is_struct": false,
@@ -383,13 +383,13 @@ private:
"bases": [
{
"access": "public",
- "id": "594234458687375950",
+ "id": "4753875669499007606",
"is_virtual": false,
"name": "clanguml::t00002::B"
},
{
"access": "public",
- "id": "1142499429598587507",
+ "id": "9139995436788700062",
"is_virtual": false,
"name": "clanguml::t00002::C"
}
@@ -403,7 +403,7 @@ private:
"text": "\n This is class D\n which is a little like B\n and a little like C\n"
},
"display_name": "D",
- "id": "60950494980414724",
+ "id": "487603959843317797",
"is_abstract": false,
"is_nested": false,
"is_struct": false,
@@ -520,19 +520,19 @@ private:
"bases": [
{
"access": "public",
- "id": "594234458687375950",
+ "id": "4753875669499007606",
"is_virtual": true,
"name": "clanguml::t00002::B"
},
{
"access": "public",
- "id": "1142499429598587507",
+ "id": "9139995436788700062",
"is_virtual": true,
"name": "clanguml::t00002::C"
}
],
"display_name": "E",
- "id": "2237886670308966220",
+ "id": "17903093362471729766",
"is_abstract": false,
"is_nested": false,
"is_struct": false,
@@ -651,52 +651,52 @@ private:
"relationships": [
{
"access": "public",
- "destination": "987634239855407298",
- "source": "594234458687375950",
+ "destination": "7901073918843258388",
+ "source": "4753875669499007606",
"type": "extension"
},
{
"access": "public",
- "destination": "987634239855407298",
- "source": "1142499429598587507",
+ "destination": "7901073918843258388",
+ "source": "9139995436788700062",
"type": "extension"
},
{
"access": "private",
- "destination": "987634239855407298",
+ "destination": "7901073918843258388",
"label": "as",
- "source": "60950494980414724",
+ "source": "487603959843317797",
"type": "association"
},
{
"access": "public",
- "destination": "594234458687375950",
- "source": "60950494980414724",
+ "destination": "4753875669499007606",
+ "source": "487603959843317797",
"type": "extension"
},
{
"access": "public",
- "destination": "1142499429598587507",
- "source": "60950494980414724",
+ "destination": "9139995436788700062",
+ "source": "487603959843317797",
"type": "extension"
},
{
"access": "private",
- "destination": "987634239855407298",
+ "destination": "7901073918843258388",
"label": "as",
- "source": "2237886670308966220",
+ "source": "17903093362471729766",
"type": "association"
},
{
"access": "public",
- "destination": "594234458687375950",
- "source": "2237886670308966220",
+ "destination": "4753875669499007606",
+ "source": "17903093362471729766",
"type": "extension"
},
{
"access": "public",
- "destination": "1142499429598587507",
- "source": "2237886670308966220",
+ "destination": "9139995436788700062",
+ "source": "17903093362471729766",
"type": "extension"
}
],
diff --git a/docs/test_cases/t00002_class.svg b/docs/test_cases/t00002_class.svg
index d5ca305a..ff2fe6f0 100644
--- a/docs/test_cases/t00002_class.svg
+++ b/docs/test_cases/t00002_class.svg
@@ -1,6 +1,6 @@
diff --git a/docs/test_cases/t00002_class_mermaid.svg b/docs/test_cases/t00002_class_mermaid.svg
index 071b3e85..cf6f8393 100644
--- a/docs/test_cases/t00002_class_mermaid.svg
+++ b/docs/test_cases/t00002_class_mermaid.svg
@@ -169,8 +169,8 @@
-
-
+
+
@@ -198,8 +198,8 @@
-
-
+
+
@@ -222,8 +222,8 @@
-
-
+
+
@@ -246,8 +246,8 @@
-
-
+
+
@@ -280,8 +280,8 @@
-
-
+
+
diff --git a/docs/test_cases/t00003.md b/docs/test_cases/t00003.md
index 7bcc4ba5..dc825e2e 100644
--- a/docs/test_cases/t00003.md
+++ b/docs/test_cases/t00003.md
@@ -104,7 +104,7 @@ int A::static_int = 1;
{
"bases": [],
"display_name": "A",
- "id": "1371951663534295727",
+ "id": "10975613308274365816",
"is_abstract": false,
"is_nested": false,
"is_struct": false,
diff --git a/docs/test_cases/t00003_class.svg b/docs/test_cases/t00003_class.svg
index 44096fb7..e9a84bc3 100644
--- a/docs/test_cases/t00003_class.svg
+++ b/docs/test_cases/t00003_class.svg
@@ -1,6 +1,6 @@