Skip to content

Commit

Permalink
undoing contraction changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
cathariv committed Aug 15, 2024
1 parent 305e5c0 commit 06f8f23
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 46 deletions.
34 changes: 17 additions & 17 deletions vignettes/customise.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ You can find the correct height by running `$(".navbar").outerHeight()` in the [
### bslib variables

Instead of picking a complete theme, you can tweak fonts and colours individually using bslib variables.
[bslib](https://rstudio.github.io/bslib/) is an R package that wraps scss, the tool that Boostrap uses to produce CSS from a special language called [scss](https://sass-lang.com).
The primary advantage of scss over CSS is that it is more programmable, so you can have a few key bslib variables that affect appearance of many HTML elements.
[bslib](https://rstudio.github.io/bslib/) is an R package that wraps sass, the tool that Boostrap uses to produce CSS from a special language called [scss](https://sass-lang.com).
The primary advantage of scss over CSS is that it's more programmable, so you can have a few key bslib variables that affect appearance of many HTML elements.

There are three key variables that affect the colour:

Expand All @@ -112,7 +112,7 @@ For example, `table-border-color` defaults to `border-color` which defaults to `
If you want to change the colour of all borders, you can set `border-color` and if you just want to change the colour of table borders, you can set `table-border-color`.
You can find a full list of variables in the [bslib docs](https://rstudio.github.io/bslib/articles/bs5-variables/index.html).

If you are using the light switch, [many colours](https://getbootstrap.com/docs/5.3/customize/color-modes/#sass-variables) are available for customisation specifically for the dark theme.
If you're using the light switch, [many colours](https://getbootstrap.com/docs/5.3/customize/color-modes/#sass-variables) are available for customisation specifically for the dark theme.

Theming with bslib is powered by `bslib::bs_theme()` and the `bslib` field is a direct translation of the arguments to that function.
As a result, you can fully specify a bslib theme using the `template.bslib` field, making it easy to share YAML with the `output.html_document.theme` field [of an R Markdown document](https://rstudio.github.io/bslib/articles/theming/index.html).
Expand Down Expand Up @@ -142,7 +142,7 @@ template:
code_font: {google: "JetBrains Mono"}
```

If you want to use a non-Google font, you will need to do a bit more work. There are two steps: you need to first configure the font with CSS and then use it in your `_pkgdown.yml`. There are two ways you might get the CSS:
If you want to use a non-Google font, you'll need to do a bit more work. There are two steps: you need to first configure the font with CSS and then use it in your `_pkgdown.yml`. There are two ways you might get the CSS:

* As a block of CSS which you should put in `pkgdown/extra.scss` or `pkgdown/extra.css`. The CSS will look something like this:

Expand Down Expand Up @@ -178,9 +178,9 @@ template:
base_font: proxima-nova
```

Depending on where the font is from (and if you purchased it), you may need to take additional steps to ensure that it can only be used from your site, and/or make sure that it can still be used when you're previewing locally. If you are having problems getting a custom font to work, looking for errors in the [browser developer console](https://developer.mozilla.org/en-US/docs/Glossary/Developer_Tools) is a good place to start.
Depending on where the font is from (and if you purchased it), you may need to take additional steps to ensure that it can only be used from your site, and/or make sure that it can still be used when you're previewing locally. If you're having problems getting a custom font to work, looking for errors in the [browser developer console](https://developer.mozilla.org/en-US/docs/Glossary/Developer_Tools) is a good place to start.

When iterating on fonts, you will need to run `build_home_index(); init_site()` then refresh your browser to see the update.
When iterating on fonts, you'll need to run `build_home_index(); init_site()` then refresh your browser to see the update.


### Syntax highlighting
Expand Down Expand Up @@ -243,12 +243,12 @@ navbar:
bg: primary
```

You generally don not need to set `bg` if you use a bootswatch theme, as pkgdown will pick the `bg` used on the [Bootstwatch preview](https://bootswatch.com/).
Similarly, you do not usually need to set `type` because bootstrap will guess it for you.
You generally don't need to set `bg` if you use a bootswatch theme, as pkgdown will pick the `bg` used on the [Bootstwatch preview](https://bootswatch.com/).
Similarly, you don't usually need to set `type` because bootstrap will guess it for you.
If the guess is wrong, you can override with `type: light` or `type: dark` depending on whether the background colour is light (so you need dark text) or `type: dark` if the background is dark (so you need light text).
Unfortunately, these are defined relative to the page background, so if you have a dark site you will need to flip `light` and `dark` (a little experimentation should quickly determine what looks best).
Unfortunately, these are defined relative to the page background, so if you have a dark site you'll need to flip `light` and `dark` (a little experimentation should quickly determine what looks best).

Because the navbar is styled with HTML, you will need to `build_home_index(); init_site()` to see the effect of changing this parameter.
Because the navbar is styled with HTML, you'll need to `build_home_index(); init_site()` to see the effect of changing this parameter.

## Layout {#layout}

Expand All @@ -259,7 +259,7 @@ They all use a similar structure that separately defines the overall `structure`
### Navbar {#navbar-heading}

You can customise the navigation bar that appears at the top of the page with the `navbar` field.
It is made up of two pieces: `structure`, which defines the overall layout, and `components`, which defines what each piece looks like.
It's made up of two pieces: `structure`, which defines the overall layout, and `components`, which defines what each piece looks like.
This organisation makes it easy to mix and match pkgdown defaults with your own customisations.

This is the default structure:
Expand All @@ -282,7 +282,7 @@ It makes use of the the following built-in components:
- `github`: a link to the source repository (with an icon), if it can be automatically determined from the `DESCRIPTION`.
- `lightswitch`; a ["light switch"](#light-switch) to select light mode, dark mode, or auto mode.

Note that customising `navbar` like this comes with a downside: if pkgdown later changes the defaults, you will have to update your `_pkgdown.yml`.
Note that customising `navbar` like this comes with a downside: if pkgdown later changes the defaults, you'll have to update your `_pkgdown.yml`.

[^dots]: Note that dots (`.`) in the package name need to be replaced by hyphens (`-`) in the vignette filename to be recognized as the intro. That means for a
package `foo.bar` the intro needs to be named `foo-bar.Rmd`.
Expand Down Expand Up @@ -360,7 +360,7 @@ You can also customise the colour scheme of the navbar by using the `type` and `
### Footer

You can customise the footer with the `footer` field.
It is made up of two pieces: `structure`, which defines the overall layout, and `components`, which defines what each piece looks like.
It's made up of two pieces: `structure`, which defines the overall layout, and `components`, which defines what each piece looks like.
This organisation makes it easy to mix and match the pkgdown defaults with your own customisations.

This is the default structure:
Expand Down Expand Up @@ -427,7 +427,7 @@ It can contain any of the following:
- A configuration file in `inst/pkgdown/_pkgdown.yml`. This can be used to set (e.g.) author definitions, Bootstrap version and variables, the sidebar, footer, navbar, etc.
- Templates in `inst/pkgdown/templates/` will override the default templates.
- Assets in `inst/pkgdown/assets/` will be copied in to the destination directory.
(Note these files are only copied; you will need to reference them in your stylesheet or elsewhere in order for them to be actually used.)
(Note these files are only copied; you'll need to reference them in your stylesheet or elsewhere in order for them to be actually used.)
- `inst/pkgdown/extra.scss` will be added to the bslib ruleset.
(Note that `extra.css` is not supported in templates.)

Expand All @@ -440,7 +440,7 @@ template:
package: theverybest
```

You then also need to make sure it is available when your site is built. Typically, you will not want to publish this package to CRAN, but you will want to publish to GitHub. Once you have done that, and assuming you are using the [usethis workflow](https://usethis.r-lib.org/reference/use_pkgdown.html), add the following line to your `DESCRIPTION`:
You then also need to make sure it's available when your site is built. Typically, you won't want to publish this package to CRAN, but you will want to publish to GitHub. Once you've done that, and assuming you're using the [usethis workflow](https://usethis.r-lib.org/reference/use_pkgdown.html), add the following line to your `DESCRIPTION`:

```yaml
Config/Needs/website: myorg/theverybest
Expand All @@ -454,11 +454,11 @@ To get some sense of how a theming package works, you can look at:
- [quillt](https://pkgs.rstudio.com/quillt) used for R Markdown packages;
- [rotemplate](https://github.com/ropensci-org/rotemplate) used for rOpenSci packages.

But please note that these templates are not suitable for use with your own package as they are all designed to give a common visual identity to a specific family of packages.
But please note that these templates aren't suitable for use with your own package as they're all designed to give a common visual identity to a specific family of packages.

### Porting a template package

If you are updating a template package that works with pkgdown 1.0.0, create directories `inst/pkgdown/BS5/templates` and `inst/pkgdown/BS5/assets` (if you do not have any templates/assets make sure to a add dummy file to ensure that git tracks them).
If you are updating a template package that works with pkgdown 1.0.0, create directories `inst/pkgdown/BS5/templates` and `inst/pkgdown/BS5/assets` (if you don't have any templates/assets make sure to a add dummy file to ensure that git tracks them).
The `templates` and `assets` directories directly under `inst/pkgdown` will be used by pkgdown 1.0.0 and by pkgdown 2.0.0 if `boostrap: 3`.
The directories under `inst/pkgdown/BS5/` will be used for pkgdown 2.0.0 with `boostrap: 5`.
This lets your package support both versions of Bootstrap and pkgdown.
Expand Down
36 changes: 18 additions & 18 deletions vignettes/how-to-update-released-site.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,29 @@ knitr::opts_chunk$set(

This vignette shows you how to update the released version of your site to match the dev version of the site, so the first step is to ensure that the dev site looks the way that you want it.

This site assumes that you are using a recent version of our recommended [pkgdown action](https://github.com/r-lib/actions/blob/HEAD/examples/pkgdown.yaml). If your workflow does not contain `workflow_dispatch`, you will need to update `.github/actions/pkgdown.yaml` by running `use_github_action("pkgdown")`.
This site assumes that you're using a recent version of our recommended [pkgdown action](https://github.com/r-lib/actions/blob/HEAD/examples/pkgdown.yaml). If your workflow does not contain `workflow_dispatch`, you will need to update `.github/actions/pkgdown.yaml` by running `use_github_action("pkgdown")`.

## Process

If you are up to speed with the basic idea and just want some code to follow, here it is.
If you're up to speed with the basic idea and just want some code to follow, here it is.
Otherwise, read more below.

### Setup

First, make sure you are in the `main` branch, and you have the latest version:
First, make sure you're in the `main` branch, and you have the latest version:

```{r}
gert::git_branch_checkout("main")
gert::git_pull()
```

Next figure out the released version that you are updating:
Next figure out the released version that you're updating:

```{r}
ver <- desc::desc_get_version()[1, 1:3]
```

You will use this to create and checkout the branch that you will work in:
You will use this to create and checkout the branch that you'll work in:

```{r}
gert::git_branch_create(paste0("pkgdown-v", ver), paste0("v", ver))
Expand Down Expand Up @@ -70,7 +70,7 @@ files <- c(
glue::glue("git checkout v{ver} -- {files}")
```

If you backport `DESCRIPTION`, you will also need undo the change to the `Version`:
If you backport `DESCRIPTION`, you'll also need undo the change to the `Version`:

```{r}
desc::desc_set_version(ver)
Expand All @@ -97,7 +97,7 @@ Then trigger the pkgdown workflow:
2. Select the pkgdown workflow.
3. Click *Run workflow* and select the branch you just pushed.

If there is no dropdown menu for this, that means your pkgdown workflow config is not current.
If there's no dropdown menu for this, that means your pkgdown workflow config is not current.

## Context

Expand All @@ -124,7 +124,7 @@ This directs pkgdown to "generate different sites for the development and releas
The readr package demonstrates what happens in automatic development mode:
[readr.tidyverse.org](https://readr.tidyverse.org) documents the released version, i.e. what `install.packages()` will deliver.\
[readr.tidyverse.org/dev/](https://readr.tidyverse.org/dev/) documents the dev version, i.e. what you would get by installing from GitHub.
[readr.tidyverse.org/dev/](https://readr.tidyverse.org/dev/) documents the dev version, i.e. what you'd get by installing from GitHub.

In this mode, `pkgdown::build_site()`, consults DESCRIPTION to learn the package's version number.
For a development version number, the rendered site is written to `docs/dev/`.
Expand All @@ -135,9 +135,9 @@ Automatic development mode is recommended for packages with a broad user base be

### Publishing

Now that we have established the meaning of a released (vs dev) site, we have to consider how the site is built (i.e. how the HTML is generated) and deployed (i.e. how the HTML is published to a website so people can see it.).
Now that we've established the meaning of a released (vs dev) site, we have to consider how the site is built (i.e. how the HTML is generated) and deployed (i.e. how the HTML is published to a website so people can see it.).

We recommend `usethis::use_pkgdown_github_pages()` to do basic pkgdown setup and configure a GitHub Actions (GHA) workflow to automatically render and publish the site to GitHub Pages. This function is bascially a shortcut for calling the following functions individually:
We recommend `usethis::use_pkgdown_github_pages()` to do basic pkgdown setup and configure a GitHub Actions (GHA) workflow to automatically render and publish the site to GitHub Pages. This function is basically a shortcut for calling the following functions individually:

* `use_pkgdown()`
* `use_github_pages()`
Expand Down Expand Up @@ -176,16 +176,16 @@ Altogether this means that we:

* Build and deploy for pushes to `main`.

* Build, but do not deploy, for pull requests against `main`.
This reveals any pkgdown errors, but ensures the live site is not
* Build, but don't deploy, for pull requests against `main`.
This reveals any pkgdown errors, but ensures the live site isn't
updated until the pull request is merged (because the code is
pushed to `main`).

* Build and deploy when we publish a GitHub release.
By convention, we assume that a GitHub release coincides with a CRAN release.
So this is the **primary mechanism for building the released pkgdown site**.

`pkgdown::build_site_github_pages()` consults the version in DESCRIPTION to detect whether it is building from a released version or a dev version.
`pkgdown::build_site_github_pages()` consults the version in DESCRIPTION to detect whether it's building from a released version or a dev version.
That determines the `dest_dir`, e.g. `docs/` for released and `docs/dev/` for dev.
For a package in automatic development mode, this means that almost all of your pushes trigger an update to the dev site.
The released site is only updated when you push a state with a non-development version number or when you publish a GitHub release.
Expand Down Expand Up @@ -223,8 +223,8 @@ Files you must update:

Other likely candidates:

- `README.Rmd` + `README.md`, e.g., if you have updated badges.
- Any documentation fixes that **apply to the released version**. This is the only reason to touch anything below `R/` and even then it should only affect roxygen comments. Do not forget to `document()` if you do this!
- `README.Rmd` + `README.md`, e.g., if you've updated badges.
- Any documentation fixes that **apply to the released version**. This is the only reason to touch anything below `R/` and even then it should only affect roxygen comments. Don't forget to `document()` if you do this!
- Any new vignettes or articles that apply to the released version.

Here are some tips on backporting specific changes into this branch.
Expand All @@ -235,7 +235,7 @@ In that case, we can cherry pick such a commit by its SHA:
git cherry-pick SHA
```

If that does not cover everything for each file you want to update, identify a Git reference (meaning: a SHA, tag, or branch) where the file is in the desired state.
If that doesn't cover everything for each file you want to update, identify a Git reference (meaning: a SHA, tag, or branch) where the file is in the desired state.
Checkout that specific file path from that specific ref:

```
Expand All @@ -251,7 +251,7 @@ git checkout main -- vignettes/column-types.Rmd

Commit and push this new branch to GitHub.
`usethis::pr_push()` can be handy for this.
Just do not bother opening a pull request (the branch will still be pushed).
Just don't bother opening a pull request (the branch will still be pushed).

Now we will use the `workflow_dispatch` GHA trigger:

Expand All @@ -262,7 +262,7 @@ Now we will use the `workflow_dispatch` GHA trigger:

This should kick off a pkgdown build-and-deploy and, specifically, it should cause updates to the **released** site.

You can keep this branch around for a while, in case you did not get everything right the first time or if more things crop up that you'd like backport to the released site, before your next CRAN release.
You can keep this branch around for a while, in case you didn't get everything right the first time or if more things crop up that you'd like backport to the released site, before your next CRAN release.

## Problem-solving

Expand Down
2 changes: 1 addition & 1 deletion vignettes/linking.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ knitr::opts_chunk$set(

## Within a package

pkgdown will automatically link to documentation and articles wherever it is possible to do unambiguously. This includes:
pkgdown will automatically link to documentation and articles wherever it's possible to do unambiguously. This includes:

* Bare function calls, like `build_site()`.
* Calls to `?`, like `?build_site` or `package?pkgdown`.
Expand Down
Loading

0 comments on commit 06f8f23

Please sign in to comment.