Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Licensed under the Apache-2.0 license
# SPDX-License-Identifier: Apache-2.0

# Documentation for this configuration is here:
# https://releases.llvm.org/6.0.0/tools/clang/docs/ClangFormatStyleOptions.html

BasedOnStyle: Google
IndentWidth: 4
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
DerivePointerAlignment: false
PointerAlignment: Right

IncludeCategories:
- # System Headers: #include <*>
Regex: '^<.*>$'
Priority: 1
- # All Other Headers
Regex: '.*'
Priority: 2
1 change: 1 addition & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# Developer Guide

* [Architecture](./architecture.md)
* [Coding Style](./coding-style.md)
* [Contributing](./contributing.md)
* [Design](./design/README.md)
* [Digest Driver for Hubris](./design/driver-hubris-hash.md)
Expand Down
39 changes: 39 additions & 0 deletions docs/src/coding-style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Coding Style
Comment thread
cfrantz marked this conversation as resolved.
Comment thread
cfrantz marked this conversation as resolved.

This document describes the coding style used by this project.
All of the formatters can be invoked by the `pw` utility script in the root of
the project:

```
$ ./pw format
```

## Rust

This project follows the standard [Rust Style
Guide](https://doc.rust-lang.org/style-guide/) for Rust code. Formatting is
done with `rustfmt` using the
[`rustfmt.toml`](https://github.com/pigweed-project/pigweed/blob/main/rustfmt.toml)
from the upstream [Pigweed](https://github.com/pigweed-project/pigweed/) repository.

## Python

This project follows [PEP8](https://peps.python.org/pep-0008/) for Python code.
Formatting is done with the `black` formatter.

## Starlark (bazel build system)

This project follows the standard [bzl style
guide](https://bazel.build/rules/bzl-style) for Starlark code.
Formatting is done with the `buildifier` tool.

## C / C++

This project follows the [Google C++ Style Guide] for C and C++ code, with the
following exceptions:
- Indent is 4 spaces instead of 2.
- Function names should use `snake_case` instead of `PascalCase`.
- In pointer declarations, the asterisk is attached to the variable name (`int
*foo`) instead of the type name (`int* foo`).

Formatting is done with `clang-format`.
2 changes: 1 addition & 1 deletion docs/src/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The code of conduct can be found [here](https://github.com/OpenPRoT/.github/blob

## Code Style

- Use `cargo xtask fmt` to format code
- Follow the [coding style](coding-style.md) guide.
- Run `cargo xtask clippy` to check for lints
- Ensure all tests pass with `cargo xtask test`

Expand Down
Loading