Skip to content

Commit 3367370

Browse files
committed
Working on development doc
1 parent 4e72673 commit 3367370

File tree

1 file changed

+94
-86
lines changed

1 file changed

+94
-86
lines changed

vignettes/development.Rmd

Lines changed: 94 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -18,60 +18,46 @@ The goal of this guide is to help you get up and contributing to ggplot2 as quic
1818
To contribute a change to ggplot2, you follow these steps:
1919

2020
1. Set up a local ggplot2 development environment.
21-
1. Create a branch in git.
22-
1. Make your changes.
23-
1. Push branch to github and issue pull request.
24-
1. Discuss the pull request with Winston or Hadley.
25-
1. Iterate until either we're happy, or we've determined that your change
26-
is not a good fit for ggplot2.
21+
1. Create a branch in git and make your changes.
22+
1. Push branch to github and issue pull request (PR).
23+
1. Discuss the pull request.
24+
1. Iterate until either we accept the PR or decide that it's not
25+
a good fit for ggplot2.
2726

2827
Each of these steps are described in more detail below. This might feel overwhelming the first time you get set up, but it gets easier with practice. If you get stuck at any point, please reach out for help on the [ggplot2-dev](https://groups.google.com/forum/#!forum/ggplot2-dev) mailing list
2928

3029
## Basic setup
3130

3231
If you want to do development on ggplot2 and share the changes with other people, you'll have to set up an account on GitHub. You'll make a fork of Hadley's repository and store it on GitHub. You'll also make a copy of your repository on your local machine.
3332

34-
1. [Set up an account](https://github.com/) on GitHub and set up ssh keys
35-
as described in their instructions.
33+
1. [Join github](https://github.com/join).
3634

37-
2. Make a fork of [Hadley's repository](https://github.com/hadley/ggplot2) by
38-
clicking the Fork button in the upper right. For more info, see the
39-
[GitHub page](http://help.github.com/fork-a-repo/) on forking.)
35+
1. [Set up git and github](https://help.github.com/articles/set-up-git).
4036

41-
3. Clone your GitHub repository to your local computer (change `myname` to
42-
your account name):
37+
1. Fork of the main repo by going to https://github.com/hadley/ggplot2/fork.
38+
A fork is a copy of ggplot2 that you can work on independently.
39+
See [fork a repo](https://help.github.com/articles/fork-a-repo) for
40+
more details.
41+
42+
1. Clone your fork to your local computer (change `myname` to your account
43+
name):
4344

4445
```
4546
git clone [email protected]:myname/ggplot2.git
4647
cd ggplot2
4748
```
4849
49-
4. Once you've done that, you'll probably want to add the main repository
50-
as a remote:
50+
1. Once you've done that, add the main repository as a remote and set up
51+
the master branch to track the main ggplot2 repo. This will make it
52+
easier to keep up to date.
5153
5254
```
5355
git remote add hadley git://github.com/hadley/ggplot2.git
54-
git fetch hadley
56+
git branch --set-upstream master hadley/master
5557
```
5658
5759
Now on your local machine you have the local repository and two remote repositories: `origin` (the default), which is your personal ggplot2 repo at GitHub, and `hadley` which is Hadley's. You'll be able to push changes to your own repository only.
5860
59-
### Tracking a remote branch
60-
61-
It's a good idea to set up your `master` branch to track `hadley/master`. This make it easier to update your fork of ggplot2 when the main repo changes. Do the following:
62-
63-
```
64-
git checkout master
65-
git branch --set-upstream master hadley/master
66-
```
67-
68-
Then, each time you want to get up to date, run:
69-
70-
```
71-
git checkout master
72-
git pull
73-
```
74-
7561
### Development environment
7662
7763
You'll also need a copy of the packages I use for package development. Get them by running the following R code:
@@ -96,46 +82,13 @@ The key functions you'll use when working on ggplot2:
9682

9783
If you're using Rstudio, I highly recommend learning the keyboard shortcuts for these commands. You can find them in the `Build` menu.
9884

85+
## Making changes
9986

100-
## What makes a good pull request?
101-
102-
Pull requests will be evaluated against the following checklist:
103-
104-
```
105-
* [ ] Motivate the change in one paragraph, and include it in NEWS.
106-
In parenthesis, reference your github user name and this issue:
107-
`(@hadley, #1234)`
108-
* [ ] Check pull request only includes relevant changes.
109-
* [ ] Use the [official style](http://adv-r.had.co.nz/Style.html).
110-
* [ ] Update documentation and re-run roxygen2
111-
* [ ] Add test, if bug in non-graphical function
112-
* [ ] Add visual test, if bug in graphical function
113-
* [ ] Add minimal example, if new graphical feature
114-
```
115-
116-
These are explained in more detail below. This seems like a lot of work but don't worry if your pull request isn't perfect. It's a learning process and Winston and I will be on hand to help you out. A pull request is a process, and unless you've submitted a few in the past it's unlikely that your pull request will be accepted as is.
117-
118-
The most important thing is that your pull request clearly and concisely motivates the need for the change. Unfortunately neither Winston nor I have much time to work on ggplot2 these days, so you need to describe the problem and show how your pull request solves it as concisely as possible. You should also include this motivation in the `NEWS` file so that when a new release of ggplot2 comes out it's easy for users to see what's changed.
119-
120-
When you submit your pull request, check to make sure that you haven't accidentally included any unrelated changes. These make it harder to see exactly what's changed, and to evaluate any unexpected side effects.
121-
122-
Please follow the [official ggplot2 style](http://adv-r.had.co.nz/Style.html). Maintaing a consistent style across the whole code base makes it much easier to jump into the code. Similarly, please make sure you update the roxygen comments, and re-run `devtools::document()` on the code. Currently, ggplot2 uses the development version of roxygen2, which you can get with `install_github("klutometis/roxygen"). This will be available on CRAN in the near future.
123-
124-
If you're fixing a bug in a non-graphical function, please include a test. If you're adding a new graphical feature, please add a minimal example illustrating the feature.
125-
126-
Finally, ggplot2 is a mature package used by thousands of people. This means that it's basically impossible to change any existing functionality without breaking someone's code (or another package on CRAN). Because of this please don't submit pull requests that change existing behaviour. Instead, think about how you can add a new feature in a minimally invasive way.
127-
128-
129-
130-
## How to make changes on a new branch
131-
132-
When you want to make changes, you should work on a new branch. Otherwise things can get a bit confusing when it comes time to merge it into the main branch. You probably want to start with the `master` branch.
87+
When you want to make changes, you should work on a new branch. Otherwise things can get a bit confusing when it comes time to merge it into the main repo with a pull request. You probably want to start with the `master` branch.
13388

13489
```
13590
# Fetch the latest version of hadley/ggplot2
13691
git fetch hadley
137-
138-
# Check out the latest
13992
git checkout hadley/master
14093
```
14194

@@ -152,23 +105,12 @@ Now you can make your changes and commit them to this branch on your local repos
152105
When you feel like sharing your changes, push them to your GitHub repo:
153106

154107
```
155-
git push origin myfix
108+
git push
156109
```
157110

158111
Then you can submit a pull request if you want it to be integrated in the main branch.
159112

160-
## Resetting a branch
161-
162-
If you have made some changes to your master branch and want to get it back in line with hadley/master, do the following. Before you do this, be sure that you are willing to discard all your commits that diverge from hadley/master! It is possible to recover the commits using `git reflog`, but it's easier to not discard them in the first place.
163-
164-
```
165-
git checkout master
166-
git reset --hard hadley/master
167-
```
168-
169-
## Testing merges
170-
171-
If your branch has been running parallel to the main branch for a long time, it's possible that it won't merge properly. You can test it out by checking out the main branch and merging yourself.
113+
If you've been working on your for a while, it's possible that it won't merge properly because something has changed in both the main repo and in your branch. You can test it out by checking out the main branch and merging yourself.
172114

173115
First, make a new branch called `testmerge`, based off the main branch:
174116

@@ -194,7 +136,73 @@ git branch -D testmerge
194136

195137
If there are any merge conflicts, you may want to rebase your changes on top of the current master version, or just resolve the conflicts and commit it to your branch. Rebasing may make for a somewhat cleaner commit history, but there is a possibility of messing things up. If you want to be safe, you can just make a new branch and rebase that on top of the current master.
196138

197-
## Fetching a branch from someone else's repository
139+
## What makes a good pull request?
140+
141+
<!--
142+
* [ ] Motivate the change in one paragraph, and include it in NEWS.
143+
In parentheses, reference your github user name and this issue:
144+
`(@hadley, #1234)`
145+
* [ ] Check pull request only includes relevant changes.
146+
* [ ] Use the [official style](http://adv-r.had.co.nz/Style.html).
147+
* [ ] Update documentation and re-run roxygen2
148+
* [ ] Add test, if bug in non-graphical function
149+
* [ ] Add visual test, if bug in graphical function
150+
* [ ] Add minimal example, if new graphical feature
151+
152+
See http://docs.ggplot2.org/dev/vignettes/development.html for more details.
153+
--->
154+
155+
Pull requests will be evaluated against the a seven point checklist:
156+
157+
1. __Motivation__. Your pull request must clearly and concisely motivates the
158+
need for change. Unfortunately neither Winston nor I have much time to
159+
work on ggplot2 these days, so you need to describe the problem and show
160+
how your pull request solves it as concisely as possible.
161+
162+
Also include this motivation in `NEWS` so that when a new release of
163+
ggplot2 comes out it's easy for users to see what's changed. Add your
164+
item at the top of the file and use markdown for formatting. The
165+
news item should end with `(@yourGithubUsername, #the_issue_number)`.
166+
167+
1. __Only related changes__. Before you submit your pull request, please
168+
check to make sure that you haven't accidentally included any unrelated
169+
changes. These make it harder to see exactly what's changed, and to
170+
evaluate any unexpected side effects.
171+
172+
Each PR corresponds to a git branch, so if you expect to submit
173+
multiple changes make sure to create multiple branches. If you have
174+
multiple changes that depend on each other, start with the first one
175+
and don't submit any others until the first one has been processed.
176+
177+
1. __Use ggplot2 coding style__. Please follow the
178+
[official ggplot2 style](http://adv-r.had.co.nz/Style.html). Maintaing
179+
a consistent style across the whole code base makes it much easier to
180+
jump into the code.
181+
182+
1. If you're adding new parameters or a new function, you'll also need
183+
to document them with [roxygen](https://github.com/klutometis/roxygen).
184+
Make sure to re-run `devtools::document()` on the code before submitting.
185+
186+
Currently, ggplot2 uses the development version of roxygen2, which you
187+
can get with `install_github("klutometis/roxygen")`. This will be
188+
available on CRAN in the near future.
189+
190+
1. If fixing a bug or adding a new feature to a non-graphical function,
191+
please add a [testthat](https://github.com/hadley/testthat) unit test.
192+
193+
1. If fixing a bug in the visual output, please add a visual test.
194+
(Instructions to follow soon)
195+
196+
1. If you're adding a new graphical feature, please add a short example
197+
to the appropriate function.
198+
199+
This seems like a lot of work but don't worry if your pull request isn't perfect. It's a learning process and Winston and I will be on hand to help you out. A pull request is a process, and unless you've submitted a few in the past it's unlikely that your pull request will be accepted as is.
200+
201+
Finally, remember that ggplot2 is a mature package used by thousands of people. This means that it's extremely difficult (i.e. impossible) to change any existing functionality without breaking someone's code (or another package on CRAN). Please don't submit pull requests that change existing behaviour. Instead, think about how you can add a new feature in a minimally invasive way.
202+
203+
## Advanced techniques
204+
205+
### Fetching a branch from someone else's repository
198206

199207
Sometimes you will want to fetch a branch from someone's repository, but without going to the trouble of seting it up as a remote. This is handy if you just want to quickly try out a someone's work.
200208

@@ -207,15 +215,15 @@ git checkout FETCH_HEAD
207215

208216
Just doing the above won't create a local branch -- you'll be in "detached HEAD" state. If you'd like to create a local branch to work on, run (you can replace `somebranch` with whatever name you like):
209217

210-
```
218+
```
211219
git checkout -b somebranch
212220
```
213221

214-
## Adding other repositories as remotes
222+
### Adding other repositories as remotes
215223

216224
If you often work off of someone else's repository, it can be useful to add their repo as a *remote*. This makes it easier to fetch changes in their repository. If the person's GitHub account is `otherdevel`, you would do the following:
217225

218-
```
226+
```
219227
git remote add otherdevel git://github.com/otherdevel/ggplot2.git
220228
git fetch otherdevel
221229
@@ -228,15 +236,15 @@ If you don't want to follow them any more, run:
228236
git remote rm otherdevel
229237
```
230238

231-
## Delete a branch from GitHub
239+
### Delete a branch from GitHub
232240

233241
If you pushed a branch to your GitHub repo but it's no longer needed there, you can remove it with:
234242

235243
```
236244
git push origin :mybranch
237245
```
238246

239-
## Visualizing the development tree
247+
### Visualizing the development tree
240248

241249
GitHub has a very nice [development tree view](https://github.com/hadley/ggplot2/), but it of course only shows commits that have been pushed to GitHub. You may also want to view the tree on your local machine, to see how your local changes relate to the main tree. There are a number of programs out there that will do this.
242250

0 commit comments

Comments
 (0)