Title: [193379] trunk/Websites/webkit.org
Revision
193379
Author
j...@apple.com
Date
2015-12-03 14:47:29 -0800 (Thu, 03 Dec 2015)

Log Message

Add sub-section anchors to code style guidelines
https://bugs.webkit.org/show_bug.cgi?id=151770

Reviewed by Timothy Hatcher.

* code-style.md:
* wp-content/plugins/table-of-contents.php:
* wp-content/themes/webkit/includes.php:
* wp-content/themes/webkit/style.css:
(a[name]):
(p > a[name]::before):
(a[name]:hover):
(h6 a[name]):
(.admin-bar a[name]):
(.admin-bar p > a[name]::before):
(.screen-reader-text):
(.table-of-contents ul li > ul):
(#post-4132 pre:nth-child(-n+10)):
(#post-4132 pre:nth-child(-n+8)): Deleted.

Modified Paths

Diff

Modified: trunk/Websites/webkit.org/ChangeLog (193378 => 193379)


--- trunk/Websites/webkit.org/ChangeLog	2015-12-03 22:41:36 UTC (rev 193378)
+++ trunk/Websites/webkit.org/ChangeLog	2015-12-03 22:47:29 UTC (rev 193379)
@@ -1,3 +1,25 @@
+2015-12-03  Jonathan Davis  <j...@apple.com>
+
+        Add sub-section anchors to code style guidelines
+        https://bugs.webkit.org/show_bug.cgi?id=151770
+
+        Reviewed by Timothy Hatcher.
+
+        * code-style.md:
+        * wp-content/plugins/table-of-contents.php:
+        * wp-content/themes/webkit/includes.php:
+        * wp-content/themes/webkit/style.css:
+        (a[name]):
+        (p > a[name]::before):
+        (a[name]:hover):
+        (h6 a[name]):
+        (.admin-bar a[name]):
+        (.admin-bar p > a[name]::before):
+        (.screen-reader-text):
+        (.table-of-contents ul li > ul):
+        (#post-4132 pre:nth-child(-n+10)):
+        (#post-4132 pre:nth-child(-n+8)): Deleted.
+
 2015-12-01  Jonathan Davis  <j...@apple.com>
 
         Updated favicon.ico with the new logo.

Modified: trunk/Websites/webkit.org/code-style.md (193378 => 193379)


--- trunk/Websites/webkit.org/code-style.md	2015-12-03 22:41:36 UTC (rev 193378)
+++ trunk/Websites/webkit.org/code-style.md	2015-12-03 22:47:29 UTC (rev 193379)
@@ -1,7 +1,9 @@
 ### Indentation
 
-Use spaces, not tabs. The indent size is 4 spaces. Tabs should only appear in files that require them for semantic meaning, like Makefiles.
+[](#indentation-no-tabs) Use spaces, not tabs. Tabs should only appear in files that require them for semantic meaning, like Makefiles.
 
+[](#indentation-4-spaces) The indent size is 4 spaces.
+
 ###### Right:
 
 ```cpp
@@ -20,7 +22,7 @@
 }
 ```
 
-The contents of an outermost `namespace` block (and any nested namespaces with the same scope) should not be indented. The contents of other nested namespaces should be indented.
+[](#indentation-namespace) The contents of an outermost `namespace` block (and any nested namespaces with the same scope) should not be indented. The contents of other nested namespaces should be indented.
 
 ###### Right:
 
@@ -78,9 +80,8 @@
 } // namespace WebCore
 ```
 
+[](#indentation-case-label) A case label should line up with its switch statement. The case statement is indented.
 
-A case label should line up with its switch statement. The case statement is indented.
-
 ###### Right:
 
 ```cpp
@@ -107,9 +108,8 @@
 }
 ```
 
+[](#indentation-wrap-bool-op) Boolean expressions at the same nesting level that span multiple lines should have their operators on the left side of the line instead of the right side.
 
-Boolean expressions at the same nesting level that span multiple lines should have their operators on the left side of the line instead of the right side.
-
 ###### Right:
 
 ```cpp
@@ -130,7 +130,7 @@
 
 ### Spacing
 
-Do not place spaces around unary operators.
+[](#spacing-unary-op) Do not place spaces around unary operators.
 
 ###### Right:
 
@@ -145,9 +145,8 @@
 i ++;
 ```
 
+[](#spacing-binary-ternary-op) **Do** place spaces around binary and ternary operators.
 
-**Do** place spaces around binary and ternary operators.
-
 ###### Right:
 
 ```cpp
@@ -166,9 +165,8 @@
 return condition ? 1:0;
 ```
 
+[](#spacing-for-colon) Place spaces around the colon in a range-based for loop.
 
-Place spaces around the colon in a range-based for loop.
-
 ###### Right:
 
 ```cpp
@@ -185,9 +183,8 @@
     registerPlugin(plugin);
 ```
 
+[](#spacing-comma-semicolon) Do not place spaces before comma and semicolon.
 
-Do not place spaces before comma and semicolon.
-
 ###### Right:
 
 ```cpp
@@ -206,9 +203,8 @@
 f(a , b) ;
 ```
 
+[](#spacing-control-paren) Place spaces between control statements and their parentheses.
 
-Place spaces between control statements and their parentheses.
-
 ###### Right:
 
 ```cpp
@@ -223,9 +219,8 @@
     doIt();
 ```
 
+[](#spacing-function-paren) Do not place spaces between a function and its parentheses, or between a parenthesis and its content.
 
-Do not place spaces between a function and its parentheses, or between a parenthesis and its content.
-
 ###### Right:
 
 ```cpp
@@ -241,7 +236,7 @@
 
 ### Line breaking
 
-Each statement should get its own line.
+[](#linebreaking-multiple-statements) Each statement should get its own line.
 
 ###### Right:
 
@@ -259,7 +254,7 @@
 if (condition) doIt();
 ```
 
-An `else` statement should go on the same line as a preceding close brace if one is present, else it should line up with the `if` statement.
+[](#linebreaking-else-braces) An `else` statement should go on the same line as a preceding close brace if one is present, else it should line up with the `if` statement.
 
 ###### Right:
 
@@ -299,9 +294,8 @@
 }
 ```
 
+[](#linebreaking-else-if) An `else if` statement should be written as an `if` statement when the prior `if` concludes with a `return` statement.
 
-An `else if` statement should be written as an `if` statement when the prior `if` concludes with a `return` statement.
-
 ###### Right:
 
 ```cpp
@@ -327,7 +321,7 @@
 
 ### Braces
 
-Function definitions: place each brace on its own line.
+[](#braces-function) Function definitions: place each brace on its own line.
 
 ###### Right:
 
@@ -346,7 +340,7 @@
 }
 ```
 
-Other braces: place the open brace on the line preceding the code block; place the close brace on its own line.
+[](#braces-blocks) Other braces: place the open brace on the line preceding the code block; place the close brace on its own line.
 
 ###### Right:
 
@@ -373,7 +367,7 @@
 };
 ```
 
-One-line control clauses should not use braces unless comments are included or a single statement spans multiple lines.
+[](#braces-one-line) One-line control clauses should not use braces unless comments are included or a single statement spans multiple lines.
 
 ###### Right:
 
@@ -408,9 +402,8 @@
         reallyLongParam5);
 ```
 
+[](#braces-empty-block) Control clauses without a body should use empty braces:
 
-Control clauses without a body should use empty braces:
-
 ###### Right:
 
 ```cpp
@@ -425,11 +418,11 @@
 
 ### Null, false and zero
 
-In C++, the null pointer value should be written as `nullptr`. In C, it should be written as `NULL`. In Objective-C and Objective-C++, follow the guideline for C or C++, respectively, but use `nil` to represent a null Objective-C object.
+[](#zero-null) In C++, the null pointer value should be written as `nullptr`. In C, it should be written as `NULL`. In Objective-C and Objective-C++, follow the guideline for C or C++, respectively, but use `nil` to represent a null Objective-C object.
 
-C++ and C `bool` values should be written as `true` and `false`. Objective-C `BOOL` values should be written as `YES` and `NO`.
+[](#zero-bool) C++ and C `bool` values should be written as `true` and `false`. Objective-C `BOOL` values should be written as `YES` and `NO`.
 
-Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.
+[](#zero-comparison) Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.
 
 ###### Right:
 
@@ -457,11 +450,11 @@
     return;
 ```
 
-In Objective-C, instance variables are initialized to zero automatically. Don't add explicit initializations to nil or NO in an init method.
+[](#zero-objc-variables) In Objective-C, instance variables are initialized to zero automatically. Don't add explicit initializations to nil or NO in an init method.
 
 ### Floating point literals
 
-Unless required in order to force floating point math, do not append `.0`, `.f` and `.0f` to floating point literals.
+[](#float-suffixes) Unless required in order to force floating point math, do not append `.0`, `.f` and `.0f` to floating point literals.
 
 ###### Right:
 
@@ -497,7 +490,7 @@
 
 ### Names
 
-Use CamelCase. Capitalize the first letter, including all letters in an acronym, in a class, struct, protocol, or namespace name. Lower-case the first letter, including all letters in an acronym, in a variable or function name.
+[](#names-basic) Use CamelCase. Capitalize the first letter, including all letters in an acronym, in a class, struct, protocol, or namespace name. Lower-case the first letter, including all letters in an acronym, in a variable or function name.
 
 ###### Right:
 
@@ -517,7 +510,7 @@
 String MIMEType();
 ```
 
-Use full words, except in the rare case where an abbreviation would be more canonical and easier to understand.
+[](#names-full-words) Use full words, except in the rare case where an abbreviation would be more canonical and easier to understand.
 
 ###### Right:
 
@@ -535,7 +528,7 @@
 short tabulationIndex; // bizarre
 ```
 
-Data members in C++ classes should be private. Static data members should be prefixed by "s_". Other data members should be prefixed by "m_".
+[](#names-data-members) Data members in C++ classes should be private. Static data members should be prefixed by "s_". Other data members should be prefixed by "m_".
 
 ###### Right:
 
@@ -560,7 +553,7 @@
 };
 ```
 
-Prefix Objective-C instance variables with "_".
+[](#names-objc-instance-variables) Prefix Objective-C instance variables with "_".
 
 ###### Right:
 
@@ -580,7 +573,7 @@
 @end
 ```
 
-Precede boolean values with words like "is" and "did".
+[](#names-bool) Precede boolean values with words like "is" and "did".
 
 ###### Right:
 
@@ -596,7 +589,7 @@
 bool sentData;
 ```
 
-Precede setters with the word "set". Use bare words for getters. Setter and getter names should match the names of the variables being set/gotten.
+[](#names-setter-getter) Precede setters with the word "set". Use bare words for getters. Setter and getter names should match the names of the variables being set/gotten.
 
 ###### Right:
 
@@ -612,7 +605,7 @@
 size_t getCount();
 ```
 
-Precede getters that return values through out arguments with the word "get".
+[](#names-out-argument) Precede getters that return values through out arguments with the word "get".
 
 ###### Right:
 
@@ -626,7 +619,7 @@
 void inlineBoxAndOffset(InlineBox*&, int& caretOffset) const;
 ```
 
-Use descriptive verbs in function names.
+[](#names-verb) Use descriptive verbs in function names.
 
 ###### Right:
 
@@ -640,7 +633,7 @@
 bool toASCII(short*, size_t);
 ```
 
-Leave meaningless variable names out of function declarations. A good rule of thumb is if the parameter type name contains the parameter name (without trailing numbers or pluralization), then the parameter name isn't needed. Usually, there should be a parameter name for bools, strings, and numerical types.
+[](#names-variable-name-in-function-decl) Leave meaningless variable names out of function declarations. A good rule of thumb is if the parameter type name contains the parameter name (without trailing numbers or pluralization), then the parameter name isn't needed. Usually, there should be a parameter name for bools, strings, and numerical types.
 
 ###### Right:
 
@@ -658,7 +651,7 @@
 void doSomething(ScriptExecutionContext* context);
 ```
 
-Prefer enums to bools on function parameters if callers are likely to be passing constants, since named constants are easier to read at the call site. An exception to this rule is a setter function, where the name of the function already makes clear what the boolean is.
+[](#names-enum-to-bool) Prefer enums to bools on function parameters if callers are likely to be passing constants, since named constants are easier to read at the call site. An exception to this rule is a setter function, where the name of the function already makes clear what the boolean is.
 
 ###### Right:
 
@@ -675,15 +668,15 @@
 setResizable(NotResizable);
 ```
 
-Objective-C method names should follow the Cocoa naming guidelines — they should read like a phrase and each piece of the selector should start with a lowercase letter and use intercaps.
+[](#names-objc-methods) Objective-C method names should follow the Cocoa naming guidelines — they should read like a phrase and each piece of the selector should start with a lowercase letter and use intercaps.
 
-Enum members should use InterCaps with an initial capital letter.
+[](#names-enum-members) Enum members should use InterCaps with an initial capital letter.
 
-Prefer `const` to `#define`. Prefer inline functions to macros.
+[](#names-const-to-define) Prefer `const` to `#define`. Prefer inline functions to macros.
 
-`#defined` constants should use all uppercase names with words separated by underscores.
+[](#names-define-constants) `#defined` constants should use all uppercase names with words separated by underscores.
 
-Macros that expand to function calls or other non-constant computation: these should be named like functions, and should have parentheses at the end, even if they take no arguments (with the exception of some special macros like ASSERT). Note that usually it is preferable to use an inline function in such cases instead of a macro.
+[](#names-define-non-const) Macros that expand to function calls or other non-constant computation: these should be named like functions, and should have parentheses at the end, even if they take no arguments (with the exception of some special macros like ASSERT). Note that usually it is preferable to use an inline function in such cases instead of a macro.
 
 ###### Right:
 
@@ -702,7 +695,7 @@
         NSLocalizedString(@"Stop", @"Stop button title")
 ```
 
-`#define`, `#ifdef` "header guards" should be named exactly the same as the file (including case), replacing the `.` with a `_`.
+[](#names-header-guards) `#define`, `#ifdef` "header guards" should be named exactly the same as the file (including case), replacing the `.` with a `_`.
 
 ###### Right:
 
@@ -722,7 +715,7 @@
 
 ### Other Punctuation
 
-Constructors for C++ classes should initialize all of their members using C++ initializer syntax. Each member (and superclass) should be indented on a separate line, with the colon or comma preceding the member on that line.
+[](#punctuation-member-init) Constructors for C++ classes should initialize all of their members using C++ initializer syntax. Each member (and superclass) should be indented on a separate line, with the colon or comma preceding the member on that line.
 
 ###### Right:
 
@@ -752,7 +745,7 @@
 MyOtherClass::MyOtherClass() : MySuperClass() {}
 ```
 
-Prefer index over iterator in Vector iterations for terse, easier-to-read code.
+[](#punctuation-vector-index) Prefer index over iterator in Vector iterations for terse, easier-to-read code.
 
 ###### Right:
 
@@ -780,10 +773,10 @@
 
 ### Pointers and References
 
-**Pointer types in non-C++ code**
+[](#pointers-non-cpp) **Pointer types in non-C++ code**
 Pointer types should be written with a space between the type and the `*` (so the `*` is adjacent to the following identifier if any).
 
-**Pointer and reference types in C++ code**
+[](#pointers-cpp) **Pointer and reference types in C++ code**
 Both pointer types and reference types should be written with no space between the type name and the `*` or `&`.
 
 ###### Right:
@@ -804,9 +797,8 @@
     const KCDashArray &dashes = dashArray();
 ```
 
+[](#pointers-out-argument) An out argument of a function should be passed by reference except rare cases where it is optional in which case it should be passed by pointer.
 
-An out argument of a function should be passed by reference except rare cases where it is optional in which case it should be passed by pointer.
-
 ###### Right:
 
 ```cpp
@@ -832,10 +824,9 @@
 }
 ```
 
-
 ### #include Statements
 
-All implementation files must `#include` `config.h` first. Header files should never include `config.h`.
+[](#include-config-h) All implementation files must `#include` `config.h` first. Header files should never include `config.h`.
 
 ###### Right:
 
@@ -857,9 +848,9 @@
 #include "Node.h"
 ```
 
-All implementation files must `#include` the primary header second, just after `config.h`. So for example, `Node.cpp` should include `Node.h` first, before other files. This guarantees that each header's completeness is tested. This also assures that each header can be compiled without requiring any other header files be included first.
+[](#include-primary) All implementation files must `#include` the primary header second, just after `config.h`. So for example, `Node.cpp` should include `Node.h` first, before other files. This guarantees that each header's completeness is tested. This also assures that each header can be compiled without requiring any other header files be included first.
 
-Other `#include` statements should be in sorted order (case sensitive, as done by the command-line sort tool or the Xcode sort selection command). Don't bother to organize them in a logical order.
+[](#include-others) Other `#include` statements should be in sorted order (case sensitive, as done by the command-line sort tool or the Xcode sort selection command). Don't bother to organize them in a logical order.
 
 ###### Right:
 
@@ -883,9 +874,8 @@
 #include "Attribute.h"
 ```
 
+[](#include-system) Includes of system headers must come after includes of other headers.
 
-Includes of system headers must come after includes of other headers.
-
 ###### Right:
 
 ```cpp
@@ -914,7 +904,7 @@
 
 ### "using" Statements
 
-In header files, do not use "using" statements in namespace (or global) scope.
+[](#using-in-headers) In header files, do not use "using" statements in namespace (or global) scope.
 
 ###### Right:
 
@@ -947,9 +937,8 @@
 } // namespace WTF
 ```
 
+[](#using-wtf) In header files in the WTF sub-library, however, it is acceptable to use "using" declarations at the end of the file to import one or more names in the WTF namespace into the global scope.
 
-In header files in the WTF sub-library, however, it is acceptable to use "using" declarations at the end of the file to import one or more names in the WTF namespace into the global scope.
-
 ###### Right:
 
 ```cpp
@@ -986,9 +975,8 @@
 using WTF::PlacementNewAdopt;
 ```
 
+[](#using-in-cpp) In C++ implementation files, do not use "using" declarations of any kind to import names in the standard template library. Directly qualify the names at the point they're used instead.
 
-In C++ implementation files, do not use "using" declarations of any kind to import names in the standard template library. Directly qualify the names at the point they're used instead.
-
 ###### Right:
 
 ```cpp
@@ -1030,9 +1018,8 @@
 } // namespace WebCore
 ```
 
+[](#using-nested-namespaces) In implementation files, if a "using namespace" statement is for a nested namespace whose parent namespace is defined in the file, put the statement inside that namespace definition.
 
-In implementation files, if a "using namespace" statement is for a nested namespace whose parent namespace is defined in the file, put the statement inside that namespace definition.
-
 ###### Right:
 
 ```cpp
@@ -1057,9 +1044,8 @@
 } // namespace WebCore
 ```
 
+[](#using-position) In implementation files, put all other "using" statements at the beginning of the file, before any namespace definitions and after any "include" statements.
 
-In implementation files, put all other "using" statements at the beginning of the file, before any namespace definitions and after any "include" statements.
-
 ###### Right:
 
 ```cpp
@@ -1086,7 +1072,7 @@
 
 ### Types
 
-Omit "int" when using "unsigned" modifier. Do not use "signed" modifier. Use "int" by itself instead.
+[](#types-unsigned) Omit "int" when using "unsigned" modifier. Do not use "signed" modifier. Use "int" by itself instead.
 
 ###### Right:
 
@@ -1105,7 +1091,7 @@
 
 ### Classes
 
-Use a constructor to do an implicit conversion when the argument is reasonably thought of as a type conversion and the type conversion is fast. Otherwise, use the explicit keyword or a function returning the type. This only applies to single argument constructors.
+[](#classes-explicit) Use a constructor to do an implicit conversion when the argument is reasonably thought of as a type conversion and the type conversion is fast. Otherwise, use the explicit keyword or a function returning the type. This only applies to single argument constructors.
 
 ###### Right:
 
@@ -1136,7 +1122,7 @@
 
 ### Singleton pattern
 
-Use a static member function named "singleton()" to access the instance of the singleton.
+[](#singleton-static-member) Use a static member function named "singleton()" to access the instance of the singleton.
 
 ###### Right:
 
@@ -1168,7 +1154,7 @@
 
 ### Comments
 
-Use only _one_ space before end of line comments and in between sentences in comments.
+[](#comments-eol) Use only _one_ space before end of line comments and in between sentences in comments.
 
 ###### Right:
 
@@ -1183,9 +1169,9 @@
 double f; // This is another comment.  There are two spaces before this sentence which is a non-conforming style.
 ```
 
-Make comments look like sentences by starting with a capital letter and ending with a period (punctation). One exception may be end of line comments like this `if (x == y) // false for NaN`.
+[](#comments-sentences) Make comments look like sentences by starting with a capital letter and ending with a period (punctation). One exception may be end of line comments like this `if (x == y) // false for NaN`.
 
-Use FIXME: (without attribution) to denote items that need to be addressed in the future.
+[](#comments-fixme) Use FIXME: (without attribution) to denote items that need to be addressed in the future.
 
 ###### Right:
 

Modified: trunk/Websites/webkit.org/wp-content/plugins/table-of-contents.php (193378 => 193379)


--- trunk/Websites/webkit.org/wp-content/plugins/table-of-contents.php	2015-12-03 22:41:36 UTC (rev 193378)
+++ trunk/Websites/webkit.org/wp-content/plugins/table-of-contents.php	2015-12-03 22:47:29 UTC (rev 193379)
@@ -28,7 +28,7 @@
 
     public static function filterIndex($value, $key) {
         list($level, $anchor) = explode('::', $key);
-        if ( $level < 4 ) self::$toc[ $key ] = $value;
+        if ( $level < 3 ) self::$toc[ $key ] = $value;
     }
 
     public static function renderMarkup() {

Modified: trunk/Websites/webkit.org/wp-content/themes/webkit/includes.php (193378 => 193379)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/includes.php	2015-12-03 22:41:36 UTC (rev 193378)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/includes.php	2015-12-03 22:47:29 UTC (rev 193379)
@@ -18,9 +18,15 @@
             ob_start();
             include $path . '/' . $file;
             $content = ob_get_clean();
-        
+
+            // Handle sub-section anchors
+            $content = preg_replace('/\[]\(\#([^\)]+)\)\s+?/', '<a href="" name="$1"></a>', $content);
+            
+            // Transform Markdown
             $Markdown = WPCom_Markdown::get_instance();
             $content = wp_unslash( $Markdown->transform($content) );
+            
+            // Index table of contents
             $content = table_of_contents_index($content, get_the_ID());
             
             set_transient($cachekey, $content, DAY_IN_SECONDS);

Modified: trunk/Websites/webkit.org/wp-content/themes/webkit/style.css (193378 => 193379)


--- trunk/Websites/webkit.org/wp-content/themes/webkit/style.css	2015-12-03 22:41:36 UTC (rev 193378)
+++ trunk/Websites/webkit.org/wp-content/themes/webkit/style.css	2015-12-03 22:47:29 UTC (rev 193379)
@@ -97,9 +97,33 @@
 
 /** Accessibility Helpers **/
 a[name] {
-    display: block;
+    display: inline-block;
     position: relative;
     top: -3rem;
+    color: #ddd;
+    width: 0;
+}
+
+p > a[name]::before {
+    content: "#";
+    margin-left: -1.7rem;
+    position: relative;
+    top: 3rem;
+    
+}
+
+a[name]:hover {
+    color: #08c;
+    text-decoration: none;
+}
+
+h1 a[name],
+h2 a[name],
+h3 a[name],
+h4 a[name],
+h5 a[name],
+h6 a[name] {
+    display: block;
     visibility: hidden;
 }
 
@@ -107,6 +131,10 @@
     top: calc(-32px - 3rem);
 }
 
+.admin-bar p > a[name]::before {
+    top: calc(32px + 3rem);
+}
+
 .screen-reader-text {
 	clip: rect(1px, 1px, 1px, 1px);
 	position: absolute !important;
@@ -1216,7 +1244,7 @@
 }
 
 .with-toc pre:nth-child(-n+6),
-#post-4132 pre:nth-child(-n+8) {
+#post-4132 pre:nth-child(-n+10) {
     width: 55%;
     z-index: -1;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to