contributing. more whitespace fixes. ref #111

This commit is contained in:
Paul Irish 2014-08-20 23:17:46 -07:00
Родитель f6cebc5ffb
Коммит accf201ae3
1 изменённых файлов: 52 добавлений и 122 удалений

Просмотреть файл

@ -38,16 +38,11 @@ Read on to learn how to contribute a patch to DevTools source.
## Contributing to DevTools source code
The Chrome DevTools are actually a web app written in JavaScript and CSS. If
you're familiar with these technologies, you know enough to write a patch. A few
folks have already done this, giving us a colorpicker, a file picker
and other features, all contributed by developers just like you.
The Chrome DevTools are actually a web app written in JavaScript and CSS. If you're familiar with these technologies, you know enough to write a patch. A few folks have already done this, giving us a colorpicker, a file picker and other features, all contributed by developers just like you.
IRC channel on [Freenode](http://webchat.freenode.net/?channels=blink): #chrome-devtools and #blink
In this guide, we'll cover how to get set up and running locally so you can
start developing and contributing to the DevTools. You may also find it helpful
to read the [Chromium guide for contributing code](http://dev.chromium.org/developers/contributing-code).
In this guide, we'll cover how to get set up and running locally so you can start developing and contributing to the DevTools. You may also find it helpful to read the [Chromium guide for contributing code](http://dev.chromium.org/developers/contributing-code).
<p class="note"><strong>Note:</strong> You will need to sign and submit a completed <a href="https://developers.google.com/open-source/cla/individual">CLA (Contributor License Agreement)</a> before we are able to consider any contributions you may wish to make.
</p>
@ -57,20 +52,21 @@ to read the [Chromium guide for contributing code](http://dev.chromium.org/devel
There are a few things you need in order to contribute to DevTools.
**Get the code**<br/>
Download the [Blink](http://www.chromium.org/blink) source code by [cloning the git repository](https://chromium.googlesource.com/chromium/blink). This process
can take anywhere between 30-60 minutes (depending on your connection).<br/>
Download the [Blink](http://www.chromium.org/blink) source code by [cloning the git repository](https://chromium.googlesource.com/chromium/blink). This process can take anywhere between 30-60 minutes (depending on your connection).<br/>
<br/>
`git clone https://chromium.googlesource.com/chromium/blink`<br/><br/>
**Install Canary**<br/>
While Blink downloads, install Chrome Canary on [Mac OS / Windows](https://tools.google.com/dlpage/chromesxs) or download [the latest Chromium build](https://download-chromium.appspot.com/).<br/>
<p class="note"><strong>Note:</strong> To save you time, we created a <a href="https://github.com/jankeromnes/cr">helpful bash
script</a> that can take care of some of the
grunt work for you.
<p class="note"><strong>Note:</strong> To save you time, we created a <a href="https://github.com/jankeromnes/cr">helpful bash script</a> that can take care of some of the grunt work for you.
</p>
<br/>
**Serve devtools frontend**<br/>
Run a local web server. The local web server will serve files from the directory
`blink/Source/devtools` on some port (e.g. `8000`).
@ -82,65 +78,43 @@ From there you can run a local server on port 8000 with the following command:
python -m SimpleHTTPServer
Then, open `http://localhost:8000/front_end/inspector.html` in your favorite
browser and start debugging!
Then, open `http://localhost:8000/front_end/inspector.html` in your favorite browser and start debugging!
**Why does the server need to run from the devtools directory?**<br/>
When remotely debugging and developing the front-end of Blink, the content of the
`InspectorBackendCommands.js` file is generated based on the content of
`protocol.json` instead as a fallback of the Chromium build system. The
`protocol.json` file is in the parent folder of the `front_end` folder which is
`/devtools`. This is why you need to run the web server from within the `devtools`
directory.
`/devtools`. This is why you need to run the web server from within the `devtools` directory.
<p class="note"><strong>Note:</strong> If you have checked out the entire Chromium source you will need to
run the web server from <code>/src/third_party/WebKit/Source/devtools</code> instead.
<p class="note"><strong>Note:</strong> If you have checked out the entire Chromium source you will need to run the web server from <code>/src/third_party/WebKit/Source/devtools</code> instead.
</p>
If your feature requires changes to the back-end code then you definitely need
to checkout and build Chromium. Otherwise, you only need to setup a web server
for the front-end files and run Chrome with remote-debugging options.
If your feature requires changes to the back-end code then you definitely need to checkout and build Chromium. Otherwise, you only need to setup a web server for the front-end files and run Chrome with remote-debugging options.
<p class="note"><strong>Note:</strong> `protocol.json` describes the API between front-end and back-end. It is
used for generating API stubs for the front-end and back-end at the build stage.
When remote debugging the front-end part of the API, <code>InspectorBackendCommands.js</code>
is generated on the fly by front-end code. For more information, read the <a href="http://www.chromium.org/developers/how-tos">Chromium How-tos</a>.
<p class="note"><strong>Note:</strong> `protocol.json` describes the API between front-end and back-end. It is used for generating API stubs for the front-end and back-end at the build stage. When remote debugging the front-end part of the API, <code>InspectorBackendCommands.js</code> is generated on the fly by front-end code. For more information, read the <a href="http://www.chromium.org/developers/how-tos">Chromium How-tos</a>.
</p>
**Install depot_tools**<br/>
You will need to [install the depot_tools](http://dev.chromium.org/developers/how-tos/install-depot-tools) in
order to upload your patch once your changes are completed. The
**[depot_tools](http://dev.chromium.org/developers/how-tos/depottools)** are a
package of scripts used to manage checkouts and code reviews, and it includes
commands `gclient`, `gcl`, and `git-cl` and will be useful later on. You will
still want to sync your Chromium checkout with all its dependencies however.
**Install depot_tools**<br/> You will need to [install the depot_tools](http://dev.chromium.org/developers/how-tos/install-depot-tools) in order to upload your patch once your changes are completed. The **[depot_tools](http://dev.chromium.org/developers/how-tos/depottools)** are a package of scripts used to manage checkouts and code reviews, and it includes commands `gclient`, `gcl`, and `git-cl` and will be useful later on. You will still want to sync your Chromium checkout with all its dependencies however.
Download `depot_tools` by cloning the repository:
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
Then you will need to add it to your
[PATH](http://www.google.com/url?q=http%3A%2F%2Fwww.lmgtfy.com%2F%3Fq%3DPATH%2Benvironment&sa=D&sntz=1&usg=AFQjCNEpeE0-9UdbY3wOOLl2YafKhXvyvA).
Do this by adding the following to your `.bashrc` or `.bashprofile` file or your
shell's equivalent at the end of the file. This way you won't need to reset your
`$PATH` manually each time you open a new shell.
[PATH](http://www.google.com/url?q=http%3A%2F%2Fwww.lmgtfy.com%2F%3Fq%3DPATH%2Benvironment&sa=D&sntz=1&usg=AFQjCNEpeE0-9UdbY3wOOLl2YafKhXvyvA). Do this by adding the following to your `.bashrc` or `.bashprofile` file or your shell's equivalent at the end of the file. This way you won't need to reset your `$PATH` manually each time you open a new shell.
export PATH="$PATH":`pwd`/depot_tools
**Windows**
This guide is currently not tested on Windows due to not being able to
successfully add `depot_tools` to the PATH while using the default CMD line of
Windows. However, you can try Cygwin as an alternative solution. Here you can find [steps for installing depot_tools on Windows with Cygwin](http://dev.chromium.org/developers/how-tos/install-depot-tools#TOC-Windows-Cygwin-and-non-Cygwin-).
<p class="note"><strong>Note:</strong> This guide includes steps for Windows throughout it, but has not been
confirmed to work due to the inability to `add depot_tools` to the PATH, while
using the Windows CMD line.
<p class="note"><strong>Note:</strong> This guide includes steps for <strong>Windows</strong> throughout it, but has not been confirmed to work due to the inability to add `depot_tools` to the PATH of Windows command line. However, you can try Cygwin as an alternative solution. Here you can find <a href="http://dev.chromium.org/developers/how-tos/install-depot-tools#TOC-Windows-Cygwin-and-non-Cygwin-">steps for installing depot_tools on Windows with Cygwin</a>.
</p>
### Step 2: Running an edge-build of Chromium
To begin, get an [edge-build](http://www.chromium.org/getting-involved/download-chromium) of
Chromium. These are available for all platforms.
To begin, get an [edge-build](http://www.chromium.org/getting-involved/download-chromium) of Chromium. These are available for all platforms.
There are a couple of [command line flags](http://www.chromium.org/developers/how-tos/run-chromium-with-flags) (or switches) that are needed when running Chromium for developing DevTools.<br/>
**<br/>
@ -158,29 +132,25 @@ For example:
<img src="contributing-files/image02.png" alt="Command-line flags" width="700"/>
<p class="note"><strong>Note:</strong>It's a good idea if you copy the path in Target to a text editor so
you can see the full value while adding the flags with a space between each one
to the end of the path. Then paste the entire line into the field.</p>
<p class="note"><strong>Note:</strong>It's a good idea if you copy the path in Target to a text editor so you can see the full value while adding the flags with a space between each one to the end of the path. Then paste the entire line into the field.</p>
**On OS X<br/>
**Run Canary in the terminal with the flags added at the end of the path to the
program.<br/>
**Run Canary in the terminal with the flags added at the end of the path to the program.<br/>
<br/>
`/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary \
--remote-debugging-port=9222 --no-first-run \
--user-data-dir=blink/chromeServerProfile \
--remote-debugging-port=9222 --no-first-run
--user-data-dir=blink/chromeServerProfile
http://localhost:9222#http://localhost:8000/front_end/inspector.html`<br/>
<br/>
<p class="note"><strong>Note:</strong> You will need to escape any spaces in the path with a slash "\ " as
shown in above.</p>
<p class="note"><strong>Note:</strong> You will need to escape any spaces in the path with a slash "\ " as shown in above.</p>
<br/>
**On Linux:<br/>
**Run the chromium-browser command with the flags added after it:<br/>
`chromium-browser --remote-debugging-port=9222 --no-first-run \
--user-data-dir=blink/chromeServerProfile \
`chromium-browser --remote-debugging-port=9222 --no-first-run
--user-data-dir=blink/chromeServerProfile
http://localhost:9222#http://localhost:8000/front_end/inspector.html`<br/>
@ -220,20 +190,14 @@ Here you will see a grid menu of every open page that can be inspected. Refresh
<img src="contributing-files/image01.png" alt="Inspectable pages" width="700"/>
This grid menu is served by a small web server running inside the first instance
of Canary which the `--remote-debugging-port=9222` parameter was passed into.
Since the web server is running from your local git repo in the
`/blink/Source/devtools` directory, so the files within the devtools folder will
be used for the inspector you see when clicking any of one these pages.
This grid menu is served by a small web server running inside the first instance of Canary which the `--remote-debugging-port=9222` parameter was passed into. Since the web server is running from your local git repo in the
`/blink/Source/devtools` directory, so the files within the devtools folder will be used for the inspector you see when clicking any of one these pages.
Clicking on the thumbnail of the tab you opened. You'll then have a full tab of DevTools that's inspecting your other tab.
Nice job, so far!
Notice that the URL address of this DevTools instance points to [http://localhost:8000/front_end/inspector.html](http://localhost:8000/front_end/inspector.html).
This is because of the inspector URL `http://localhost:9222#http://localhost:8000/front_end/inspector.html`
that was passed as a hash to the "Inspectable Pages" URL. It connects to
your local repo through a websocket, which you may notice, is part of the URL
Notice that the URL address of this DevTools instance points to [http://localhost:8000/front_end/inspector.html](http://localhost:8000/front_end/inspector.html). This is because of the inspector URL `http://localhost:9222#http://localhost:8000/front_end/inspector.html` that was passed as a hash to the "Inspectable Pages" URL. It connects to your local repo through a websocket, which you may notice, is part of the URL
`?ws=localhost:9222/devtools/`. (You can also use DevTools to look at this WebSocket frame data). Back to hacking…
@ -242,37 +206,28 @@ Now, use your keyboard shortcut to open DevTools within this window. You now hav
<img src="contributing-files/image00.png" alt="inspector inception" width="700"/>
Well done. Now you can [start contributing](http://dev.chromium.org/developers/contributing-code) and
developing the DevTools front-end code located in the directory
Well done. Now you can [start contributing](http://dev.chromium.org/developers/contributing-code) and developing the DevTools front-end code located in the directory
`/blink/Source/devtools/front_end`.<br/><br/>
### Step 4: Pick a ticket
Now that you are ready to dig into the code and start developing the DevTools
source, head over to [http://crbug.com](http://crbug.com) and find the ticket
for your change and leave a comment saying you will be writing a patch for it. If you haven't decided on what you to change look through the open issues and
choose one you would like to do and leave a comment on it asking for it to be
assigned to you.
Now that you are ready to dig into the code and start developing the DevTools source, head over to [http://crbug.com](http://crbug.com) and find the ticket for your change and leave a comment saying you will be writing a patch for it. If you haven't decided on what you to change look through the open issues and choose one you would like to do and leave a comment on it asking for it to be assigned to you.
<p class="note"><strong>Note:</strong> We occasionally label bugs that require a small patch but make for
good first-time contributions with GoodFirstBug. You can [filter](https://code.google.com/p/chromium/issues/list?q=label:GoodFirstBug) down the issues list to only display these.
<p class="note"><strong>Note:</strong> We occasionally label bugs that require a small patch but make for good first-time contributions with GoodFirstBug. You can [filter](https://code.google.com/p/chromium/issues/list?q=label:GoodFirstBug) down the issues list to only display these.
</p>
Alternatively, if there is no existing ticket for the change, then [create a new issue](http://chromiumbugs.appspot.com/?token=3LKZrfbEU7e_Zxic4HVH3gTdvS4%3A1371938055157&role=&continue=https%3A//code.google.com/p/chromium/issues/entry.do). Be sure to describe what the change is and justify why it was needed, adding
"patch to follow" to the end.
**Communicate**<br/>
Before you start
[contributing](http://dev.chromium.org/developers/contributing-code) on a
ticket, it's a good idea to open a new thread on the [DevTools Google Group](https://groups.google.com/forum/?fromgroups#!forum/google-chrome-developer-tools)
so you can discuss anything you are unsure of or may not know about regarding
the particular ticket you will be working on. You can never over communicate.
[contributing](http://dev.chromium.org/developers/contributing-code) on a ticket, it's a good idea to open a new thread on the [DevTools Google Group](https://groups.google.com/forum/?fromgroups#!forum/google-chrome-developer-tools) so you can discuss anything you are unsure of or may not know about regarding the particular ticket you will be working on. You can never over communicate.
### Step 5: Pull, Develop, Branch, Commit
Pull the latest files from the repository and sync to be sure you are working
with the latest code.<br/>
Pull the latest files from the repository and sync to be sure you are working with the latest code.<br/>
git pull --rebase
@ -280,13 +235,9 @@ Then create a new branch which you can make your changes on.<br/>
git checkout -b yourBugOrFeatureName
Open the DevTools on your DevTools, open your favorite code editor and start
digging through the files in your local repository directory
`/blink/Source/devtools/front_end`.
Open the DevTools on your DevTools, open your favorite code editor and start digging through the files in your local repository directory `/blink/Source/devtools/front_end`.
<p class="note"><strong>Note:</strong> During development use the Refresh icon or <span class="kbd">Alt</span> + <span class="kbd">R</span> instead
of <span class="kbd">F5</span>, <span class="kbd">Ctrl</span> + <span class="kbd">R</span> or <span class="kbd">Cmd</span> + <span class="kbd">R</span> as they are bound to refresh the host page which you
are using to develop the DevTools instance.</p>
<p class="note"><strong>Note:</strong> During development use the Refresh icon or <span class="kbd">Alt</span> + <span class="kbd">R</span> instead of <span class="kbd">F5</span>, <span class="kbd">Ctrl</span> + <span class="kbd">R</span> or <span class="kbd">Cmd</span> + <span class="kbd">R</span> as they are bound to refresh the host page which you are using to develop the DevTools instance.</p>
Run your change against the Closure Compiler with:
@ -302,20 +253,16 @@ You should see "0 error(s), 0 warning(s)".
3. Should pass the closure compiler tests
4. Should be a reasonable size to review (larger patches take longer)
Once you have made your change, commit it. In your commit message include the
ticket number and specify that it's a DevTools patch.
Once you have made your change, commit it. In your commit message include the ticket number and specify that it's a DevTools patch.
git commit -m "#175024 DevTools: This describes the Goat Teleporter"
It is a good idea to pull down any changes that have been added since you last
did one and merge them with your branch.
It is a good idea to pull down any changes that have been added since you last did one and merge them with your branch.
Once everything for your patch is complete, you will want to write and run
relevant layout tests. To get started with layout tests for the DevTools see the
Once everything for your patch is complete, you will want to write and run relevant layout tests. To get started with layout tests for the DevTools see the
[WebKit layout tests](http://www.chromium.org/developers/testing/webkit-layout-tests) guide.
<p class="note"><strong>Note:</strong> If your patch includes changes that require writing new unit tests or
UI tests, they will need to be created and included as part of the patch.</p>
<p class="note"><strong>Note:</strong> If your patch includes changes that require writing new unit tests or UI tests, they will need to be created and included as part of the patch.</p>
### Step 6: Upload your Patch
@ -323,18 +270,14 @@ If your patch is finished and all tests pass, upload your changes:<br/>
git cl upload --bypass-hooks
Your editor prompts you to write the patch description. Explain the
change in much detail as you like. Save and exit the editor to
finalize the patch submission.
Your editor prompts you to write the patch description. Explain the change in much detail as you like. Save and exit the editor to finalize the patch submission.
You must have an account for [codereview.chromium.org](http://codereview.chromium.org) and you'll enter in your
credentials in this process. Afterwards, you'll get the codereview URL e.g.<br/>
You must have an account for [codereview.chromium.org](http://codereview.chromium.org) and you'll enter in your credentials in this process. Afterwards, you'll get the codereview URL e.g.<br/>
`Issue created. URL: https://codereview.chromium.org/18173008".
Take note of this URL, you can go to the page and view the status of it.`
Now you just have to wait for your friendly neighborhood reviewers to check
things out to make sure it's all good.
Now you just have to wait for your friendly neighborhood reviewers to check things out to make sure it's all good.
**Cleanup**
@ -345,16 +288,13 @@ Go back to master branch.
## Troubleshooting workflows
Below are a couple alternative perspectives from some of the contributors who
described their workflows and some tips you might find helpful along the way. If you run into any issues following the steps outlined in this
document above, we've documented these to help you troubleshoot things should
you run into any issues.
Below are a couple alternative perspectives from some of the contributors who described their workflows and some tips you might find helpful along the way. If you run into any issues following the steps outlined in this document above, we've documented these to help you troubleshoot things should you run into any issues.
### Alternative workflow #1
You get to pick between two workflows: **merge** or **rebase**. Both are
"_mathematically equivalent_" but you use different commands. Unless you are a
git uber-guru, the workflows and thinking for each are different.<br/>
"_mathematically equivalent_" but you use different commands. Unless you are a git uber-guru, the workflows and thinking for each are different.<br/>
About half of the contributors to Chromium use this **rebase workflow**.
1. git checkout -b myAwesomeBranch
@ -370,9 +310,7 @@ About half of the contributors to Chromium use this **rebase workflow**.
* should be the exact patch you're expecting to upload
11. git cl upload
The _merge workflow_ is slightly less work but you end up with merge revisions
in your history. Also, it can be harder to think of it in such that the
code/patch which you are authoring will eventually be something you apply to
The _merge workflow_ is slightly less work but you end up with merge revisions in your history. Also, it can be harder to think of it in such that the code/patch which you are authoring will eventually be something you apply to
`master`.
### Alternative workflow #2
@ -394,12 +332,9 @@ code/patch which you are authoring will eventually be something you apply to
8. If received LGTM from owners - press commit button.
9. Otherwise, fix comments in local checkout in that branch and proceed to step 3.
Sometimes you may need to rebase if the "commit" button fails on codereview
page. Some reviewers don't like rebasing during a codereview since it makes
reviewing harder for them.
Sometimes you may need to rebase if the "commit" button fails on codereview page. Some reviewers don't like rebasing during a codereview since it makes reviewing harder for them.
While waiting for comments you can switch to another branch and work
on a fix for another issue while this one is "frozen", waiting for review.
While waiting for comments you can switch to another branch and work on a fix for another issue while this one is "frozen", waiting for review.
### Running Layout tests
@ -416,13 +351,8 @@ On a Mac or Linux machine you can simply run:
If you have problems with this step you can look at [Clang](https://code.google.com/p/chromium/wiki/Clang) for Mac help and the [Linux build instructions](https://code.google.com/p/chromium/wiki/LinuxBuildInstructions) for Linux help.
This will also take some time. Once it has finished providing you with warmth from your laptop then you are
good to run the layout tests which can be run with from your src directory
`webkit/tools/layout_tests/run_webkit_tests.sh`. Replace the .sh with .bat if you
are on Windows. Some failures are expected! (unfortunatly). A good process here
is to run them before you make any changes, then run them after you make your
changes. It can also take an argument to a directory so you can just point it to
the `LayoutTests/inspector` directory to run.
This will also take some time. Once it has finished providing you with warmth from your laptop then you are good to run the layout tests which can be run with from your src directory
`webkit/tools/layout_tests/run_webkit_tests.sh`. Replace the .sh with .bat if you are on Windows. Some failures are expected! (unfortunatly). A good process here is to run them before you make any changes, then run them after you make your changes. It can also take an argument to a directory so you can just point it to the `LayoutTests/inspector` directory to run.
### Frequently Asked Questions