Skip to content

Commit d8ef12d

Browse files
committed
Added Doxygen documentation
1 parent a39af67 commit d8ef12d

16 files changed

+1063
-39
lines changed

.clang-uml

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ compilation_database_dir: debug
22
output_directory: docs/diagrams
33
comment_parser: clang
44
generate_links:
5-
link: https://github.com/bkryza/clang-uml/blob/{{ git.commit }}/{{ element.source.path }}#L{{ element.source.line }}
5+
link: "{% if existsIn(element, \"doxygen_link\") %}{{ element.doxygen_link }}{% endif %}"
66
tooltip: "{% if existsIn(element, \"comment\") and existsIn(element.comment, \"brief\") %}{{ abbrv(trim(replace(element.comment.brief.0, \"\\n+\", \" \")), 256) }}{% else %}{{ element.name }}{% endif %}"
77
diagrams:
88
# Class diagrams
9+
architecture_visitors_class:
10+
include!: uml/class/architecture_visitors_class.yml
911
config_class:
1012
include!: uml/class/config_class.yml
1113
config_context_class:
@@ -52,7 +54,7 @@ diagrams:
5254
include!: uml/class/sequence_model_class.yml
5355
package_model_class:
5456
include!: uml/class/package_model_class.yml
55-
# Sequence diargams
57+
# Sequence diagrams
5658
main_sequence:
5759
include!: uml/sequence/main_sequence.yml
5860
load_config_sequence:
@@ -70,6 +72,8 @@ diagrams:
7072
# Package diagrams
7173
main_package:
7274
include!: uml/package/main_package.yml
75+
architecture_package:
76+
include!: uml/package/architecture_package.yml
7377
# Include diagrams
7478
include_graph:
7579
include!: uml/include/include.yml

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ docs:
142142
doxygen: docs
143143
cp CONTRIBUTING.md docs/contributing.md
144144
cp CHANGELOG.md docs/changelog.md
145+
cp docs/diagrams/*.svg docs/doxygen/
146+
mkdir -p docs/doxygen/html/test_cases
147+
cp docs/test_cases/*.svg docs/doxygen/html/test_cases/
145148
../doxygen/_build/bin/doxygen
146149

147150
.PHONY: fedora/%

docs/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ UPDATE_TOC := markdown-toc --bullets "*" -i
1919

2020
.PHONY: toc
2121
toc:
22+
$(UPDATE_TOC) architecture.md
2223
$(UPDATE_TOC) class_diagrams.md
2324
$(UPDATE_TOC) comment_decorators.md
2425
$(UPDATE_TOC) common_options.md

docs/architecture.md

+200
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,202 @@
11
# Architecture
22

3+
<!-- toc -->
4+
5+
* [Overview](#overview)
6+
* [Configuration model](#configuration-model)
7+
* [Diagram model](#diagram-model)
8+
* [Common model](#common-model)
9+
* [Diagram filters](#diagram-filters)
10+
* [Translation unit visitors](#translation-unit-visitors)
11+
* [Diagram generators](#diagram-generators)
12+
* [Command line handler](#command-line-handler)
13+
* [Tests](#tests)
14+
* [Unit tests](#unit-tests)
15+
* [Test cases](#test-cases)
16+
* [Real code tests](#real-code-tests)
17+
18+
<!-- tocstop -->
19+
20+
This section presents general architecture and components of `clang-uml`.
21+
22+
> All diagrams below are generated by `clang-uml` and updated automatically.
23+
24+
## Overview
25+
26+
`clang-uml` is written in C++17 and
27+
uses [Clang LibTooling API](https://releases.llvm.org/16.0.0/tools/clang/docs/LibTooling.html)
28+
to traverse
29+
the AST (Abstract Syntax Tree) of the source code and extract any information
30+
relevant for a specified diagram.
31+
32+
The code is divided into several packages (namespaces), the main of them are:
33+
34+
- [`clanguml::config`](./namespaceclanguml_1_1config.html) - configuration
35+
handling
36+
- [`clanguml::common`](./namespaceclanguml_1_1common.html) - common interfaces
37+
- [`clanguml::class_diagram`](./namespaceclanguml_1_1class__diagram.html) -
38+
specializations for class diagrams
39+
- [`clanguml::sequence_diagram`](./namespaceclanguml_1_1sequence__diagram.html) -
40+
specializations for sequence diagrams
41+
- [`clanguml::include_diagram`](./namespaceclanguml_1_1include__diagram.html) -
42+
specializations for include diagrams
43+
- [`clanguml::package_diagram`](./namespaceclanguml_1_1package__diagram.html) -
44+
specializations for package diagrams
45+
46+
![clang-uml packages](./architecture_package.svg)
47+
48+
## Configuration model
49+
50+
The configuration model consists of classes representing the configuration
51+
specified in the YAML configuration files.
52+
53+
Depending on the option, it can either:
54+
55+
- be specified only at the top level of the configuration file
56+
- only in the specific diagram configuration
57+
- either of the above
58+
59+
The first group of options are stored in
60+
the [`config::config`](structclanguml_1_1config_1_1config.html) class.
61+
62+
The second group is stored in a specific diagram config subclass, e.g.
63+
[`config::sequence_diagram`](structclanguml_1_1config_1_1sequence__diagram.html)
64+
65+
The options in the last group are modeled in the
66+
[`config::inheritable_diagram_options`](./structclanguml_1_1config_1_1inheritable__diagram__options.html).
67+
68+
![configuration model](./config_class.svg)
69+
70+
The YAML configuration file is parsed
71+
using [yaml-cpp](https://github.com/jbeder/yaml-cpp) library:
72+
73+
![configuration load sequence](./load_config_sequence.svg)
74+
75+
For each possible option type, there must an implementation of a
76+
YAML decoder - e.g.
77+
[`YAML::convert<filter>`](./structYAML_1_1convert_3_01filter_01_4.html)
78+
(for converting YAML nodes to configuration model classes)
79+
and a YAML emitter - e.g.
80+
[`operator<<`](./group__yaml__emitters.html#ga4c8bc075684b08daa379aef609bb6297)
81+
(for generating YAML from configuration model classes).
82+
83+
## Diagram model
84+
85+
The diagram model namespace is divided into the [`common`](#common-model) model
86+
namespace and 1 namespace for each supported diagram type.
87+
88+
![clang-uml packages](./architecture_model.svg)
89+
90+
### Common model
91+
92+
The [common diagram model namespace](./namespaceclanguml_1_1common_1_1model.html),
93+
provides a set of classes representing typical UML and C++ concepts such as
94+
diagram elements, packages, templates, and others which are shared by more than
95+
1 diagram type.
96+
97+
![clang-uml packages](./common_model_class.svg)
98+
99+
The diagram elements are composed into a hierarchy spanning all major
100+
namespaces,
101+
depending on whether the element is specific for a single diagram type (
102+
e.g. [`participant`](./structclanguml_1_1sequence__diagram_1_1model_1_1participant.html)),
103+
or whether it's common for several diagram types (
104+
e.g. [`package`](./classclanguml_1_1common_1_1model_1_1package.html)).
105+
106+
### Diagram filters
107+
108+
In order to ease the generation of diagrams, `clang-uml` has a (very) simple
109+
intermediate UML model, which covers only the features necessary for
110+
generation of the supported diagram types. The model can be extended if
111+
necessary to add new features.
112+
113+
![diagram filter context](./diagram_filter_context_class.svg)
114+
115+
## Translation unit visitors
116+
117+
The first stage in the diagram generation involves traversing the AST of
118+
each translation unit from the `compile_commands.json` compilation database,
119+
which matched at least one pattern specified in the `glob` pattern of the
120+
configuration file.
121+
122+
Each visitor is implemented in a subclass of
123+
[`translation_unit_visitor`](./classclanguml_1_1common_1_1visitor_1_1translation__unit__visitor.html),
124+
and must also implement relevant methods from Clang's
125+
[RecursiveASTVisitor](https://clang.llvm.org/doxygen/classclang_1_1RecursiveASTVisitor.html).
126+
127+
![AST visitors](./architecture_visitors_class.svg)
128+
129+
The output of the `translation_unit_visitor` for each diagram type is an
130+
intermediate diagram model, which is then passed to the relevant diagram
131+
generator.
132+
133+
## Diagram generators
134+
135+
Diagram generators convert the `clang-uml`'s internal UML model into actual
136+
diagram in one of the supported formats:
137+
138+
- PlantUML
139+
- JSON
140+
141+
Each diagram generator extends a common interface appropriate for the
142+
selected output format, i.e.:
143+
144+
- [PlantUML](classclanguml_1_1common_1_1generators_1_1plantuml_1_1generator.html)
145+
- [JSON](classclanguml_1_1common_1_1generators_1_1json_1_1generator.html)
146+
147+
and renders the output to a file. For each diagram type there is a separate
148+
generator for each supported output format.
149+
150+
## Command line handler
151+
152+
The [cli_handler](classclanguml_1_1cli_1_1cli__handler.html) is a command line
153+
handler class is a wrapper around [CLI11](https://github.com/CLIUtils/CLI11),
154+
and implements handlers for various actions, validates command line parameters
155+
and reports errors.
156+
157+
## Tests
158+
159+
### Unit tests
160+
161+
Basic set of units tests are stored in
162+
[tests/test_*.cc](https://github.com/bkryza/clang-uml/tree/master/tests)
163+
test files. The unit tests do not aim to cover the entire codebase, only
164+
specific algorithms or methods, which should behave as expected and if their
165+
errors can be difficult to diagnose when running the test cases on C++ code.
166+
167+
### Test cases
168+
169+
These tests are the main tests of `clang-uml`. Each test case tests one or
170+
more feature of a specific diagram type. Each of them has a separated directory
171+
in the `tests` directory and its own `.clang-uml` with diagram configuration
172+
as well as a `test_case.h` file which contains the tests assertions.
173+
174+
Any other sources in that directory are compiled and then used to generate the
175+
diagrams, whose contents should be then verified within `test_case.h`
176+
for correctness. All the sources should be wrapped within a namespace:
177+
`clanguml::`
178+
179+
These test directories are numbered in consecutive numbers using the following
180+
convention:
181+
- Start with a letter `t`
182+
- The first digit of the number is the diagram type:
183+
- `0` - class diagram
184+
- `2` - sequence diagram
185+
- `3` - package diagram
186+
- `4` - include diagram
187+
- `9` - other test cases
188+
- The rest of the name is the consecutive number of the test case
189+
190+
Each test case is also referenced in
191+
[test_cases.yaml](https://github.com/bkryza/clang-uml/blob/master/tests/test_cases.yaml)
192+
where it has assigned a title. That file is used to generate the [test cases
193+
documentation page](./md_docs_2test__cases.html).
194+
195+
### Real code tests
196+
197+
Each release is tested on a set of open-source C++ projects, to be sure that
198+
at least the new version does not crash or introduce some obvious regressions.
199+
200+
The tests are stored in a separate
201+
repository: [clang-uml-examples](https://github.com/bkryza/clang-uml-examples).
202+

docs/common_options.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ from it. The file must be specified in YAML and it's overall structure is as fol
2121
# common options for all diagrams
2222
...
2323
diagrams:
24-
first_diagram_name>:
24+
first_diagram_name:
2525
type: class|sequence|package|include
2626
# diagram specific options
2727
...

docs/doxygen/layout-clang-uml.xml

+11-10
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
<tab type="structlist" visible="yes" title="" intro=""/>
3131
<tab type="structindex" visible="$ALPHABETICAL_INDEX" title=""/>
3232
</tab>
33-
<tab type="exceptions" visible="yes" title="">
34-
<tab type="exceptionlist" visible="yes" title="" intro=""/>
35-
<tab type="exceptionindex" visible="$ALPHABETICAL_INDEX" title=""/>
36-
<tab type="exceptionhierarchy" visible="yes" title="" intro=""/>
37-
</tab>
33+
<!-- <tab type="exceptions" visible="yes" title="">-->
34+
<!-- <tab type="exceptionlist" visible="yes" title="" intro=""/>-->
35+
<!-- <tab type="exceptionindex" visible="$ALPHABETICAL_INDEX" title=""/>-->
36+
<!-- <tab type="exceptionhierarchy" visible="yes" title="" intro=""/>-->
37+
<!-- </tab>-->
3838
<tab type="files" visible="yes" title="">
3939
<tab type="filelist" visible="yes" title="" intro=""/>
4040
<tab type="globals" visible="yes" title="" intro=""/>
@@ -46,6 +46,7 @@
4646
<!-- Layout definition for a class page -->
4747
<class>
4848
<briefdescription visible="yes"/>
49+
<detaileddescription title=""/>
4950
<includes visible="$SHOW_HEADERFILE"/>
5051
<inheritancegraph visible="$CLASS_GRAPH"/>
5152
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
@@ -83,7 +84,6 @@
8384
<related title="" subtitle=""/>
8485
<membergroups visible="yes"/>
8586
</memberdecl>
86-
<detaileddescription title=""/>
8787
<memberdef>
8888
<inlineclasses title=""/>
8989
<typedefs title=""/>
@@ -105,6 +105,7 @@
105105
<!-- Layout definition for a namespace page -->
106106
<namespace>
107107
<briefdescription visible="yes"/>
108+
<detaileddescription title=""/>
108109
<memberdecl>
109110
<nestednamespaces visible="yes" title=""/>
110111
<constantgroups visible="yes" title=""/>
@@ -121,7 +122,6 @@
121122
<variables title=""/>
122123
<membergroups visible="yes"/>
123124
</memberdecl>
124-
<detaileddescription title=""/>
125125
<memberdef>
126126
<inlineclasses title=""/>
127127
<typedefs title=""/>
@@ -137,6 +137,7 @@
137137
<!-- Layout definition for a concept page -->
138138
<concept>
139139
<briefdescription visible="yes"/>
140+
<detaileddescription title=""/>
140141
<includes visible="$SHOW_HEADERFILE"/>
141142
<definition visible="yes" title=""/>
142143
<detaileddescription title=""/>
@@ -146,6 +147,7 @@
146147
<!-- Layout definition for a file page -->
147148
<file>
148149
<briefdescription visible="yes"/>
150+
<!-- <detaileddescription title=""/>-->
149151
<includes visible="$SHOW_INCLUDE_FILES"/>
150152
<includegraph visible="$INCLUDE_GRAPH"/>
151153
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
@@ -167,7 +169,6 @@
167169
<variables title=""/>
168170
<membergroups visible="yes"/>
169171
</memberdecl>
170-
<detaileddescription title=""/>
171172
<memberdef>
172173
<inlineclasses title=""/>
173174
<defines title=""/>
@@ -184,6 +185,7 @@
184185
<!-- Layout definition for a group page -->
185186
<group>
186187
<briefdescription visible="yes"/>
188+
<detaileddescription title=""/>
187189
<groupgraph visible="$GROUP_GRAPHS"/>
188190
<memberdecl>
189191
<nestedgroups visible="yes" title=""/>
@@ -209,7 +211,6 @@
209211
<friends title=""/>
210212
<membergroups visible="yes"/>
211213
</memberdecl>
212-
<detaileddescription title=""/>
213214
<memberdef>
214215
<pagedocs/>
215216
<inlineclasses title=""/>
@@ -240,6 +241,6 @@
240241
<dirs visible="yes"/>
241242
<files visible="yes"/>
242243
</memberdecl>
243-
<detaileddescription title=""/>
244+
<!-- <detaileddescription title=""/>-->
244245
</directory>
245246
</doxygenlayout>

0 commit comments

Comments
 (0)