Commit f0e606a5 authored by brettw's avatar brettw Committed by Commit bot

Add C++ style guide to repo.

This is a Markdown conversion of https://www.chromium.org/developers/coding-style

This separates out the language-independent parts from the C++-specific parts.

The C++ portion is mostly the same as the web page with the following updates:
 - New stuff at the top that references clang format and style update process.
 - The sections on ?: and function parameter ordering were deleted. The advice was long and detailed and seems to contradict Clang format.
 - Converted scoped_ptr to unique_ptr
 - Removed the one-line section on return values vs out params as it didn't seem to add much.
 - Removed the list of platform-specific ifdefs. Some were out-of-date, and "use the ones from build_config.h" seems sufficient for the style guide.

Review-Url: https://codereview.chromium.org/2127713004
Cr-Commit-Position: refs/heads/master@{#403954}
parent 47dc4a53
This diff is collapsed.
# Chromium coding style
## Main style guides
* [Chromium C++ style guide](c++/c++.md)
* [Google Objective-C style guide](https://google.github.io/styleguide/objcguide.xml)
* [Java style guide for Android](https://sites.google.com/a/chromium.org/dev/developers/coding-style/java)
* [GN style guide](https://chromium.googlesource.com/chromium/src/+/master/tool) for build files
Chromium also uses these languages to a lesser degree:
* [Kernel C style](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle?id=refs/heads/master) for ChromiumOS firmware.
* [IDL](https://sites.google.com/a/chromium.org/dev/blink/webidl#TOC-Style)
* [Jinja style guide](https://sites.google.com/a/chromium.org/dev/developers/jinja#TOC-Style) for [Jinja](https://sites.google.com/a/chromium.org/dev/developers/jinja) templates.
## Python
Python code should follow [PEP-8](https://www.python.org/dev/peps/pep-0008/),
except:
* Use two-space indentation instead of four-space indentation.
* Use `CamelCase()` method and function names instead of
* `unix_hacker_style()` names.
(The rationale for these is mostly legacy: the code was originally written
following Google's internal style guideline, the cost of updating all of the
code to PEP-8 compliance was not small, and consistency was seen to be a
greater virtue than compliance.)
[Depot tools](http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools.html)
contains a local copy of pylint, appropriately configured.
Note that asserts are of limited use, and should not be used for validating
input – throw an exception instead. Asserts can be used for validating program
logic, especially use of interfaces or invariants (e.g., asserting that a
function is only called with dictionaries that contain a certain key). [See
Using Assertions
Effectively](https://wiki.python.org/moin/UsingAssertionsEffectively).
See also the [Chromium OS Python Style
Guidelines](https://sites.google.com/a/chromium.org/dev/chromium-os/python-style-guidelines).
## Web languages (JavaScript, HTML, CSS)
When working on Web-based UI features, consult the [Web Development Style Guide](https://sites.google.com/a/chromium.org/dev/developers/web-development-style-guide) for the Chromium conventions used in JS/CSS/HTML files.
Internal uses of web languages, notably "layout" tests, should preferably follow these style guides, but it is not enforced.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment