Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.56 KB

STYLE_GUIDE.md

File metadata and controls

54 lines (40 loc) · 1.56 KB

C++

C++ code should conform to Google C++ Style Guide.

Addons uses clang-format to check your C/C++ changes. Sometimes you have some manually formatted code that you don’t want clang-format to touch. You can disable formatting like this:

int formatted_code;
// clang-format off
    void    unformatted_code  ;
// clang-format on
void formatted_code_again;

Install Clang-format 9 with:

wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository -u 'http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
sudo apt install clang-format-9

format all with:

clang-format-9 -i --style=google **/*.cc **/*.h

Python

Addons uses flake8 to check pep8 compliance and code analysis.

Addons use Black to format our code. The continuous integration check will fail if you do not use it.

Install them with:

pip install flake8 black

Be sure to run them both before you push your commits, otherwise the CI will fail!

python -m black ./
python -m flake8

TensorFlow Conventions

Follow the guidance in the TensorFlow Style Guide - Conventions.

Please note that Addons follows the conventions of the TensorFlow library, but formats our code using PEP8 guidelines.