Skip to content

Commit dd5a76d

Browse files
Merge pull request #547 from UBC-DSCI/trevorcampbell-patch-1
add new workflows to readme
2 parents 08295e9 + 8826eed commit dd5a76d

File tree

1 file changed

+60
-65
lines changed

1 file changed

+60
-65
lines changed

README.md

Lines changed: 60 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,29 @@ This textbook is offered under
1313
the [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) License](https://creativecommons.org/licenses/by-nc-sa/4.0/).
1414
See [the license file](LICENSE.md) for more information.
1515

16-
## Contributing
16+
## Development
1717

18-
Primary development in this repository happens on the `main` branch. If you
19-
want to contribute to the book, please branch off of `main` and make a pull
20-
request into `main`.
18+
### Setup
2119

22-
The `production` branch contains the source material for the live, publicly
23-
viewable HTML book. The website is served from the `gh-pages` branch, which is
24-
automatically built from the `production` branch.
20+
Building the book requires Docker (instructors here: https://docs.docker.com/get-docker/)
2521

26-
### Update build environment
27-
You can update the build environment for the book by making changes to
28-
`Dockerfile` in the root of the repository in the `main` branch. If you push
29-
any changes to the `Dockerfile` on the `main` branch, GitHub will trigger a
30-
rebuild of the docker image, push it to DockerHub, and update the
31-
`build_html.sh` and `build_pdf.sh` scripts with the new image tag.
22+
### Build locally
3223

33-
### Update public html
34-
You can update the live, publicly viewable HTML book by making changes to any
35-
`*.Rmd` file, or any file in the `img/` or `data/` folders in the `production`
36-
branch. If you push any changes to these files/folders on the `production`
37-
branch, GitHub will trigger a rebuild of the public HTML site and push it to
38-
the `gh-pages` branch.
24+
You must have at least 8GB of RAM (and ideally more like 16GB RAM) to build the book.
3925

40-
## Building the book locally
41-
42-
In order to build the book, you need to install [Docker](https://docs.docker.com/get-docker/).
43-
You must have at least **8GB of RAM** (and ideally at least 16GB RAM) to build the book.
44-
45-
To build the **html version** of the book, navigate to the repository root folder and run
26+
You can build the HTML version of the book on your own machine by running
4627
```
4728
./build_html.sh
48-
```
49-
from the command line. This command automatically spawns a docker container
50-
with the `ubcdsci/intro-to-ds` image, renders the book within the container,
51-
and then stops the container. The book HTML files will be located in the `docs/` folder
52-
after the build completes. If you did not already have the `ubcdsci/intro-to-ds` image pulled,
53-
the script will automatically pull the image from DockerHub.
54-
55-
To build the **PDF version** of the book, instead run
29+
```
30+
in the root directory of this repository. The book can be viewed in your browser by opening the `docs/index.html` file.
31+
32+
You can build the PDF version of the book on your own machine by running
5633
```
5734
./build_pdf.sh
5835
```
59-
This command again spawns a docker container and render the PDF version of the book inside the container.
36+
in the root directory of this repository. The book can be viewed in a PDF reader by opening `docs/latex/python.pdf`.
6037

61-
### Working with RStudio (HTML only)
38+
#### Working with RStudio (HTML only)
6239

6340
If you want to edit the source material and build the book using RStudio, navigate to the repository root and run
6441
```
@@ -72,9 +49,40 @@ bookdown::render_book('index.Rmd', 'bookdown::gitbook')
7249
```
7350
When you are done working, make sure to type `docker-compose down` to shut down the container.
7451

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+
7583
## Style Guide
7684

77-
#### General
85+
### General
7886
- **80 character line limit!** This is necessary to make git diffs useful
7987
- numbers in text should be english words ("four common mistakes" not "4 common mistakes") unless there are units (40km, not forty km)
8088
- 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
9098
There are likely exceptions to this rule though.
9199
- Book titles in the text should be typeset in italics (e.g. *R for Data Science*)
92100

93-
#### Code blocks
101+
### Code blocks
94102
- Use the knitr label format `##-[name with only alphanumeric + hyphens]` where
95103
the `##` is the 2-digit chapter number, e.g. `03-test-name` for a label `test-name` in chapter 3
96104
- 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
115123
- use `slice`, `slice_min`, `slice_max` (not `top_n`)
116124
- just `pull(colname)`, don't `select` first
117125

118-
#### Section headings
126+
### Section headings
119127
- All (sub)section headings should be sentence case ("Loading a tabular data set", not "Loading a Tabular Data Set")
120128
- Make sure that subsections occur in 1-step hierarchies (no subsubsection directly below subsection, for example)
121129
- Make sure that `{-}` is used wherever unnumbered headings are required
@@ -126,11 +134,11 @@ bookdown::gitbook:
126134
toc_depth: 2
127135
```
128136

129-
#### Learning objectives
137+
### Learning objectives
130138
- when saying that students will do things in code, always say "in R"
131139
- "you will be able to" (not "students will be able to", "the reader will be able to")
132140

133-
#### Captions
141+
### Captions
134142
- captions should be sentence formatted and end with a period
135143
- If you have special characters (particularly underscores, quotation marks, plus signs, other LaTeX math symbols) make sure to separate
136144
the caption out of the code chunk like so
@@ -143,10 +151,10 @@ bookdown::gitbook:
143151
\`\`\`
144152
```
145153

146-
#### Equations
154+
### Equations
147155
- make sure all equations get capitalized labels ("Equation \\@ref(blah)", not "equation below" or "equation above")
148156

149-
#### Figures
157+
### Figures
150158
- make sure all figures get (capitalized) labels ("Figure \\@ref(blah)", not "figure below" or "figure above")
151159
- make sure all figures get captions
152160
- 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`.
160168
- 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)
161169
- cropping width for syntax diagrams is 1625 (done using `image_crop`)
162170

163-
#### Tables
171+
### Tables
164172
- make sure all tables get capitalized labels ("Table \\@ref(blah)", not "table below" or "table above")
165173
- make sure all tables get captions
166174
- make sure the row + column spacing is reasonable
167175
- Do not put links in table captions, it breaks pdf rendering
168176
- Do not put underscores in table captions, it breaks pdf rendering
169177

170-
#### Note boxes
178+
### Note boxes
171179
- note boxes should be typeset as quote boxes using `>` and start with **Note:**
172180

173-
#### Bibliography
181+
### Bibliography
174182
- do not put "et al" or "and others"; always use the full list of authors, BibTeX will choose how to abbreviate
175183
- read https://trevorcampbell.me/html/bibtex.html and make sure our bib follows this convention
176184

177-
#### Naming conventions
185+
### Naming conventions
178186
- K-means (not $K$-\*, K means, Kmeans)
179187
- 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
180188
- 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`.
191199
- numerical variable (not quantitative variable)
192200
- categorical variable (not class variable)
193201

194-
#### Punctuation
202+
### Punctuation
195203
- 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`
196204
- 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`
197205

198-
#### Common typos to check for
206+
### Common typos to check for
199207
- RMPSE: should be RMSPE
200208
- boostrap: should be bootstrap
201209

202-
#### Use American spelling
210+
### Use American spelling
203211
Generally the book uses American spelling. Some common British vs American and Canadian vs American gotchas:
204212
- o vs ou: neighbor and color (not neighbour and colour)
205213
- single vs double ell: labeling and labeled (not labelling and labelled)
206214
- z vs s: summarize (not summarise)
207215
- c vs s: defense (not defence)
208216
- er vs re: center (not centre)
209217

210-
#### Whitespace
218+
### Whitespace
211219
We need a line of whitespace before and after code fences (code surrounded by three backticks above and below). This is for readability,
212220
and it is essential for figure captions.
213221

214-
#### PDF Output
222+
### PDF Output
215223
These are absolute last steps when rendering the PDF output:
216224
- Look for and fix bad line breaks (e.g. with only one word on the next line, orphans, and widows)
217225
- 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:
226234
sense in the hardcopy book version (i.e. nothing like "click this"). Many links appear in the additional resources: make sure the
227235
text-replacement of the URL contains enough information for someone to find the resource (without being able to click the link)
228236

229-
#### HTML Output
237+
### HTML Output
230238
- Look for broken references (I *think* these end up as `??`)
231239
- 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:
235-
236-
```
237-
docker run --rm -it -p 8888:8888 -v $PWD:/home/rstudio/introduction-to-datascience ubcdsci/intro-to-ds jupyter notebook --ip=0.0.0.0 --allow-root
238-
```
239-
240-
## Repository Organization / Important Files
241-
- 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

Comments
 (0)