Skip to content

Commit da60017

Browse files
committed
Improved docs (#208)
1 parent c0faecc commit da60017

21 files changed

+173
-150
lines changed

CHANGELOG.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# CHANGELOG
2-
3-
* Added radius parameter to context filter (#201)
2+
3+
* Fixed random typos and omissions in docs (#208)
4+
* Fixed handling of diagram hyperlinks with sources outside of project dir (#213)
5+
* Fixed test case t00014 on macos (#176)
6+
* Added automatic generation of diagram images using PlantUML and MermaidJS (#204)
7+
* Added radius parameter to context filter (#201)
48

59
### 0.4.1
610
* Enabled manual call expression injection through comments (#196)

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test cases [here](./docs/test_cases.md) or examples in
2929
Main features supported so far include:
3030

3131
* **Class diagram generation**
32-
* Class properties and methods including access - [_example_](docs/test_cases/t00003.md)
32+
* Class properties and methods including access scope - [_example_](docs/test_cases/t00003.md)
3333
* Class inheritance - [_example_](docs/test_cases/t00002.md)
3434
* Other class relationships including associations, aggregations, dependencies and friendship - [_example_](docs/test_cases/t00006.md)
3535
* Template instantiation relationships - [_example_](docs/test_cases/t00014.md)
@@ -38,8 +38,8 @@ Main features supported so far include:
3838
* Diagram content filtering based on namespaces, elements and relationships - [_example_](docs/test_cases/t00040.md)
3939
* Optional package generation from namespaces (only PlantUML) - [_example_](docs/test_cases/t00036.md)
4040
* Optional package generation from subdirectories (only PlantUML) - [_example_](docs/test_cases/t00065.md)
41-
* Interactive links to online code to classes, methods and class fields in SVG diagrams - [_example_](https://raw.githubusercontent.com/bkryza/clang-uml/master/docs/test_cases/t00002_class.svg)
42-
* Support for plain C99/C11 code (struct and units relationships) - [_example_](docs/test_cases/t00057.md)
41+
* Interactive links to online code or docs for classes, methods and class fields in SVG diagrams - [_example_](https://raw.githubusercontent.com/bkryza/clang-uml/master/docs/test_cases/t00002_class.svg)
42+
* Support for plain C99/C11 code (struct, units and their relationships) - [_example_](docs/test_cases/t00057.md)
4343
* C++20 concept constraints - [_example_](docs/test_cases/t00059.md)
4444
* **Sequence diagram generation**
4545
* Generation of sequence diagram from specific method or function - [_example_](docs/test_cases/t20001.md)

docs/architecture.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This section presents general architecture and components of `clang-uml`.
2727
uses [Clang LibTooling API](https://releases.llvm.org/16.0.0/tools/clang/docs/LibTooling.html)
2828
to traverse
2929
the AST (Abstract Syntax Tree) of the source code and extract any information
30-
relevant for a specified diagram.
30+
relevant for a specific diagram.
3131

3232
The code is divided into several packages (namespaces), the main of them are:
3333

@@ -131,11 +131,7 @@ generator.
131131
## Diagram generators
132132

133133
Diagram generators convert the `clang-uml`'s internal UML model into actual
134-
diagram in one of the supported formats:
135-
136-
- PlantUML
137-
- MermaidJS
138-
- JSON
134+
diagram in one of the supported formats: PlantUML, MermaidJS and JSON.
139135

140136
Each diagram generator extends a common interface appropriate for the
141137
selected output format, i.e.:

docs/class_diagrams.md

+32-18
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* [Relationships](#relationships)
88
* [Relationships to classes in containers or smart pointers](#relationships-to-classes-in-containers-or-smart-pointers)
99
* [Inheritance diagrams](#inheritance-diagrams)
10-
* [Including packages in the diagram](#including-packages-in-the-diagram)
10+
* [Generating UML packages in the diagram](#generating-uml-packages-in-the-diagram)
1111
* [Class context diagram](#class-context-diagram)
1212
* [Disabling dependency relationships](#disabling-dependency-relationships)
1313

@@ -72,18 +72,18 @@ To render only classes without any properties an exclusion filter can be added:
7272

7373
## Relationships
7474

75-
The following table presents the PlantUML arrows representing each relationship
76-
in the class diagrams.
75+
The following table presents the PlantUML and MermaidJS arrows representing each
76+
type of relationship generated in the class diagrams.
7777

78-
| UML | PlantUML |
79-
| ---- | --- |
80-
| Inheritance | ![extension](img/puml_inheritance.png) |
81-
| Association | ![association](img/puml_association.png) |
82-
| Dependency | ![dependency](img/puml_dependency.png) |
83-
| Aggregation | ![aggregation](img/puml_aggregation.png) |
84-
| Composition | ![composition](img/puml_composition.png) |
85-
| Template specialization/instantiation | ![specialization](img/puml_instantiation.png) |
86-
| Nesting (inner class/enum) | ![nesting](img/puml_nested.png) |
78+
| UML | PlantUML | MermaidJS |
79+
| ---- | --- |--------------------------------------------|
80+
| Inheritance | ![extension](img/puml_inheritance.png) | ![extension](img/mermaid_inheritance.png) |
81+
| Association | ![association](img/puml_association.png) | ![extension](img/mermaid_association.png) |
82+
| Dependency | ![dependency](img/puml_dependency.png) | ![extension](img/mermaid_dependency.png) |
83+
| Aggregation | ![aggregation](img/puml_aggregation.png) | ![extension](img/mermaid_aggregation.png) |
84+
| Composition | ![composition](img/puml_composition.png) | ![extension](img/mermaid_composition.png) |
85+
| Template specialization/instantiation | ![specialization](img/puml_instantiation.png) | ![extension](img/mermaid_instantiation.png) |
86+
| Nesting (inner class/enum) | ![nesting](img/puml_nested.png) | ![extension](img/mermaid_nested.png) |
8787

8888

8989
By default, a member from which a relationship has been added to the diagram
@@ -131,7 +131,7 @@ rendered. This can be easily achieved in `clang-uml` through inclusion filters:
131131
- inheritance
132132
```
133133

134-
## Including packages in the diagram
134+
## Generating UML packages in the diagram
135135
By default, `clang-uml` will render all element names including a namespace
136136
(relative to `using_namespace` property), e.g. `ns1::ns2::MyClass`.
137137
In order to generate packages in the diagram for each namespace instead, the
@@ -145,9 +145,10 @@ which results in the following diagram:
145145

146146
![t00036_class](test_cases/t00036_class.svg)
147147

148-
In case the code base is structured based on subdirectory instead of namespaces,
149-
packages can be generated based on the location of a given declaration in the
150-
filesystem tree, by adding also the following option:
148+
In case the code base is structured based on subdirectory instead of namespaces
149+
(or this is a C project, where namespaces are not available), packages can be
150+
generated based on the location of a given declaration in the filesystem tree,
151+
by adding also the following option:
151152

152153
```yaml
153154
package_type: directory
@@ -173,6 +174,19 @@ this can be easily achieved using `context` inclusion filter:
173174
- ns1::MyClass
174175
```
175176

177+
By default, the diagram will include only elements in direct relationship to
178+
`ns1::MyClass`, but an addition option called `radius` can be added to this
179+
filter, which will extend the context to elements related to `ns1::MyClass`
180+
through at most N relationships, e.g:
181+
182+
```yaml
183+
include:
184+
context:
185+
- match:
186+
radius: 3
187+
pattern: ns1::MyClass
188+
```
189+
176190
## Disabling dependency relationships
177191
Dependency relationships are inferred whenever a class uses another class, thus
178192
often dependency relationship will be rendered in addition to other
@@ -185,8 +199,8 @@ skip_redundant_dependencies: false
185199
```
186200

187201
In many cases, dependency relationships between classes can clutter the diagram
188-
too much. In such cases it might be useful to disable dependency relationships
189-
completely for this diagram completely using the following exclusion filter:
202+
too much. In such cases, it might be useful to disable dependency relationships
203+
completely for this diagram using the following exclusion filter:
190204
```yaml
191205
exclude:
192206
relationships:

docs/common_options.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<!-- tocstop -->
1616

1717
## Overall configuration file structure
18-
By default, `clang-uml` will look for file `.clang-uml` in the projects directory and read all diagrams definitions
19-
from it. The file must be specified in YAML and it's overall structure is as follows:
18+
By default, `clang-uml` will look for file `.clang-uml` in the project's directory and read all diagrams definitions
19+
configuration from it. The file must be specified in YAML and it's overall structure is as follows:
2020

2121
```yaml
2222
# common options for all diagrams
@@ -68,16 +68,16 @@ The syntax is simple and based on glob patterns, which can be added to the confi
6868
```
6969
7070
The glob patterns only need to match the translation units, which are also in the `compile_commands.json` file, i.e.
71-
any files that match the glob patterns but are not in `compile_commands.json` will be ignored. In case the `glob`
71+
any files that match the glob patterns, but are not in `compile_commands.json` will be ignored. In case the `glob`
7272
pattern set does not match any translation units an error will be printed on the standard output.
7373

7474
For small projects, the `glob` property can be omitted, which will result in `clang-uml` parsing all translation units
75-
from `compile_commands.json` for the diagram. However for large projects, constraining the number of translation units
75+
from `compile_commands.json` for the diagram. However, for large projects, constraining the number of translation units
7676
for each diagram to absolute minimum will significantly decrease the diagram generation times.
7777

7878
## Custom directives
7979
In case it's necessary to add some custom PlantUML or MermaidJS declarations
80-
before or after the generated diagram content, it can be achieved simply using
80+
before or after the generated diagram content, it can be achieved using
8181
the `plantuml` or `mermaid` configuration properties, for instance for PlantUML:
8282

8383
```yaml
@@ -98,11 +98,12 @@ or for MermaidJS:
9898
- note for {{ alias("ns1::ns2::MyClass") }} "This is my class."
9999
```
100100

101-
These directive are useful for instance for adding notes to elements in the
102-
diagrams or customizing diagram layout or style.
101+
These directives are useful for instance for adding notes to elements in the
102+
diagrams or customizing diagram layout and style.
103103

104-
Please note that when referring to diagram elements in the PlantUML directives,
105-
they must be added using Jinja templates `alias` command as in the example above.
104+
Please note that when referring to diagram elements in PlantUML or MermaidJS
105+
directives, they must be added using Jinja templates `alias` command as in the
106+
example above.
106107

107108
More options can be found in the official docs for each respective generator:
108109
* [PlantUML](https://plantuml.com/)
@@ -118,8 +119,7 @@ debug_mode: true
118119
```
119120

120121
the generated PlantUML diagram will contain comments before each line containing
121-
the source location of the
122-
specific diagram element.
122+
the source location of the specific diagram element.
123123

124124
## Resolving include path and compiler flags issues
125125
Due to the fact, that your project can be compiled with different compilers
@@ -175,8 +175,8 @@ command:
175175
```
176176

177177
If you want to include the system headers reported by the compiler specified
178-
already as `argv[0]` in your `compile_commands.json`, you can simply invoke
179-
`clang-uml` as:
178+
already as first argument of each compile command in your
179+
`compile_commands.json`, you can simply invoke `clang-uml` as:
180180

181181
```bash
182182
clang-uml --query-driver .

docs/diagram_filters.md

+41-31
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ Some filters accept either specified exact values, some support regular
4141
expressions while some except glob patterns.
4242
4343
For filters which accept regular expressions, the regular expression has to
44-
be provided as a map `r: 'pattern'` due to the fact the pointer (`*`) otherwise
45-
would have to be escaped in situations such as `mycontainer<char*>`, so for
44+
be provided as a map ```r: 'pattern'``` due to the fact the pointer (```*```) otherwise
45+
would have to be escaped in situations such as ```mycontainer<char*>```, so for
4646
instance to specify that the diagram should exclude all classes containing the
47-
word `test` simply add the following filter:
47+
word ```test``` simply add the following filter:
4848

4949
```yaml
5050
exclude:
@@ -73,12 +73,21 @@ The following table specifies the values allowed in each filter:
7373
| `dependencies` | Qualified name or regex | ```ns1::ns2::ClassA```, ```r: 'ns1::ns2::ClassA.+'``` |
7474
| `callee_types` | Callee types in sequence diagrams| ```constructor```, ```assignment```, ```operator```, ```defaulted```, ```static```, ```method```, ```function```, ```function_template```, ```lambda``` |
7575

76-
The following filters are available.
76+
The following filters are available:
7777

7878
## namespaces
7979

8080
Allows to include or exclude entities from specific namespaces.
8181

82+
```yaml
83+
include:
84+
namespaces:
85+
- ns1::ns2
86+
exclude:
87+
namespaces:
88+
- ns1::ns2::detail
89+
```
90+
8291
## elements
8392

8493
Allows to directly include or exclude specific entities from the diagrams, for instance to exclude a specific class
@@ -113,10 +122,11 @@ in specific files.
113122
diagrams:
114123
t00061_class:
115124
type: class
116-
relative_to: ../../tests/t00061
117-
glob: [t00061.cc]
125+
glob:
126+
- t00061.cc
118127
include:
119-
paths: [include/t00061_a.h]
128+
paths:
129+
- include/t00061_a.h
120130
using_namespace:
121131
- clanguml::t00061
122132
```
@@ -166,14 +176,14 @@ include inheritance and template specialization/instantiation relationships add
166176
```
167177

168178
The following relationships can be used in this filter:
169-
* inheritance
170-
* composition
171-
* aggregation
172-
* ownership
173-
* association
174-
* instantiation
175-
* friendship
176-
* dependency
179+
* `inheritance`
180+
* `composition`
181+
* `aggregation`
182+
* `ownership`
183+
* `association`
184+
* `instantiation`
185+
* `friendship`
186+
* `dependency`
177187

178188
## subclasses
179189

@@ -198,13 +208,13 @@ This filter allows to include or exclude class methods and members based on thei
198208
## method_types
199209

200210
This filter allows to include or exclude various method types from the class diagram, allowed values ar:
201-
* constructor
202-
* destructor
203-
* assignment
204-
* operator
205-
* defaulted
206-
* deleted
207-
* static
211+
* `constructor`
212+
* `destructor`
213+
* `assignment`
214+
* `operator`
215+
* `defaulted`
216+
* `deleted`
217+
* `static`
208218

209219
This filter is independent of the `access` filter, which controls which methods
210220
are included based on access scope (e.g. `public`).
@@ -217,15 +227,15 @@ a `callee` is the receiver of a message, and this filter specifies which types
217227
of receivers should match.
218228

219229
The following callee types are supported:
220-
* constructor
221-
* assignment
222-
* operator
223-
* defaulted
224-
* static
225-
* method
226-
* function
227-
* function_template
228-
* lambda
230+
* `constructor`
231+
* `assignment`
232+
* `operator`
233+
* `defaulted`
234+
* `static`
235+
* `method`
236+
* `function`
237+
* `function_template`
238+
* `lambda`
229239

230240
## dependants and dependencies
231241

docs/generator_types.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Currently, there are 3 types of diagram generators: `plantuml`, `mermaid`
1212
and `json`.
1313

1414
To specify, which generators should be used on the command line use option `-g`.
15-
For instance to generate both types of diagrams run `clang-uml` as follows:
15+
For instance to generate all types of diagrams run `clang-uml` as follows:
1616

1717
```bash
1818
clang-uml -g plantuml -g mermaid -g json

docs/img/mermaid_aggregation.png

5.86 KB
Loading

docs/img/mermaid_association.png

5.24 KB
Loading

docs/img/mermaid_composition.png

5.46 KB
Loading

docs/img/mermaid_dependency.png

5.9 KB
Loading

docs/img/mermaid_inheritance.png

5.77 KB
Loading

docs/img/mermaid_instantiation.png

6.23 KB
Loading

docs/img/mermaid_nested.png

5.65 KB
Loading

0 commit comments

Comments
 (0)