Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Unified Diff: styleguide/styleguide.md

Issue 2127713004: Add C++ style guide to repo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« styleguide/c++/c++.md ('K') | « styleguide/c++/c++.md ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: styleguide/styleguide.md
diff --git a/styleguide/styleguide.md b/styleguide/styleguide.md
new file mode 100644
index 0000000000000000000000000000000000000000..e9132dadb744bbbbf9931d5ccf50379622f4eabf
--- /dev/null
+++ b/styleguide/styleguide.md
@@ -0,0 +1,47 @@
+# Chromium coding style
+
+## Main style guides
+
+ * [Chromium C++ style guide](https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md)
jbroman 2016/07/06 19:38:03 Since this file is also in this repo, shouldn't a
+ * [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 langauges (JavaScript, HTML, CSS)
jbroman 2016/07/06 19:38:03 spelling: "languages"
+
+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.
« styleguide/c++/c++.md ('K') | « styleguide/c++/c++.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698