Skip to content

Commit 26a3730

Browse files
committed
doc: unify developer-notes and productivity header styles
1 parent eb13718 commit 26a3730

File tree

2 files changed

+35
-70
lines changed

2 files changed

+35
-70
lines changed

doc/developer-notes.md

Lines changed: 29 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Developer Notes
2-
===============
1+
# Developer Notes
32

43
<!-- markdown-toc start -->
54
**Table of Contents**
@@ -49,8 +48,7 @@ Developer Notes
4948

5049
<!-- markdown-toc end -->
5150

52-
Coding Style (General)
53-
----------------------
51+
## Coding Style (General)
5452

5553
Various coding styles have been used during the history of the codebase,
5654
and the result is not very consistent. However, we're now trying to converge to
@@ -60,8 +58,7 @@ commits.
6058

6159
Do not submit patches solely to modify the style of existing code.
6260

63-
Coding Style (C++)
64-
------------------
61+
## Coding Style (C++)
6562

6663
- **Indentation and whitespace rules** as specified in
6764
[src/.clang-format](/src/.clang-format). You can use the provided
@@ -171,8 +168,7 @@ public:
171168
} // namespace foo
172169
```
173170

174-
Coding Style (C++ functions and methods)
175-
--------------------
171+
### Coding Style (C++ functions and methods)
176172

177173
- When ordering function parameters, place input parameters first, then any
178174
in-out parameters, followed by any output parameters.
@@ -192,8 +188,7 @@ Coding Style (C++ functions and methods)
192188
non-optional in-out and output parameters should usually be references, as
193189
they cannot be null.
194190

195-
Coding Style (C++ named arguments)
196-
------------------------------
191+
### Coding Style (C++ named arguments)
197192

198193
When passing named arguments, use a format that clang-tidy understands. The
199194
argument names can otherwise not be verified by clang-tidy.
@@ -237,14 +232,11 @@ To run clang-tidy on the changed source lines:
237232
git diff | ( cd ./src/ && clang-tidy-diff -p2 -path ../build -j $(nproc) )
238233
```
239234

240-
Coding Style (Python)
241-
---------------------
235+
## Coding Style (Python)
242236

