Skip to content

Commit

Permalink
Move Coding style from wiki to main repo.
Browse files Browse the repository at this point in the history
This is the last page to migrate, which enables disabling the wiki completely.

Add links to markdown google style guide.

[email protected]
BUG=

Review-Url: https://codereview.chromium.org/2017433002
  • Loading branch information
maruel authored and Commit bot committed May 25, 2016
1 parent 9709eb0 commit 2e2cd9a
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
80 changes: 80 additions & 0 deletions CODING_STYLE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Coding style

For Markdown, use the [Google
style](https://github.com/google/styleguide/blob/gh-pages/docguide/style.md).


## General style

* ALL_CAPS_GLOBALS at top
* function_name
* ClassName
* variable_name
* +2 space indent, a legacy from Google
* 2 empty lines between file level symbols
* 1 empty line between class members


## Line breaks

Keep line width under 80 chars. Break a line on a first syntactic structure,
prefer hanging indent of 4 spaces over vertical alignment. Prefer parentheses
for line joining over `\`. For JSON-like nested dicts and lists it's acceptable
to use 2 space indent.

Yes:

str = (
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam diam met, '
'tristique ac placerat sit amet: %s, %s' % (a, b))

func_call(
param1=...,
param2=...,
param3=...)

like_json = {
'key': {
'a': {
'b': 123,
'c': 123,
'd': 123,
},
},
}

No:

str = \
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam diam met, '

str = ('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam diam '
'met, ....')

func_call(param1=...,
param2=...,
param3=...)

fun_call(param1=..., param2=...,
param3=...)


## Import statements

* import modules, not symbols.
* `from X import Y` statements, then `import X` statements within a single block


Separations:

<import block of stdlib>

<import block of import sys.path hack, e.g. test_env. Needed for now>

<import block of appengine lib>

<import block of appengine third_party lib, e.g. webapp2, or in third_party/>

<import block of components and other application external libs>

<import block of application libs>
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ A complete CI toolkit:
## Contributing

* Sign the [Google CLA](https://cla.developers.google.com/clas).
* See the [coding style](CODING_STYLE.md).
* Make sure your `user.email` and `user.name` are configured in `git config`.

Run the following to setup the code review tool and create your first review:
Expand Down

0 comments on commit 2e2cd9a

Please sign in to comment.