Code style
License
- Licenses: All Carbon files outside of
third_party/should have a license following CONTRIBUTING license instructions.
Formatting
- Bazel: Use
pre-commit run buildifier --files <file.bzl>to format Bazel files. - C++: Use
pre-commit run clang-format --files <file.cpp>to format C++ files. - Carbon: The toolchain's
formatcommand doesn't work well right now. Instead, try to format Carbon code based on other Carbon files and the C++ style. - Markdown: Use
pre-commit run prettier --files <file.md>to format markdown files. - Python: Use
pre-commit run black --files <file.py>to format Python files.
Style Guides
- C++ style: Follow the Carbon C++ Project Style Guide.
- Markdown style: Follow the Google developer documentation style guide.
- Python style: Follow the PEP 8
style guide.
- Wrap code and comments to 80 columns.
- Run
pre-commit run flake8 --files <file.py>to check Python style.