Bug 9671 - Style rules not supported by autoformatters
Summary: Style rules not supported by autoformatters
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 420+
Hardware: PC OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-30 16:13 PDT by Michael Emmel
Modified: 2009-03-10 11:29 PDT (History)
1 user (show)

See Also:


Attachments
Format rules using astyle (486 bytes, text/plain)
2006-10-25 22:32 PDT, Michael Emmel
mjs: review-
Details
Format rules using astyle (486 bytes, text/plain)
2006-10-25 22:33 PDT, Michael Emmel
mjs: review-
Details
astyle and sed script for webkit style rules (882 bytes, patch)
2006-10-31 09:02 PST, Michael Emmel
mjs: review-
Details | Formatted Diff | Diff
Style script (2.97 KB, patch)
2006-11-02 08:56 PST, Michael Emmel
mjs: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Emmel 2006-06-30 16:13:09 PDT
The current style rules for WebKit
http://webkit.opendarwin.org/coding/coding-style.html

Are not directly supported by available auto-code formatters astyle,indent etc.

First it would be nice to develop either a modified style guidelines that would allow the use of at least one command line code formatter. 

I've developed a set of rules for astyle that seem close.

astyle \
--mode=c \
--convert-tabs \
--indent=spaces=4 \
--brackets=linux \
--indent-switches \
--max-instatement-indent=40 \
--min-conditional-indent=4 \
--one-line=keep-statements \
--one-line=keep-blocks \
--pad=oper \
$@

But they do not work completely
namespace foo {
becomes
namespace foo
{

And if() -> if () is not supported.
Other artifacts are possbile.

The following is needed
1.) Determine the best formatter
2.) Modify formatter if needed to fit the current rules.
3.) Change the rules to follow the formatter where its difficult or impossible
to follow the current formatting rules.

Note desired formatting that is not handled by auto formatting as strong suggestions.

Finally schedule a full reformat of the code base if desired.
Comment 1 Michael Emmel 2006-10-18 09:53:38 PDT
I made this bug critical because until the choice of auto formatting tools is chosen it blocks contributions to webkit from people with  a disability like dyslexia from contributing.

The first step is to determine which autoformat tools are candidates for acceptance. Eclipse might be a good choice for example.

Next since almost all of these tools produce unwanted changes we need to identify those. In most cases simple pattern matches can be used to find and revert unwanted autoformat changes.

Comment 2 Michael Emmel 2006-10-25 22:32:35 PDT
Created attachment 11220 [details]
Format rules using astyle


This script almost formats correctly for the Webkit style guidlines

The current obvious failure is bit vars used in node and other place are not formatted correctly

thus

foo:1
is turun
Comment 3 Michael Emmel 2006-10-25 22:33:24 PDT
Created attachment 11221 [details]
Format rules using astyle


This script almost formats correctly for the Webkit style guidlines

The current obvious failure is bit vars used in node and other place are not formatted correctly

thus

    foo:1;
becomes

foo:
 1;

foo:1
is turun
Comment 4 Maciej Stachowiak 2006-10-31 04:00:00 PST
The autoformatting script looks good, but I'm not sure what you'd like us to do with it since it is not, as such, a patch. If you provide a patch to add the script to WebKitTools/Scripts (with a ChangeLog or what have you) I'll happily r+ it.
Comment 5 Maciej Stachowiak 2006-10-31 04:14:27 PST
Comment on attachment 11221 [details]
Format rules using astyle

r- because this is not a patch. Please resubmit as a patch, thanks!
Comment 6 Maciej Stachowiak 2006-10-31 04:14:31 PST
Comment on attachment 11220 [details]
Format rules using astyle

r- because this is not a patch. Please resubmit as a patch, thanks!
Comment 7 Michael Emmel 2006-10-31 09:02:39 PST
Created attachment 11299 [details]
astyle and sed script for webkit style rules


Astyle does not handle WebKit C++ class constructor rules.
And it messes up on formatting bitfields. 
I will file a astyle bug on this.
Comment 8 Maciej Stachowiak 2006-11-01 19:02:12 PST
Comment on attachment 11299 [details]
astyle and sed script for webkit style rules

Thanks! Also needs a ChangeLog entry and copyright notice. Please add these.
Comment 9 Michael Emmel 2006-11-02 08:56:37 PST
Created attachment 11347 [details]
Style script

Patch with copyright and changelog entry
Comment 10 Maciej Stachowiak 2006-11-03 04:05:23 PST
Thanks, r=me
Comment 11 Maciej Stachowiak 2006-11-03 05:01:53 PST
Oops, didn't mean to close this.
Comment 12 Maciej Stachowiak 2006-11-03 05:02:18 PST
Comment on attachment 11347 [details]
Style script

r=me
Comment 13 Alexey Proskuryakov 2006-11-03 11:05:51 PST
Committed revision 17575.
Comment 14 David Kilzer (:ddkilzer) 2009-03-10 11:29:36 PDT
See also Bug 17124.