Documentation.md 3.18 KB
Newer Older
1
2
# Documentation

Matteo's avatar
Matteo committed
3
4
[TOC]

Matteo's avatar
update    
Matteo committed
5
6
> There is no worse software than undocumented software.

Matteo's avatar
Matteo committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
![Meme](../img/meme-documentation.jpg)

## Generate the documentation

Along with the source code, the documentation of the *Video Analyser* is provided in the `docs` folder. The documentation is generated with [Doxygen](https://www.doxygen.nl/index.html) and can be accessed by opening the `index.html` file in the `docs/html` folder with a browser.

To generate the documentation, run the following command from the root folder:
```
make docs
```

Note that Doxygen must be installed on your machine.

## Write the documentation

Doxygen is a tool for generating documentation from annotated C++ sources, as well as other popular programming languages like C, Objective-C, C#, PHP, Java, Python, IDL (Corba, Microsoft, and UNO/OpenOffice flavors), Fortran, VHDL, Tcl, and to some extent D.

To access Doxygen superpowers you need to add comments to your code. Doxygen supports two types of comments: single-line and multi-line comments. Single-line comments start with `///` or `//!` and multi-line comments start with `/**` and end with `*/`. The following example shows how to use both types of comments:

```
/// This is a single-line comment.

//! This is also a single-line comment.

/**
 * This is a multi-line comment.
 */
```

A sample of Doxygen commented class looks like this:

```
/**
 * @class SampleClass
 * @brief This is a sample class.
 *
 * This class is used to show how to comment a class with Doxygen.
 */
class SampleClass {
private:
    int field1; /**< This is a sample field. */
public:
    /**
     * @brief This is a sample constructor.
     *
     * This constructor is used to show how to comment a constructor with Doxygen.
     */
    SampleClass();

    /**
     * @brief This is a sample destructor.
     *
     * This destructor is used to show how to comment a destructor with Doxygen.
     */
    ~SampleClass();

    /**
     * @brief This is a sample method.
     *
     * This method is used to show how to comment a method with Doxygen.
     *
     * @param[in] param1 This is a sample parameter.
     * @param[in] param2 This is another sample parameter.
     * @return This is a sample return value.
     */
    int sampleMethod(int param1, int param2);
};
```

For more information about Doxygen, please refer to the [official documentation](https://www.doxygen.nl/manual/index.html).

# Style guide
Matteo's avatar
update    
Matteo committed
79
80
81

The code is written following C++20 standard, to ensure the best readability and maintainability. The code is formatted using [clang-format](https://clang.llvm.org/docs/ClangFormat.html) with the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) as a reference.

Matteo's avatar
Matteo committed
82
83
84
85
86
87
88
89
90
91
92
93
To format the code, run the following command from the root folder:
```
make format
```

Note that clang-format must be installed on your machine.

In addition to the Google C++ Style Guide, the following rules are applied:

- when returning multiple values, use `std::tuple` or `std::pair`, instead of passing by reference;
- when dealing with nullable values, use `std::optional`;
- avoid to manipulate global variables, if you need to share data between different parts of the code, use dependency injection and pass the data as a parameter;