1 # Chromium coding style
5 * [Chromium C++ style guide](c++/c++.md)
6 * [Chromium Objective-C style guide](objective-c/objective-c.md)
7 * [Java style guide for Android](java/java.md)
8 * [GN style guide](../tools/gn/docs/style_guide.md) for build files
10 Chromium also uses these languages to a lesser degree:
12 * [Kernel C style](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle?id=refs/heads/master) for ChromiumOS firmware.
13 * [IDL](https://sites.google.com/a/chromium.org/dev/blink/webidl#TOC-Style)
14 * [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.
16 Regardless of the language used, please keep code [gender neutral](gender_neutral_code.md).
20 Python code should follow [PEP-8](https://www.python.org/dev/peps/pep-0008/),
23 * Use two-space indentation instead of four-space indentation.
24 * Use `CamelCase()` method and function names instead of `unix_hacker_style()` names.
26 (The rationale for these is mostly legacy: the code was originally written
27 following Google's internal style guideline, the cost of updating all of the
28 code to PEP-8 compliance was not small, and consistency was seen to be a
29 greater virtue than compliance.)
31 [Depot tools](http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools.html)
32 contains a local copy of pylint, appropriately configured.
34 Note that asserts are of limited use, and should not be used for validating
35 input – throw an exception instead. Asserts can be used for validating program
36 logic, especially use of interfaces or invariants (e.g., asserting that a
37 function is only called with dictionaries that contain a certain key). [See
39 Effectively](https://wiki.python.org/moin/UsingAssertionsEffectively).
41 See also the [Chromium OS Python Style
42 Guidelines](https://sites.google.com/a/chromium.org/dev/chromium-os/python-style-guidelines).
44 ## Web languages (JavaScript, HTML, CSS)
46 When working on Web-based UI features, consult the [Web Development Style Guide](web/web.md) for the Chromium conventions used in JS/CSS/HTML files.
48 Internal uses of web languages, notably "layout" tests, should preferably follow these style guides, but it is not enforced.