Skip to content

Commit ce69bba

Browse files
committed
Minor wording tweaks to API documentation secion
1 parent 2569da5 commit ce69bba

1 file changed

Lines changed: 20 additions & 22 deletions

File tree

bestpractices/c++practices.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -613,30 +613,28 @@ When in doubt, use a struct - it is better to have good names than not.
613613
614614
## API Documentation
615615
616-
API Documentation in FreeCAD roughly consists of two types of API documentation. **Topics** that explain the concepts behind the code and **API documentation strings**. Both are important but topics are even more valued.
616+
API Documentation in FreeCAD consists of two main types of documentation. **Topics** explain the concepts behind the code and **API documentation strings** explain the code itself. Both are important but topics are especially valued.
617617
618-
Although it is not required, it is encouraged to write API documentation when applicable. Note that it **is required** to make current API documentation up-to-date with changes that are made to the code. In this section we offer a set of guidelines.
618+
Although it is not strictly required, developers are highly encouraged to write API documentation when applicable. Note that it **is required** to make current API documentation up-to-date with changes that are made to the code. This section presents a set of guidelines for that documentation.
619619
620620
### General guidelines
621621
622-
For the API documentation, the following general guidelines are recommended:
623-
624-
- Try to be as complete as possible with each item (classes, enums, public and protected members) in a file having a documentation string.
625-
- Try to minimize the vertical space. So, when possible, use a single line with `///` or `///<` for enum items (see below).
622+
- Be as complete as possible with each item (classes, enums, public and protected members) in a file having a documentation string.
623+
- Minimize the vertical space. So, when possible, use a single line with `///` or `///<` for enum items (see below).
626624
- In general, do not document C++ concepts such as destructors, friends, or constructors, except when there are arguments or if something special happens.
627625
628626
### Syntax
629627
630-
Doxygen supports two different types of syntax for commands with a backslash and with an `@` symbol, for example `\brief` and `@brief`. The latter is more prevalent in the FreeCAD source code and preferred.
628+
Doxygen supports two different types of syntax for commands, those with a backslash (e.g. `\brief`) and those with an `@` symbol (`@brief`). The `@`-prefixed version is more prevalent in the FreeCAD source code and is the preferred style for new documentation.
631629
632-
For a single line, for example commenting a function, we use `/// <your comment.` ending with a full stop without using `@brief`. Example:
630+
For a single line API documentation comment, for example commenting a function, use `/// <your comment.` without using `@brief` and ending with a full stop. Example:
633631
634632
```c++
635633
/// Get the transaction ID of this transaction.
636634
int getID() const;
637635
```
638636
639-
For multiple lines, we use `/**` to start the docstring. The documentation starts on the next line with a `@brief` command that ends with a full stop and then a line break. In the case below, there are details after which the `@param[in]` and `@return` commands document the parameters and return statement respectively.
637+
For multiple lines, use `/**` to start the docstring. The documentation starts on the next line with a `@brief` command that ends with a full stop and then a line break. In the case below, there are details after which the `@param[in]` and `@return` commands document the parameters and return statement, respectively.
640638
641639
```c++
642640
/**
@@ -651,7 +649,7 @@ For multiple lines, we use `/**` to start the docstring. The documentation star
651649
static bool isValidName(const char* name);
652650
```
653651
654-
If possible, it is advised to keep the number of added lines as low as possible. For example, you can use `///<` to keep the comments on the same line, for example in this Enum documentation:
652+
Keep the number of added lines to a minimum. For example, use `///<` to keep the comments on the same line:
655653
656654
```c++
657655
/// The status of the transaction object.
@@ -663,7 +661,7 @@ If possible, it is advised to keep the number of added lines as low as possible.
663661
} status {New};
664662
```
665663
666-
Use a single line to separate documentation of functions to make more clear to which function the documentation string belongs:
664+
Use a single line to separate the documentation of different functions to make clearer to which function the documentation string belongs:
667665
668666
```c++
669667
/// Generate a new unique transaction ID.
@@ -673,7 +671,7 @@ Use a single line to separate documentation of functions to make more clear to w
673671
static int getLastID();
674672
```
675673
676-
To prevent doxygen to automatically create a link you can use the `%` prefix. For example, since we have a namespace `Base` in FreeCAD, we use `%Base` in the example below to prevent Doxygen to create a link here to the `Base` package:
674+
To prevent Doxygen from automatically creating an irrelevant or undesired link use a `%` prefix. For example, since there is a namespace `Base` in FreeCAD, use `%Base` as shown in the example below to prevent Doxygen to create a link here to the `Base` package:
677675
678676
```c++
679677
/**
@@ -685,7 +683,7 @@ To prevent doxygen to automatically create a link you can use the `%` prefix. F
685683
*/
686684
```
687685
688-
It is possible to use Markdown syntax in doc comments. In the example below, we make use of a Markdown list:
686+
It is possible to use Markdown syntax in doc comments. For example, a Markdown list:
689687
690688
```c++
691689
/**
@@ -705,7 +703,7 @@ It is possible to use Markdown syntax in doc comments. In the example below, we
705703
706704
### Placing API documentation
707705
708-
The main page of the API documentation is in `src/Doc/mainpage.dox.in`. The most important function of this page is arguably the "Organization of the API Documentation" section that allows you to quickly browse important topics.
706+
The main page of the API documentation is in `src/Doc/mainpage.dox.in`. The most important function of this page is the "Organization of the API Documentation" section allowing readers to quickly browse important topics.
709707
710708
Topics should be defined in dedicated `.dox` files in the main directory of a package. For example, `src/App/core-app.dox` defines a group `APP` that is in group `CORE` (defined in the main page) and then it defines several topics in `APP`, such as `DocumentGroup` (for the concept of a Document in FreeCAD), `DocumentObjectGroup` (for the concept of a document object), etc. Below are two excerpts from that file to give an indication:
711709
@@ -758,15 +756,15 @@ class AppExport Document: public PropertyContainer
758756
...
759757
```
760758
761-
Documentation strings can be added to classes, enums, and public and protected members of a class. This is highly valued if a class is at the top of a hierarchy and its methods are reused in many other subclasses. The documentation should be added in the header file and not in the C++ file.
759+
Documentation strings can be added to classes, enums, and public and protected members of a class. This is especially important if a class is at the top of a hierarchy and its methods are reused in many other subclasses. The documentation should be added in the header file and not in the C++ file.
762760
763761
### Specific guidelines
764762
765763
This section contains guidelines for specific types of documentation.
766764
767765
#### Namespaces
768766
769-
Since namespace statements are typically in many files, it is difficult to determine where to put documentation strings. The recommendation is to add them to the `.dox` file of the respective package. For example, in `src/App/core-app.dox` we have:
767+
Since namespace statements are typically in many files, it is difficult to determine where to put documentation strings. In most cases a best practice is to add them to the `.dox` file of the respective module. For example, in `src/App/core-app.dox`:
770768
771769
```c++
772770
/**
@@ -787,7 +785,7 @@ Since namespace statements are typically in many files, it is difficult to deter
787785
788786
#### Classes
789787
790-
For classes you can use a brief statement and more detailed comments:
788+
For classes use a brief statement and more detailed comments:
791789
792790
```c++
793791
/**
@@ -806,7 +804,7 @@ class AppExport Document: public PropertyContainer
806804
807805
#### Functions
808806
809-
For functions, you can use a brief statement, optionally more detailed comments and if applicable and the parameters are not trivial, `@param` statements marking the direction `[in]`, `[out]`, or `[in,out]`, a `@return` command and `@throws` command if applicable. An example:
807+
For functions, use a brief statement, optionally more detailed comments, and if applicable and the parameters are not trivial, `@param` statements marking the direction `[in]`, `[out]`, or `[in,out]`, a `@return` command and `@throws` command, if applicable. An example:
810808
811809
```c++
812810
/**
@@ -839,9 +837,9 @@ For enumerations, it often suffices to have a brief statement and a short commen
839837
840838
#### Grouping
841839
842-
Preferred is that a group starts with a documentation block `/**` with an `@name` command and an `@{` grouping command on the next line. The group is ended with `/// @}`.
840+
Special documentation comments can be used to indicate that some group of functions, variables, etc. are all part of some single conceptual grouping. A best practice is to start a group with a documentation block `/**` with an `@name` command and an `@{` grouping command on the next line. The group is ended with `/// @}`.
843841
844-
Often, FreeCAD source files contain grouping commands with normal comments instead of documentation comments, such as `// @{` and `// @}`. Since these comments are not documentation comments, this usage is incorrect and can lead to issues in rendering the documentation.
842+
Often, FreeCAD source files contain grouping commands with normal comments instead of documentation comments, such as `// @{` and `// @}`. Since these comments are not documentation comments, this usage is incorrect and can lead to issues in rendering the documentation. This usage should be avoided in new code, and corrected when encountered.
845843
846844
847845
```c++
@@ -880,7 +878,7 @@ Templates can be document with a `@tparam` command:
880878
881879
#### Documentation with much repetition
882880
883-
The preferred way to handle code with much repetition is to use `@copydoc` or `@copydetails`.
881+
The preferred way to handle code with significant repetition is to use `@copydoc` or `@copydetails`.
884882
885883
```c++
886884
/**
@@ -951,7 +949,7 @@ An example with `@copydetails`:
951949
void addExportType(const char* filter, const char* moduleName);
952950
```
953951
954-
Another way to handle documentation with a high degree of repetition is by grouping, although it is less preferred than using `@copydoc` or `@copydetails`.
952+
Another way to handle documentation with a high degree of repetition is by grouping, although in most cases it is a best practice to use `@copydoc` or `@copydetails` instead.
955953
956954
```c++
957955
/**

0 commit comments

Comments
 (0)