About this guide
-~~~~~~~~~~~~~~~~
+----------------
Purpose of this style guide is to encourage use of common coding practices within the ESP-IDF.
When doing modifications to third-party code used in ESP-IDF, follow the way that particular project is written. That will help propose useful changes for merging into upstream project.
C code formatting
-~~~~~~~~~~~~~~~~~
+-----------------
Indentation
------------
+^^^^^^^^^^^
Use 4 spaces for each indentation level. Don't use tabs for indentation. Configure the editor to emit 4 spaces each time you press tab key.
Vertical space
---------------
+^^^^^^^^^^^^^^
Place one empty line between functions. Don't begin or end a function with an empty line.
::
}
Horizontal space
-----------------
+^^^^^^^^^^^^^^^^
Always add single space after conditional and loop keywords::
Braces
-------
+^^^^^^
- Function definition should have a brace on a separate line::
if (condition) {
do_one();
- }
- else if (other_condition) {
+ } else if (other_condition) {
do_two();
}
Comments
---------
+^^^^^^^^
Use ``//`` for single line comments. For multi-line comments it is okay to use either ``//`` on each line or a ``/* */`` block.
Formatting your code
---------------------
+^^^^^^^^^^^^^^^^^^^^
You can use ``astyle`` program to format your code according to the above recommendations.
tools/format.sh components/my_component/file.c
+Documenting code
+----------------
+
+Please see the guide here: `Documenting Code <documenting-code.rst>`_.
+
Structure and naming
-~~~~~~~~~~~~~~~~~~~~
+--------------------
+
-To be written.
Language features
-~~~~~~~~~~~~~~~~~
+-----------------
To be written.