243237
Refer to [/test/functional/README.md#style-guidelines](/test/functional/README.md#style-guidelines).
244238

245-
246-
Coding Style (Doxygen-compatible comments)
247-
------------------------------------------
239+
## Coding Style (Doxygen-compatible comments)
248240

249241
Bitcoin Core uses [Doxygen](https://www.doxygen.nl/) to generate its official documentation.
250242

@@ -348,8 +340,7 @@ Linux: `sudo apt install doxygen graphviz`
348340

349341
MacOS: `brew install doxygen graphviz`
350342

351-
Development tips and tricks
352-
---------------------------
343+
## Development tips and tricks
353344

354345
### Compiling for debugging
355346

@@ -393,7 +384,7 @@ ln -s /path/to/project/root/src src
393384

394385
4. If your IDE has an option for this, change your breakpoints to use the file name only.
395386

396-
### `debug.log`
387+
### debug.log
397388

398389
If the code is behaving strangely, take a look in the `debug.log` file in the data directory;
399390
error and debugging messages are written there.
@@ -713,8 +704,7 @@ Additional resources:
713704
* [GCC Instrumentation Options](https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html)
714705
* [Google Sanitizers Wiki](https://github.com/google/sanitizers/wiki)
715706

716-
Locking/mutex usage notes
717-
-------------------------
707+
## Locking/mutex usage notes
718708

719709
The code is multi-threaded and uses mutexes and the
720710
`LOCK` and `TRY_LOCK` macros to protect data structures.
@@ -730,8 +720,7 @@ between the various components is a goal, with any necessary locking
730720
done by the components (e.g. see the self-contained `FillableSigningProvider` class
731721
and its `cs_KeyStore` lock for example).
732722

733-
Threads
734-
-------
723+
## Threads
735724

736725
- [Main thread (`bitcoind`)](https://doxygen.bitcoincore.org/bitcoind_8cpp.html#a0ddf1224851353fc92bfbff6f499fa97)
737726
: Started from `main()` in `bitcoind.cpp`. Responsible for starting up and
@@ -784,22 +773,19 @@ Threads
784773
- [ThreadI2PAcceptIncoming (`b-i2paccept`)](https://doxygen.bitcoincore.org/class_c_connman.html#a57787b4f9ac847d24065fbb0dd6e70f8)
785774
: Listens for and accepts incoming I2P connections through the I2P SAM proxy.
786775

787-
Development guidelines
788-
============================
776+
# Development guidelines
789777

790778
A few non-style-related recommendations for developers, as well as points to
791779
pay attention to for reviewers of Bitcoin Core code.
792780

793-
General Bitcoin Core
794-
----------------------
781+
## General Bitcoin Core
795782

796783
- New features should be exposed on RPC first, then can be made available in the GUI.
797784

798785
- *Rationale*: RPC allows for better automatic testing. The test suite for
799786
the GUI is very limited.
800787

801-
Logging
802-
-------
788+
## Logging
803789

804790
The macros `LogInfo`, `LogDebug`, `LogTrace`, `LogWarning` and `LogError` are available for
805791
logging messages. They should be used as follows:
@@ -837,8 +823,7 @@ Note that the format strings and parameters of `LogDebug` and `LogTrace`
837823
are only evaluated if the logging category is enabled, so you must be
838824
careful to avoid side-effects in those expressions.
839825

840-
General C++
841-
-------------
826+
## General C++
842827

843828
For general C++ guidelines, you may refer to the [C++ Core
844829
Guidelines](https://isocpp.github.io/CppCoreGuidelines/).
@@ -859,8 +844,7 @@ Common misconceptions are clarified in those sections:
859844

860845
- *Rationale*: This avoids memory and resource leaks, and ensures exception safety.
861846

862-
C++ data structures
863-
--------------------
847+
## C++ data structures
864848

865849
- Never use the `std::map []` syntax when reading from a map, but instead use `.find()`.
866850

@@ -953,8 +937,7 @@ int GetInt(Tabs tab)
953937
954938
*Rationale*: The comment documents skipping `default:` label, and it complies with `clang-format` rules. The assertion prevents firing of `-Wreturn-type` warning on some compilers.
955939
956-
Strings and formatting
957-
------------------------
940+
## Strings and formatting
958941
959942
- Use `std::string`, avoid C string manipulation functions.
960943
@@ -988,8 +971,7 @@ Strings and formatting
988971
checks. If a use of strings is sensitive to this, take care to check the string for embedded NULL characters first
989972
and reject it if there are any.
990973
991-
Shadowing
992-
--------------
974+
## Shadowing
993975
994976
Although the shadowing warning (`-Wshadow`) is not enabled by default (it prevents issues arising
995977
from using a different variable with the same name),
@@ -998,8 +980,7 @@ please name variables so that their names do not shadow variables defined in the
998980
When using nested cycles, do not name the inner cycle variable the same as in
999981
the outer cycle, etc.
1000982
1001-
Lifetimebound
1002-
--------------
983+
## Lifetimebound
1003984
1004985
The [Clang `lifetimebound`
1005986
attribute](https://clang.llvm.org/docs/AttributeReference.html#lifetimebound)
@@ -1008,8 +989,7 @@ potentially see a compile-time warning if the object has a shorter lifetime from
1008989
the invalid use of a temporary. You can use the attribute by adding a `LIFETIMEBOUND`
1009990
annotation defined in `src/attributes.h`; please grep the codebase for examples.
1010991
1011-
Threads and synchronization
1012-
----------------------------
992+
## Threads and synchronization
1013993
1014994
- Prefer `Mutex` type to `RecursiveMutex` one.
1015995
@@ -1110,13 +1090,11 @@ TRY_LOCK(cs_vNodes, lockNodes);
11101090
}
11111091
```
11121092
1113-
Scripts
1114-
--------------------------
1093+
## Scripts
11151094
11161095
Write scripts in Python or Rust rather than bash, when possible.
11171096
1118-
Source code organization
1119-
--------------------------
1097+
## Source code organization
11201098
11211099
- Implementation code should go into the `.cpp` file and not the `.h`, unless necessary due to template usage or
11221100
when performance due to inlining is critical.
@@ -1150,8 +1128,7 @@ namespace {
11501128

11511129
- *Rationale*: Avoids confusion about the namespace context.
11521130

1153-
GUI
1154-
-----
1131+
## GUI
11551132

11561133
- Do not display or manipulate dialogs in model code (classes `*Model`).
11571134

@@ -1172,8 +1149,7 @@ GUI
11721149
- *Rationale*: Blocking the GUI thread can increase latency, and lead to
11731150
hangs and deadlocks.
11741151

1175-
Subtrees
1176-
----------
1152+
## Subtrees
11771153

11781154
Several parts of the repository are subtrees of software maintained elsewhere.
11791155

@@ -1203,8 +1179,7 @@ The ultimate upstream of the few externally managed subtrees are:
12031179
- Used by leveldb for hardware acceleration of CRC32C checksums for data integrity.
12041180
- Upstream at https://github.com/google/crc32c ; maintained by Google.
12051181

1206-
Upgrading LevelDB
1207-
---------------------
1182+
## Upgrading LevelDB
12081183

12091184
Extra care must be taken when upgrading LevelDB. This section explains issues
12101185
you must be aware of.
@@ -1250,8 +1225,7 @@ would be to revert the upstream fix before applying the updates to Bitcoin's
12501225
copy of LevelDB. In general, you should be wary of any upstream changes affecting
12511226
what data is returned from LevelDB queries.
12521227

1253-
Scripted diffs
1254-
--------------
1228+
## Scripted diffs
12551229

12561230
For reformatting and refactoring commits where the changes can be easily automated using a bash script, we use
12571231
scripted-diff commits. The bash script is included in the commit message and our CI job checks that
@@ -1307,8 +1281,7 @@ To find all previous uses of scripted diffs in the repository, do:
13071281
git log --grep="-BEGIN VERIFY SCRIPT-"
13081282
```
13091283

1310-
Release notes
1311-
-------------
1284+
## Release notes
13121285

13131286
Release notes should be written for any PR that:
13141287

@@ -1321,8 +1294,7 @@ Release notes should be added to a PR-specific release note file at
13211294
`/doc/release-notes-<PR number>.md` to avoid conflicts between multiple PRs.
13221295
All `release-notes*` files are merged into a single `release-notes-<version>.md` file prior to the release.
13231296

1324-
RPC interface guidelines
1325-
--------------------------
1297+
## RPC interface guidelines
13261298

13271299
A few guidelines for introducing and reviewing new RPC interfaces:
13281300

@@ -1430,8 +1402,7 @@ A few guidelines for modifying existing RPC interfaces:
14301402

14311403
- *Rationale*: Changes in RPC JSON structure can break downstream application compatibility. Implementation of `deprecatedrpc` provides a grace period for downstream applications to migrate. Release notes provide notification to downstream users.
14321404

1433-
Internal interface guidelines
1434-
-----------------------------
1405+
## Internal interface guidelines
14351406

14361407
Internal interfaces between parts of the codebase that are meant to be
14371408
independent (node, wallet, GUI), are defined in

doc/productivity.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
Productivity Notes
2-
==================
1+
# Productivity Notes
32

4-
Table of Contents
5-
-----------------
3+
## Table of Contents
64

75
* [General](#general)
86
* [Cache compilations with `ccache`](#cache-compilations-with-ccache)
@@ -23,8 +21,7 @@ Table of Contents
2321
* [Reference PRs easily with `refspec`s](#reference-prs-easily-with-refspecs)
2422
* [Diff the diffs with `git range-diff`](#diff-the-diffs-with-git-range-diff)
2523

26-
General
27-
------
24+
## General
2825

2926
### Cache compilations with `ccache`
3027

@@ -114,8 +111,7 @@ This synergizes well with [`ccache`](#cache-compilations-with-ccache) as objects
114111

115112
You can also set up [upstream refspecs](#reference-prs-easily-with-refspecs) to refer to pull requests easier in the above `git worktree` commands.
116113

117-
Writing code
118-
------------
114+
## Writing code
119115

120116
### Format C/C++ diffs with `clang-format-diff.py`
121117

@@ -125,8 +121,7 @@ See [contrib/devtools/README.md](/contrib/devtools/README.md#clang-format-diff.p
125121

126122
Usage is exactly the same as [`clang-format-diff.py`](#format-cc-diffs-with-clang-format-diffpy). You can get it [here](https://github.com/MarcoFalke/yapf-diff).
127123

128-
Rebasing/Merging code
129-
-------------
124+
## Rebasing/Merging code
130125

131126
### More conflict context with `merge.conflictstyle diff3`
132127

@@ -154,8 +149,7 @@ theirs
154149

155150
This may make it much clearer what caused the conflict. In this style, you can often just look at what changed between *original* and *theirs*, and mechanically apply that to *yours* (or the other way around).
156151

157-
Reviewing code
158-
--------------
152+
## Reviewing code
159153

160154
### Reduce mental load with `git diff` options
161155

0 commit comments

Comments
 (0)