Skip to content

Commit 17dafd5

Browse files
facaiyseanpmorgan
authored andcommitted
introduction about coding style (#69)
* DOC: introduction about coding style
1 parent 6d63531 commit 17dafd5

File tree

3 files changed

+54
-5
lines changed

3 files changed

+54
-5
lines changed

CONTRIBUTING.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ us**
5151
## Development Environment
5252
It is recommended that development is done in the latest
5353
`nightly-custom-op` docker image.
54-
```
54+
55+
```bash
5556
docker run --rm -it -v ${PWD}:/addons -w /addons tensorflow/tensorflow:nightly-custom-op /bin/bash
5657
```
5758

@@ -62,6 +63,12 @@ Try those commands below:
6263
2. Run unit test: `make unit-test`
6364
3. All of the above: `make`
6465

66+
## Coding style
67+
68+
Addons provides `make code-format` command to format your changes
69+
automatically, don't forget to use it before pushing your codes.
70+
71+
Please see our [Style Guide](SYLE_GUIDE.md) for more details.
6572

6673
## Code Testing
6774
#### CI Testing
@@ -71,13 +78,15 @@ hardware will be available from our CI provider.
7178

7279
#### Locally Testing
7380

74-
```
81+
```bash
7582
docker run --rm -it -v ${PWD}:/addons -w /addons tensorflow/tensorflow:nightly-custom-op make unit-test
7683
```
7784

7885
or run manually:
7986

80-
```
87+
```bash
88+
docker run --rm -it -v ${PWD}:/addons -w /addons tensorflow/tensorflow:nightly-custom-op /bin/bash
89+
8190
./configure.sh # Links project with TensorFlow dependency
8291

8392
bazel test -c opt -k \

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ pip install artifacts/tensorflow_addons-*.whl
7373
## Contributing
7474
TF-Addons is a community led open source project. As such, the project
7575
depends on public contributions, bug-fixes, and documentation. Please
76-
see [CONTRIBUTING.md](CONTRIBUTING.md) for a guide on how to contribute.
77-
This project adheres to [TensorFlow's code of conduct](CODE_OF_CONDUCT.md).
76+
see [contribution guidelines](CONTRIBUTING.md) for a guide on how to
77+
contribute. This project adheres to [TensorFlow's code of conduct](CODE_OF_CONDUCT.md).
7878
By participating, you are expected to uphold this code.
7979

8080
## Community

STYLE_GUIDE.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#### C++
2+
C++ code should conform to [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
3+
4+
Addons uses [clang-format](https://clang.llvm.org/docs/ClangFormat.html)
5+
to check your C/C++ changes. Sometimes you have some manually formatted
6+
code that you don’t want clang-format to touch.
7+
You can disable formatting like this:
8+
9+
```cpp
10+
int formatted_code;
11+
// clang-format off
12+
void unformatted_code ;
13+
// clang-format on
14+
void formatted_code_again;
15+
```
16+
17+
#### Python
18+
Python code should conform to [PEP8](https://www.python.org/dev/peps/pep-0008/).
19+
20+
Addons uses [yapf](https://github.com/google/yapf) to format code,
21+
and [pylint](https://www.pylint.org/) for code analysis.
22+
You can disable them locally like this:
23+
24+
```python
25+
# yapf: disable
26+
FOO = {
27+
# ... some very large, complex data literal.
28+
}
29+
30+
BAR = [
31+
# ... another large data literal.
32+
]
33+
# yapf: enable
34+
```
35+
36+
```python
37+
# pylint: disable=protected-access
38+
foo._protected_member
39+
# pylint: enable=protected-access
40+
```

0 commit comments

Comments
 (0)