Each commit message should start with a directory or full file path prefix, so it was clear which part of codebase a commit affects. If a change affects one file, it's better to use path to a file. If it affects few files in a subdirectory, using subdirectory as a prefix is ok. For longish paths, it's acceptable to drop intermediate components, which still should provide good context of a change. It's also ok to drop file extensions.
Besides prefix, first line of a commit message should describe a change clearly and to the point, and be a grammatical sentence with final full stop. First line should fit within 78 characters. Examples of good first line of commit messages:
py/objstr: Add splitlines() method. py: Rename FOO to BAR. docs/machine: Fix typo in reset() description. ports: Switch to use lib/foo instead of duplicated code.
After the first line, add an empty line and in following lines describe a change in a detail, if needed. Any change beyond 5 lines would likely require such detailed description.
To get good practical examples of good commits and their messages, browse the git log
of the project.
MicroPython doesn't require explicit sign-off for patches ("Signed-off-by" lines and similar). Instead, the commit message, and your name and email address on it construes your sign-off of the following:
Python code follows PEP 8.
Naming conventions:
When writing new C code, please adhere to the following conventions.
White space:
Braces:
Header files:
Names:
Integer types: MicroPython runs on 16, 32, and 64 bit machines, so it's important to use the correctly-sized (and signed) integer types. The general guidelines are:
Comments:
//
prefix, NOT /* ... */
. No extra fluff.Memory allocation:
Braces, spaces, names and comments:
#define TO_ADD (123) // This function will always recurse indefinitely and is only used to show // coding style int foo_function(int x, int some_value) { if (x < some_value) { foo(some_value, x); } else { foo(x + TO_ADD, some_value - 1); } for (int my_counter = 0; my_counter < x; my_counter++) { } }
Type declarations:
typedef struct _my_struct_t { int member; void *data; } my_struct_t;
MicroPython generally follows CPython in documentation process and conventions. reStructuredText syntax is used for the documention.
Specific conventions/suggestions:
*
markup to refer to arguments of a function, e.g.:.. method:: poll.unregister(obj) Unregister *obj* from polling.
:func:`foo` - function foo in current module :func:`module1.foo` - function foo in module "module1" (similarly for other referent types) :class:`Foo` - class Foo :meth:`Class.method1` - method1 in Class :meth:`~Class.method1` - method1 in Class, but rendered just as "method1()", not "Class.method1()" :meth:`title <method1>` - reference method1, but render as "title" (use only if really needed) :mod:`module1` - module module1 `symbol` - generic xref syntax which can replace any of the above in case the xref is unambiguous. If there's ambiguity, there will be a warning during docs generation, which need to be fixed using one of the syntaxes above
.. _xref_target: Normal non-indented text. This is :ref:`reference <xref_target>`. (If xref target is followed by section title, can be just :ref:`xref_target`).
`link text <http://foo.com/...>`_
``None``, ``True``, ``False``
.. function:: foo(x) bar(y) Description common to foo() and bar().
More detailed guides and quickrefs: