Skip to content

Commit

Permalink
Merge pull request #1 from jangorecki/litedown
Browse files Browse the repository at this point in the history
new website from litedown, vignette with litedown
  • Loading branch information
jangorecki authored Oct 18, 2024
2 parents f6f197a + 17b669c commit 6cf2c62
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
^\.github$
^_litedown\.yml$
^pkgup$
23 changes: 9 additions & 14 deletions .github/workflows/pkgup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ jobs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
- name: cache-r-dependencies
uses: actions/cache@v3
Expand All @@ -31,28 +30,24 @@ jobs:
restore-keys: library-cache
- name: setup-r-dependencies
run: |
Rscript -e 'stopifnot(file.copy("DESCRIPTION", file.path(tdir<-tempdir(), "PACKAGES"))); db<-available.packages(paste0("file://", tdir)); deps<-setdiff(tools::package_dependencies(read.dcf("DESCRIPTION", fields="Package")[[1L]], db, which="most")[[1L]], installed.packages(priority="high")[,"Package"]); if (length(deps)) { ap<-available.packages()[,"Version"]; ap<-ap[names(ap) %in% deps]; if (!all(deps%in%names(ap))) stop("dependencies are not avaiable in repository: ",paste(setdiff(deps, names(ap)), collapse=", ")); ip<-installed.packages()[,"Version"]; ip<-ip[names(ip) %in% deps]; pkgs<-ap[deps]>ip[deps]; install.packages(names(pkgs[pkgs|is.na(pkgs)]), INSTALL_opts="--html") }'
Rscript -e 'stopifnot(file.copy("DESCRIPTION", file.path(tdir<-tempdir(), "PACKAGES"))); db<-available.packages(paste0("file://", tdir)); deps<-setdiff(tools::package_dependencies(read.dcf("DESCRIPTION", fields="Package")[[1L]], db, which="most")[[1L]], installed.packages(priority="high")[,"Package"]); if (length(deps)) { ap<-available.packages()[,"Version"]; ap<-ap[names(ap) %in% deps]; if (!all(deps%in%names(ap))) stop("dependencies are not avaiable in repository: ",paste(setdiff(deps, names(ap)), collapse=", ")); ip<-installed.packages()[,"Version"]; ip<-ip[names(ip) %in% deps]; pkgs<-ap[deps]>ip[deps]; install.packages(names(pkgs[pkgs|is.na(pkgs)])) }'
- name: build
run: |
echo "Revision:" $GITHUB_SHA >> ./DESCRIPTION
R CMD build .
- name: check
run: |
R CMD check --as-cran --no-manual $(ls -1t pkgup_*.tar.gz | head -n 1)
- name: manual
- name: website
if: github.ref == 'refs/heads/master'
run: |
cp -R ${{ env.R_LIBS_USER }} library
R CMD INSTALL --library="library" $(ls -1t pkgup_*.tar.gz | head -n 1) --html
mkdir -p doc/html
cp /usr/share/R/doc/html/{left.jpg,up.jpg,Rlogo.svg,R.css,index.html} doc/html
Rscript -e 'utils::make.packages.html("library", docdir="doc")'
sed -i "s|file://|../..|g" doc/html/packages.html
R CMD INSTALL $(ls -1t pkgup_*.tar.gz | head -n 1) ## seems to be required
Rscript -e 'invisible(file.copy("vignettes", "pkgup", recursive=TRUE))'
Rscript -e 'litedown::fuse_site("pkgup")'
mkdir -p public
mv doc public/doc
cp -r --parents library/*/{html,help,doc,demo,DESCRIPTION,README,NEWS,README.md,NEWS.md} public 2>/dev/null || :
sed -i 's|"/doc/html/|"/pkgup/doc/html/|g' public/library/pkgup/doc/index.html 2>/dev/null || :
echo '<!DOCTYPE html>\n<html><head><meta http-equiv="refresh" content="0; url=library/pkgup/html/00Index.html"><title>HTTP redirect</title></head><body></body></html>' > public/index.html
find pkgup -name '*.html' -print0 | cpio -pvdmB --null public
mv public/pkgup/* public
rm -r public/pkgup
- name: repo
if: github.ref == 'refs/heads/master'
run: |
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Package: pkgup
Version: 0.2.0
Version: 0.3.0
Title: Package Release
Authors@R: c(
person("Jan","Gorecki", role=c("aut","cre"), email="[email protected]"))
Description: Lightweight release of R packages on github.
License: GPL-2
URL: https://jangorecki.github.io/pkgup/
BugReports: https://github.com/jangorecki/pkgup/issues/
Suggests: knitr, markdown
VignetteBuilder: knitr
Suggests: litedown
VignetteBuilder: litedown
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
pkgup
----

Example package to present lightweight setup for R package release.
Example lightweight setup for R package release.
- [x] R package repository
- [x] html manual
- [x] html vignettes
- [x] R package documentation as html website
- [x] manual
- [x] news
- [x] vignettes

[R package documentation](https://jangorecki.github.io/pkgup)

Expand All @@ -17,9 +19,9 @@ Installation
install.packages("pkgup", repos="https://jangorecki.github.io/pkgup")
```

How to use
How to pkgup
----

Let's keep it light, no need to install.
Let's keep it light, no need to install.

See [howto vignette](https://jangorecki.github.io/pkgup/library/pkgup/doc/howto.html) for details.
See [howto vignette](https://jangorecki.github.io/pkgup/vignettes/howto.html) for details.
15 changes: 15 additions & 0 deletions pkgup/_litedown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output:
litedown::html_format:
options:
toc:
depth: 4
litedown::latex_format:
meta:
documentclass: "book"

book:
new_session: false
subdir: true
pattern: "[.]R?md$"
chapter_before: "Information before a chapter."
chapter_after: "This chapter was generated from `$input$`."
15 changes: 15 additions & 0 deletions pkgup/index.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
site:
rebuild: "outdated"
pattern: "[.]R?md$"
---

```{r, echo=FALSE}
litedown::pkg_desc()
```

To cite the package:

```{r, echo=FALSE}
litedown::pkg_citation()
```
3 changes: 3 additions & 0 deletions pkgup/manual.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```{r, echo=FALSE}
litedown::pkg_manual()
```
3 changes: 3 additions & 0 deletions pkgup/news.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```{r, echo=FALSE}
litedown::pkg_news(recent=0)
```
25 changes: 25 additions & 0 deletions pkgup/vignettes.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
```{r, echo=FALSE, results='asis'}
rmd = list.files("./vignettes", "*.Rmd", full.names=TRUE)
if (!length(rmd)) {
cat("no vignettes\n")
} else {
title = function(f) {
title1 = function(f) {
if (!file.exists(f))
stop("file ", f, " does not exists")
l = readLines(f)
t = paste(head(strsplit(basename(f), ".", fixed=TRUE)[[1L]], -1L), collapse=".") ## default, basename without extension
for (i in seq_along(l)) {
if (substr(l[i], 1L, 6L) != "title:")
next
t = trimws(gsub("title:", "", l[i], fixed=TRUE))
break
}
t
}
sapply(f, title1)
}
html = paste0(substr(rmd, 1L, nchar(rmd)-3L), "html")
lapply(html, function(f) cat(sprintf("[%s](%s)\n", title(rmd), f))) |> invisible()
}
```
15 changes: 11 additions & 4 deletions vignettes/howto.Rmd
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: "How to use pkgup"
title: "How to pkgup"
output:
markdown::html_vignette
litedown::html_vignette
vignette: >
%\VignetteIndexEntry{howto pkgup}
%\VignetteEngine{knitr::knitr}
%\VignetteEngine{litedown::vignette}
\usepackage[utf8]{inputenc}
---

Expand All @@ -30,4 +30,11 @@ Set _build and deployment_ source: _GitHub Actions_
## Push pkgup yaml to your package repo
Once _pkgup_ workflow complete, your R package source tarball should be published in CRAN-like repo at `https://namespace.github.io/yourpkg`. Base R html style manual and vignettes of your package as well, at the same address.
Once _pkgup_ workflow completes, your R package source tarball should be published in CRAN-like repo at `https://namespace.github.io/yourpkg`. Package desription, manual and vignettes will be published at the same address.

## Use R package repo

Then anyone can install package by pointing `repos` to your address.
```r
install.packages("yourpkg", repos="https://namespace.github.io/yourpkg")
```

0 comments on commit 6cf2c62

Please sign in to comment.