Skip to content

Commit ceb789c

Browse files
committed
Merge #17873: doc: Add to Doxygen documentation guidelines
c902c4c doc: Add to Doxygen documentation guidelines (Jon Layton) Pull request description: Completes the up-for-grabs PR #16948. Changes can be tested here: [doc/developer-notes.md](https://github.com/jonatack/bitcoin/blob/doxygen-developer-notes-improvements/doc/developer-notes.md) Co-authored-by: Jon Layton <[email protected]> ACKs for top commit: fanquake: ACK c902c4c - quick read, checked the new links work. laanwj: ACK c902c4c Tree-SHA512: 3b4cebba23061ad5243b2288c2006bf8527e74c689223825f96a44014875d15b2ab6ff54b8aa342ca657a14cf6ce3ab7d6e25bea5befd91162bc2645a74ddb7e
2 parents a4a93a0 + c902c4c commit ceb789c

File tree

1 file changed

+55
-17
lines changed

1 file changed

+55
-17
lines changed

doc/developer-notes.md

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Developer Notes
99
- [Coding Style (C++)](#coding-style-c)
1010
- [Coding Style (Python)](#coding-style-python)
1111
- [Coding Style (Doxygen-compatible comments)](#coding-style-doxygen-compatible-comments)
12+
- [Generating Documentation](#generating-documentation)
1213
- [Development tips and tricks](#development-tips-and-tricks)
1314
- [Compiling for debugging](#compiling-for-debugging)
1415
- [Compiling for gprof profiling](#compiling-for-gprof-profiling)
@@ -35,6 +36,9 @@ Developer Notes
3536
- [Source code organization](#source-code-organization)
3637
- [GUI](#gui)
3738
- [Subtrees](#subtrees)
39+
- [Upgrading LevelDB](#upgrading-leveldb)
40+
- [File Descriptor Counts](#file-descriptor-counts)
41+
- [Consensus Compatibility](#consensus-compatibility)
3842
- [Scripted diffs](#scripted-diffs)
3943
- [Suggestions and examples](#suggestions-and-examples)
4044
- [Release notes](#release-notes)
@@ -138,12 +142,17 @@ For example, to describe a function use:
138142

139143
```c++
140144
/**
141-
* ... text ...
142-
* @param[in] arg1 A description
143-
* @param[in] arg2 Another argument description
144-
* @pre Precondition for function...
145+
* ... Description ...
146+
*
147+
* @param[in] arg1 input description...
148+
* @param[in] arg2 input description...
149+
* @param[out] arg3 output description...
150+
* @return Return cases...
151+
* @throws Error type and cases...
152+
* @pre Pre-condition for function...
153+
* @post Post-condition for function...
145154
*/
146-
bool function(int arg1, const char *arg2)
155+
bool function(int arg1, const char *arg2, std::string& arg3)
147156
```
148157
149158
A complete list of `@xxx` commands can be found at http://www.doxygen.nl/manual/commands.html.
@@ -158,44 +167,73 @@ To describe a class, use the same construct above the class definition:
158167
* @see GetWarnings()
159168
*/
160169
class CAlert
161-
{
162170
```
163171

164172
To describe a member or variable use:
165173
```c++
166-
int var; //!< Detailed description after the member
174+
//! Description before the member
175+
int var;
167176
```
168177

169178
or
170179
```c++
171-
//! Description before the member
172-
int var;
180+
int var; //!< Description after the member
173181
```
174182

175183
Also OK:
176184
```c++
177185
///
178-
/// ... text ...
186+
/// ... Description ...
179187
///
180188
bool function2(int arg1, const char *arg2)
181189
```
182190
183-
Not OK (used plenty in the current source, but not picked up):
191+
Not picked up by Doxygen:
184192
```c++
185193
//
186-
// ... text ...
194+
// ... Description ...
187195
//
188196
```
189197

198+
Also not picked up by Doxygen:
199+
```c++
200+
/*
201+
* ... Description ...
202+
*/
203+
```
204+
190205
A full list of comment syntaxes picked up by Doxygen can be found at http://www.doxygen.nl/manual/docblocks.html,
191206
but the above styles are favored.
192207

193-
Documentation can be generated with `make docs` and cleaned up with `make clean-docs`. The resulting files are located in `doc/doxygen/html`; open `index.html` to view the homepage.
208+
Recommendations:
194209

195-
Before running `make docs`, you will need to install dependencies `doxygen` and `dot`. For example, on macOS via Homebrew:
196-
```
197-
brew install graphviz doxygen
198-
```
210+
- Avoiding duplicating type and input/output information in function
211+
descriptions.
212+
213+
- Use backticks (&#96;&#96;) to refer to `argument` names in function and
214+
parameter descriptions.
215+
216+
- Backticks aren't required when referring to functions Doxygen already knows
217+
about; it will build hyperlinks for these automatically. See
218+
http://www.doxygen.nl/manual/autolink.html for complete info.
219+
220+
- Avoid linking to external documentation; links can break.
221+
222+
- Javadoc and all valid Doxygen comments are stripped from Doxygen source code
223+
previews (`STRIP_CODE_COMMENTS = YES` in [Doxyfile.in](doc/Doxyfile.in)). If
224+
you want a comment to be preserved, it must instead use `//` or `/* */`.
225+
226+
### Generating Documentation
227+
228+
The documentation can be generated with `make docs` and cleaned up with `make
229+
clean-docs`. The resulting files are located in `doc/doxygen/html`; open
230+
`index.html` in that directory to view the homepage.
231+
232+
Before running `make docs`, you'll need to install these dependencies:
233+
234+
Linux: `sudo apt install doxygen graphviz`
235+
236+
MacOS: `brew install doxygen graphviz`
199237

200238
Development tips and tricks
201239
---------------------------

0 commit comments

Comments
 (0)