You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you are done working, make sure to type `docker-compose down` to shut down the container.
74
51
52
+
### Contributing
53
+
54
+
Primary development in this repository happens on the `main` branch. If you want to contribute to the book,
55
+
please branch off of `main` and make a pull request into `main`. You cannot commit directly to `main`.
56
+
57
+
The `production` branch contains the source material corresponding to the current publicly-viewable version of the book website.
58
+
59
+
The `gh-pages` branch serves the current book website at https://datasciencebook.ca.
60
+
61
+
### Workflows
62
+
63
+
#### Book deployment
64
+
65
+
You can update the live, publicly viewable HTML book by making changes to the `source/` folder in the `production` branch (e.g. by merging `main` into `production`).
66
+
GitHub will trigger a rebuild of the public HTML site, and store the built book in the root folder of the `gh-pages` branch.
67
+
68
+
#### `main` deploy previews
69
+
70
+
Any commit to `source/**` on the `main` branch (from a merged PR) will trigger a rebuild of the development preview site served at `https://datasciencebook.ca/dev`.
71
+
The built preview book will be stored in the `dev/` folder on the `gh-pages` branch.
72
+
73
+
#### PR deploy previews
74
+
75
+
Any PR to `source/` will trigger a build of a PR preview site at `https://datasciencebook.ca/pull###`, where `###` is the number of the pull request.
76
+
The built preview book will be stored in the `pull###/` folder on the `gh-pages` branch.
77
+
78
+
#### Build environment updates
79
+
80
+
Any PR to `Dockerfile` will trigger a rebuild of the docker image, push it to DockerHub, and update the image tags in the `build_html.sh` and `build_pdf.sh` scripts on the PR automatically.
81
+
This new build environment will be used for the PR deploy preview mentioned above.
82
+
75
83
## Style Guide
76
84
77
-
####General
85
+
### General
78
86
-**80 character line limit!** This is necessary to make git diffs useful
79
87
- numbers in text should be english words ("four common mistakes" not "4 common mistakes") unless there are units (40km, not forty km)
80
88
- use Oxford commas ("a, b, and c" not "a, b and c")
@@ -90,7 +98,7 @@ When you are done working, make sure to type `docker-compose down` to shut down
90
98
There are likely exceptions to this rule though.
91
99
- Book titles in the text should be typeset in italics (e.g. *R for Data Science*)
92
100
93
-
####Code blocks
101
+
### Code blocks
94
102
- Use the knitr label format `##-[name with only alphanumeric + hyphens]` where
95
103
the `##` is the 2-digit chapter number, e.g. `03-test-name` for a label `test-name` in chapter 3
96
104
- Make sure to get syntax highlighting by specifying the language in each code block:
@@ -115,7 +123,7 @@ When you are done working, make sure to type `docker-compose down` to shut down
115
123
- use `slice`, `slice_min`, `slice_max` (not `top_n`)
116
124
- just `pull(colname)`, don't `select` first
117
125
118
-
#### Section headings
126
+
### Section headings
119
127
- All (sub)section headings should be sentence case ("Loading a tabular data set", not "Loading a Tabular Data Set")
120
128
- Make sure that subsections occur in 1-step hierarchies (no subsubsection directly below subsection, for example)
121
129
- Make sure that `{-}` is used wherever unnumbered headings are required
@@ -126,11 +134,11 @@ bookdown::gitbook:
126
134
toc_depth: 2
127
135
```
128
136
129
-
#### Learning objectives
137
+
### Learning objectives
130
138
- when saying that students will do things in code, always say "in R"
131
139
- "you will be able to" (not "students will be able to", "the reader will be able to")
132
140
133
-
#### Captions
141
+
### Captions
134
142
- captions should be sentence formatted and end with a period
135
143
- If you have special characters (particularly underscores, quotation marks, plus signs, other LaTeX math symbols) make sure to separate
136
144
the caption out of the code chunk like so
@@ -143,10 +151,10 @@ bookdown::gitbook:
143
151
\`\`\`
144
152
```
145
153
146
-
#### Equations
154
+
### Equations
147
155
- make sure all equations get capitalized labels ("Equation \\@ref(blah)", not "equation below" or "equation above")
148
156
149
-
#### Figures
157
+
### Figures
150
158
- make sure all figures get (capitalized) labels ("Figure \\@ref(blah)", not "figure below" or "figure above")
151
159
- make sure all figures get captions
152
160
- specify image widths of pngs and jpegs in terms of linewidth percent
@@ -160,21 +168,21 @@ for plots we create in R use `fig.width` and `fig.height`.
160
168
- Fig size for bar charts should be: `fig.width=5, fig.height=3` (an exception are figs 1.7 & 1.8 so that we can read the axis labels)
161
169
- cropping width for syntax diagrams is 1625 (done using `image_crop`)
162
170
163
-
#### Tables
171
+
### Tables
164
172
- make sure all tables get capitalized labels ("Table \\@ref(blah)", not "table below" or "table above")
165
173
- make sure all tables get captions
166
174
- make sure the row + column spacing is reasonable
167
175
- Do not put links in table captions, it breaks pdf rendering
168
176
- Do not put underscores in table captions, it breaks pdf rendering
169
177
170
-
#### Note boxes
178
+
### Note boxes
171
179
- note boxes should be typeset as quote boxes using `>` and start with **Note:**
172
180
173
-
#### Bibliography
181
+
### Bibliography
174
182
- do not put "et al" or "and others"; always use the full list of authors, BibTeX will choose how to abbreviate
175
183
- read https://trevorcampbell.me/html/bibtex.html and make sure our bib follows this convention
176
184
177
-
#### Naming conventions
185
+
### Naming conventions
178
186
- K-means (not $K$-\*, K means, Kmeans)
179
187
- K-nearest neighbors (not $K$-\*, K nearest neighbors, K nearest neighbor, use US spelling neighbor not neighbour). Note that "K-nearest neighbor" is not the singular form; "K-nearest neighbors" is
180
188
- K-NN (not $K$-\*, KNN, K NN, $K$NN, K-nn)
@@ -191,27 +199,27 @@ for plots we create in R use `fig.width` and `fig.height`.
191
199
- numerical variable (not quantitative variable)
192
200
- categorical variable (not class variable)
193
201
194
-
#### Punctuation
202
+
### Punctuation
195
203
- emdashes should have no surrounding spaces. `This kind of typesetting—which is awesome—is correct!` and `Typesetting with spaces around em-dashes — which is bad — is not correct`
196
204
- make sure `\index` commands don't break punctuation spacing. E.g. `This is an item \index{item}; it is good` will typeset with an erroneous space after item, i.e. `This is an item ; it is good`
197
205
198
-
#### Common typos to check for
206
+
### Common typos to check for
199
207
- RMPSE: should be RMSPE
200
208
- boostrap: should be bootstrap
201
209
202
-
#### Use American spelling
210
+
### Use American spelling
203
211
Generally the book uses American spelling. Some common British vs American and Canadian vs American gotchas:
204
212
- o vs ou: neighbor and color (not neighbour and colour)
205
213
- single vs double ell: labeling and labeled (not labelling and labelled)
206
214
- z vs s: summarize (not summarise)
207
215
- c vs s: defense (not defence)
208
216
- er vs re: center (not centre)
209
217
210
-
#### Whitespace
218
+
### Whitespace
211
219
We need a line of whitespace before and after code fences (code surrounded by three backticks above and below). This is for readability,
212
220
and it is essential for figure captions.
213
221
214
-
#### PDF Output
222
+
### PDF Output
215
223
These are absolute last steps when rendering the PDF output:
216
224
- Look for and fix bad line breaks (e.g. with only one word on the next line, orphans, and widows)
217
225
- Look for and fix bad line wraps in code and text
@@ -226,19 +234,6 @@ These are absolute last steps when rendering the PDF output:
226
234
sense in the hardcopy book version (i.e. nothing like "click this"). Many links appear in the additional resources: make sure the
227
235
text-replacement of the URL contains enough information for someone to find the resource (without being able to click the link)
228
236
229
-
#### HTML Output
237
+
### HTML Output
230
238
- Look for broken references (I *think* these end up as `??`)
231
239
- Look for uncentered images
232
-
233
-
## Updating the textbook data
234
-
Data sets are collected and curated by `data/retrieve_data.ipynb`. To run that notebook in the Docker container type the following in the terminal:
- The files `index.Rmd` and `##-name.Rmd` are [R-markdown](https://rmarkdown.rstudio.com/) chapter contents to be parsed by [Bookdown](https://bookdown.org/)
242
-
- `_bookdown.yml` sets the output directory (`docs/`) and default chapter name
243
-
- `img/` contains custom images to be used in the text; note this is not all of the images as some are generated by R code when compiling
244
-
- `data/` stores datasets processed during compile
0 commit comments