Main features of BiocBook
s
BiocBook
s created with the {BiocBook
}
package and hosted on GitHub are deployed and served on
the gh-pages
branch and a Docker image is available on ghcr.io.
BiocBook
s created with the {BiocBook
}
package and submitted to Bioconductor are directly
available for reading from the Bioconductor website.
Read the BiocBookDemo
example book to know more about BiocBook
s features.
Creating a BiocBook
A new BiocBook
should be created using the
init(new_package = "...")
function.
This function performs the following operations:
- It checks that the provided package name is available;
- It logs in the GitHub user accounts;
- It creates a new remote Github repository using the
BiocBook.template
from js2264/BiocBook
;
- It sets up Github Pages to serve the future books from the
gh-pages
branch;
- It clones the remote Github repository to a
local folder;
- It edits several placeholders from the template and commits the
changes.
library(BiocBook)
## Note that `.local = TRUE` is only set here for demonstration.
init("myNewBook", .local = TRUE)
#> ══ Running preflight checklist ═════════════════════════════════════════════════
#> ⠙ Checking that no folder named `myNewBook` already exists
#> ⠙ Checking package name availability
#> ✔ Package name `myNewBook` is available
#> ⠙ Checking package name availability! Dummy git configured
#> ⠙ Checking package name availability• git user: `dummy`
#> ⠙ Checking package name availability• git email: `[email protected]`
#> ⠙ Checking package name availability! No GitHub configured
#> ⠙ Checking package name availability• github user: NULL
#> ⠙ Checking package name availability• PAT: NULL
#> ⠙ Checking package name availability
#> ══ Initiating a new `BiocBook` ═════════════════════════════════════════════════
#> ⠙ Creating new repository from template provided in BiocBook `inst/` directory`
#> ✔ New local book `myNewBook` successfully created
#> ⠙ Creating new repository from template provided in BiocBook `inst/` directory`✔ Filled out `inst/assets/_book.yml` fields
#> ⠙ Creating new repository from template provided in BiocBook `inst/` directory`✔ Filled out `README.md` fields
#> ⠙ Creating new repository from template provided in BiocBook `inst/` directory`✔ Filled out `DESCRIPTION` fields
#> ⠙ Creating new repository from template provided in BiocBook `inst/` directory`ℹ Please finish editing the `DESCRIPTION` fields, including:
#> ⠙ Creating new repository from template provided in BiocBook `inst/` directory` • Title
#> ⠙ Creating new repository from template provided in BiocBook `inst/` directory` • Description
#> ⠙ Creating new repository from template provided in BiocBook `inst/` directory` • Authors@R
#> ⠙ Creating new repository from template provided in BiocBook `inst/` directory`✔ Filled out `inst/index.qmd` fields
#> ⠙ Creating new repository from template provided in BiocBook `inst/` directory`ℹ Please finish editing the `inst/index.qmd` fields, including the `Welcome` section
#> ⠙ Creating new repository from template provided in BiocBook `inst/` directory`ℹ The following files need to be committed:
#> • .Rbuildignore
#> • .github/
#> • DESCRIPTION
#> • Dockerfile
#> • LICENSE
#> • LICENSE.md
#> • NAMESPACE
#> • README.md
#> • inst/
#> • vignettes/
#> ✔ The new files have been commited to the `devel` branch.
#> ── NOTES ───────────────────────────────────────────────────────────────────────
#> ℹ If you wish to change the cover picture, please replace the following file:
#> • inst/assets/cover.png
#> ══ Results ═════════════════════════════════════════════════════════════════════
#> ✔ Local `BiocBook` directory successfully created : myNewBook
#> ! This book will be only available in local until a Github remote is set.
#>
#> # You can connect to the local directory as follows:
#> biocbook <- BiocBook('myNewBook')
The BiocBook
class
A BiocBook
object acts as a pointer to a local package
directory, with book chapters contained in a pages/
folder
as .qmd
files.
bb <- BiocBook("myNewBook")
bb
#> BiocBook object
#> - local path: /tmp/Rtmpr5x08i/Rbuildfa71e26b004/BiocBook/vignettes/myNewBook
#> - remote url:
#> - Title: myNewBook
#> - Releases(0):
#> - Chapters(1):
#> • Welcome [/inst/index.qmd]
Editing an existing BiocBook
BiocBook
objects can be modified using the following
helper functions:
add_preamble(biocbook)
to start writing a
preamble;
add_chapter(biocbook, title = "...")
to start writing a
new chapter;
edit_page(biocbook, page = "...")
to edit an existing
chapter.
add_preamble(bb, open = FALSE)
#> ✔ File created @ `/tmp/Rtmpr5x08i/Rbuildfa71e26b004/BiocBook/vignettes/myNewBook/inst/pages/preamble.qmd`
add_chapter(bb, title = 'Chapter 1', open = FALSE)
#> ✔ File created @ `/tmp/Rtmpr5x08i/Rbuildfa71e26b004/BiocBook/vignettes/myNewBook/inst/pages/chapter-1.qmd`
bb
#> BiocBook object
#> - local path: /tmp/Rtmpr5x08i/Rbuildfa71e26b004/BiocBook/vignettes/myNewBook
#> - remote url:
#> - Title: myNewBook
#> - Releases(0):
#> - Chapters(3):
#> • Welcome [/inst/index.qmd]
#> • Preamble [/inst/pages/preamble.qmd]
#> • Chapter 1 [/inst/pages/chapter-1.qmd]
preview(biocbook)
will compile (and cache) the book
locally. Use it to verify that your book renders correctly.
Publishing an existing BiocBook
As long as the local BiocBook
has been initiated with
init()
, the writer simply has to commit changes and push
them to the origin
remote.
In R
, this can be done as follows:
The different available versions published in the origin
gh-pages
branch can be listed using
status(biocbook)
.