diff options
author | mark@chromium.org <mark@chromium.org@955884f1-7149-0410-9467-59e7ac3f4d80> | 2013-03-21 16:03:26 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@955884f1-7149-0410-9467-59e7ac3f4d80> | 2013-03-21 16:03:26 +0000 |
commit | 8190c132fd0560e7dffd212efb53077a3e2315aa (patch) | |
tree | 5e16921eb4c776e855098de3ba20275e1d285d94 /javascriptguide.xml | |
parent | 7cf216c97672442bb812e79dfd5d2daae72986db (diff) | |
download | google-styleguide-8190c132fd0560e7dffd212efb53077a3e2315aa.tar.gz |
Update C++ style guide to 3.245:
- Relax the rule for sizeof(varname) vs. sizeof(type).
- Allow an exception for nonconst reference parameters where
convention dictates their use, such as for swap.
- C++11: allow static_assert.
- Require non-trivial fall-through between cases in switch
statements to be annotated. Trivial fall-through includes
consecutive case labels with no intervening code, and no comment
is required in these cases.
- C++11: allow constexpr.
- Revise the "Integer Types" section to note type-width problems.
- Clarify that the "arguments on subsequent lines" function call
style is acceptable even when the 80-column limit doesn't require
it.
- Boost: allow part of Polygon.
- C++11: allow <tuple>.
Update Objective-C style guide to 2.52:
- Fix ARC example to not imply the use of @private in .m files.
- Add an example to the "Category Names" section.
- Require that ARC-using files insert preprocessor directives that
generate an error when compiling without ARC.
- Fix spacing around the *s in the ARC example per the C++ style
guide.
Update Python style guide to 2.48:
- Allow comments with URLs to exceed 80 characters per line.
- Update outdated implicit-line-joining URLs.
Update HTML/CSS style guide to 2.21:
- Consistent use of title case.
- Add new "Declaration Block Separation" section.
- Add a CSS example to the "Capitalization" section.
- Minor fixes to whitespace.
Update JavaScript style to guide to 2.72:
- Make it clear that the injunction against aliasing namespaces only
applies to local aliases, not goog.scope.
- Clarify the style guide's recommendation on array/object literals.
- Add documentation on @private {type}, @protected {type}, and
@const {type}.
- Make JSDoc descriptions required only if not obvious.
- Clarify that only private properties and methods need a trailing
underscore.
- Fix spelling of arv's name.
Update Common Lisp style guide to 1.18:
- Macro-defining macros are harder to understand for everyone, not
just for the "uninitiated." There's no need to condescend.
In all of the above style guides:
- The guide source is now encoded as UTF-8. The numeric character
references have been replaced with raw UTF-8-encoded characters.
Diffstat (limited to 'javascriptguide.xml')
-rw-r--r-- | javascriptguide.xml | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/javascriptguide.xml b/javascriptguide.xml index 32e9e63..282f8b7 100644 --- a/javascriptguide.xml +++ b/javascriptguide.xml @@ -3,14 +3,14 @@ <GUIDE title="Google JavaScript Style Guide"> <p class="revision"> - Revision 2.64 + Revision 2.72 </p> <address> Aaron Whyte<br/> Bob Jervis<br/> Dan Pupius<br/> - Eric Arvidsson<br/> + Erik Arvidsson<br/> Fritz Schneider<br/> Robby Walker<br/> </address> @@ -96,7 +96,7 @@ <code>boolean</code>) are constant values.</p> <p><code>Objects</code>' - immutabilty is more subjective — objects should be + immutabilty is more subjective — objects should be considered immutable only if they do not demonstrate obeserverable state change. This is not enforced by the compiler.</p> @@ -729,11 +729,10 @@ <BODY> <SUBSECTION title="Properties and methods"> <ul> - <li><em>Private</em> properties, variables, and methods (in files - or classes) should be named with a trailing - underscore. + <li><em>Private</em> properties and methods should be named with a + trailing underscore. </li> - <li><em>Protected</em> properties, variables, and methods should be + <li><em>Protected</em> properties and methods should be named without a trailing underscore (like public ones).</li> </ul> <p>For more information on <em>private</em> and <em>protected</em>, @@ -892,7 +891,8 @@ staticHelper(new MyClass()); }; </CODE_SNIPPET> - <p>Do not alias namespaces.</p> + <p>Do not create local aliases of namespaces. Namespaces should only + be aliased using <a href="#goog-scope">goog.scope</a>.</p> <BAD_CODE_SNIPPET> myapp.main = function() { var namespace = some.long.namespace; @@ -999,7 +999,7 @@ var obj = {a: 1, b: 2, c: 3}; // No space after { or before }. </CODE_SNIPPET> <p>Multiline array initializers and object initializers are indented - 2 spaces, just like blocks.</p> + 2 spaces, with the braces on their own line, just like blocks.</p> <CODE_SNIPPET> // Object initializer. var inset = { @@ -1127,6 +1127,7 @@ </CODE_SNIPPET> </SUBSECTION> <SUBSECTION title="Aliasing with goog.scope"> + <a name="goog-scope"/> <p> <a href="https://docs.google.com/document/pub?id=1ETFAuh2kaXMVL-vafUYhaWlhl6b5D9TOvboVg7Zl68Y"><code>goog.scope</code></a> may be used to shorten references to @@ -2204,7 +2205,10 @@ <p>All files, classes, methods and properties should be documented with <a href="http://code.google.com/p/jsdoc-toolkit/">JSDoc</a> comments with the appropriate <a href="#JSDoc_Tag_Reference">tags</a> - and <a href="#JsTypes">types</a>.</p> + and <a href="#JsTypes">types</a>. Textual descriptions for methods, + method parameters and method return values should be included + unless obvious from the method or parameter name. + </p> <p>Inline comments should be of the <code>//</code> variety.</p> @@ -2438,15 +2442,15 @@ <tr> <td><a name="tag-const">@const</a></td> <td> - <code>@const</code> + <code>@const</code><br/> + <code>@const {type}</code> <p><i>For example:</i></p> <CODE_SNIPPET> /** @const */ var MY_BEER = 'stout'; /** * My namespace's favorite kind of beer. - * @const - * @type {string} + * @const {string} */ mynamespace.MY_BEER = 'stout'; @@ -2476,7 +2480,7 @@ <p>When <code>@const</code> is applied to a method, it implies the method is not only not overwritable, but also - that the method is <em>finalized</em> — + that the method is <em>finalized</em> — not overridable in subclasses.</p> <p>For more on <code>@const</code>, see the @@ -2861,6 +2865,10 @@ </td> </tr> + + + + <tr> <td><a name="tag-noalias">@noalias</a></td> <td> @@ -2962,13 +2970,13 @@ <tr> <td><a name="tag-private">@private</a></td> <td> - <code>@private</code> + <code>@private</code><br/> + <code>@private {type}</code> <p><i>For example:</i></p> <CODE_SNIPPET> /** * Handlers that are listening to this logger. - * @type Array.<Function> - * @private + * @private {!Array.<Function>} */ this.handlers_ = []; </CODE_SNIPPET> @@ -2985,7 +2993,8 @@ <tr> <td><a name="tag-protected">@protected</a></td> <td> - <code>@protected</code> + <code>@protected</code><br/> + <code>@protected {type}</code> <p><i>For example:</i></p> <CODE_SNIPPET> /** @@ -3222,6 +3231,9 @@ <a href="#Typedefs">complex type</a>. </td> </tr> + + + </tbody> </table> @@ -3527,7 +3539,7 @@ </PARTING_WORDS> <p align="right"> - Revision 2.64 + Revision 2.72 </p> |