From 4a6af760e6b85b75af6f595d0b53c9c1a4822002 Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Wed, 15 Nov 2023 14:21:14 +0100 Subject: [PATCH] increment version --- .buildlibrary | 2 +- .github/workflows/check.yaml | 97 ++++++++++-------------------------- .pre-commit-config.yaml | 4 +- CITATION.cff | 4 +- DESCRIPTION | 4 +- R/helper_functions.R | 54 ++++++++++---------- README.md | 6 +-- man/createModulePage.Rd | 2 +- man/dot-section.Rd | 29 +++++++++++ man/extractDocumentation.Rd | 6 +-- vignettes/goxygen.Rmd | 6 +-- 11 files changed, 97 insertions(+), 117 deletions(-) create mode 100644 man/dot-section.Rd diff --git a/.buildlibrary b/.buildlibrary index 3801552..991e5ab 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '2603874' +ValidationKey: '2754640' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index fcd7136..870f216 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -1,5 +1,3 @@ -# Run CI for R using https://eddelbuettel.github.io/r-ci/ - name: check on: @@ -8,11 +6,6 @@ on: pull_request: branches: [main, master] -env: - USE_BSPM: "true" - _R_CHECK_FORCE_SUGGESTS_: "false" - NO_BINARY_INSTALL_R_PACKAGES: 'c("madrat", "magclass", "citation", "gms", "goxygen", "GDPuc", "roxygen2")' - jobs: check: runs-on: ubuntu-latest @@ -20,80 +13,38 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Bootstrap - run: | - sudo chown runner -R . - sudo locale-gen en_US.UTF-8 - sudo add-apt-repository -y ppa:ubuntugis/ppa - curl -OLs https://eddelbuettel.github.io/r-ci/run.sh - chmod 0755 run.sh - ./run.sh bootstrap - rm -f bspm_*.tar.gz - - - name: Enable r-universe repo, modify bspm integration - run: | - # install packages from https://pik-piam.r-universe.dev and CRAN - echo ' - options(repos = c(universe = "https://pik-piam.r-universe.dev", - CRAN = "https://cloud.r-project.org")) - ' >> .Rprofile - cat .Rprofile - # modify bspm integration to never install binary builds of PIK CRAN packages - sudo sed -i '/bspm::enable()/d' /etc/R/Rprofile.site - # need double % because of printf, %s is replaced with "$NO_BINARY_INSTALL_R_PACKAGES" (see "env:" above) - printf ' - local({ - expr <- quote({ - if (!is.null(repos)) { - noBinaryInstallRPackages <- %s - pkgs <- c(bspm::install_sys(pkgs[!pkgs %%in%% noBinaryInstallRPackages]), - pkgs[pkgs %%in%% noBinaryInstallRPackages]) - } - type <- "source" - }) - trace(utils::install.packages, expr, print = FALSE) - }) - ' "$NO_BINARY_INSTALL_R_PACKAGES" | sudo tee --append /etc/R/Rprofile.site >/dev/null - cat /etc/R/Rprofile.site - - - name: Set up Pandoc - uses: r-lib/actions/setup-pandoc@v2 + - uses: r-lib/actions/setup-pandoc@v2 - - name: Set up Python 3.9 - uses: actions/setup-python@v4 + - uses: r-lib/actions/setup-r@v2 with: - python-version: 3.9 + use-public-rspm: true + extra-repositories: "https://rse.pik-potsdam.de/r/packages" - - name: Cache R libraries - if: ${{ !env.ACT }} # skip when running locally via nektos/act - uses: pat-s/always-upload-cache@v3 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: /usr/local/lib/R/ - key: 3-${{ runner.os }}-usr-local-lib-R-${{ hashFiles('DESCRIPTION') }} - restore-keys: | - 3-${{ runner.os }}-usr-local-lib-R- - - - name: Restore R library permissions - run: | - sudo chmod 2777 /usr/local/lib/R /usr/local/lib/R/site-library - - - name: Install dependencies - run: | - ./run.sh install_aptget libhdf5-dev libharfbuzz-dev libfribidi-dev - ./run.sh install_all - ./run.sh install_r_binary covr rstudioapi - ./run.sh install_r lucode2 + extra-packages: | + gamstransfer=?ignore + any::lucode2 + any::covr + any::madrat + any::magclass + any::citation + any::gms + any::goxygen + any::GDPuc + # piam packages also available on CRAN (madrat, magclass, citation, + # gms, goxygen, GDPuc) will usually have an outdated binary version + # available; by using extra-packages we get the newest version + + - uses: actions/setup-python@v4 + with: + python-version: 3.9 - name: Install python dependencies if applicable run: | [ -f requirements.txt ] && python -m pip install --upgrade pip wheel || true [ -f requirements.txt ] && pip install -r requirements.txt || true - - name: Remove bspm integration # to get rid of error when running install.packages - run: | - sudo sed -i '/ trace(utils::install.packages, expr, print = FALSE)/d' /etc/R/Rprofile.site - cat /etc/R/Rprofile.site - - name: Verify validation key shell: Rscript {0} run: lucode2:::validkey(stopIfInvalid = TRUE) @@ -106,6 +57,8 @@ jobs: - name: Test coverage shell: Rscript {0} - run: covr::codecov(quiet = FALSE) + run: | + nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps")) + if(length(nonDummyTests) > 0) covr::codecov(quiet = FALSE) env: NOT_CRAN: "true" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9c3b069..2f13466 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ exclude: '^tests/testthat/_snaps/.*$' repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-case-conflict - id: check-json @@ -15,7 +15,7 @@ repos: - id: mixed-line-ending - repo: https://github.com/lorenzwalthert/precommit - rev: v0.3.2.9013 + rev: v0.3.2.9025 hooks: - id: parsable-R - id: deps-in-desc diff --git a/CITATION.cff b/CITATION.cff index 01867e2..4d3c4d9 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,8 +2,8 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'goxygen: In-Code Documentation for ''GAMS''' -version: 1.3.3 -date-released: '2023-08-09' +version: 1.4.0 +date-released: '2023-11-15' abstract: A collection of tools which extract a model documentation from 'GAMS' code and comments. In order to use the package you need to install 'pandoc' and 'pandoc-citeproc' first (). diff --git a/DESCRIPTION b/DESCRIPTION index f7ac6bc..7dc1b6d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: goxygen Type: Package Title: In-Code Documentation for 'GAMS' -Version: 1.3.3 -Date: 2023-08-09 +Version: 1.4.0 +Date: 2023-11-15 Authors@R: c(person("Jan Philipp", "Dietrich", email = "dietrich@pik-potsdam.de", role = c("aut","cre")), person("Kristine", "Karstens", email = "karstens@pik-potsdam.de", role = "aut"), person("David", "Klein", email = "dklein@pik-potsdam.de", role = "aut"), diff --git a/R/helper_functions.R b/R/helper_functions.R index 123b204..358b04f 100644 --- a/R/helper_functions.R +++ b/R/helper_functions.R @@ -8,7 +8,7 @@ #' @export #' .empty <- function(zz) { - writeLines("",zz) + writeLines("", zz) } #' .write @@ -20,8 +20,8 @@ #' @author Jan Philipp Dietrich #' @seealso \code{\link{goxygen}}, \code{\link{createModulePage}} #' -.write <- function(zz,data) { - if(!is.null(data)) writeLines(data,zz) +.write <- function(zz, data) { + if (!is.null(data)) writeLines(data, zz) .empty(zz) } @@ -36,19 +36,19 @@ #' @author Jan Philipp Dietrich #' @seealso \code{\link{goxygen}}, \code{\link{createModulePage}} #' -.header <- function(zz,title,level,id=NULL) { - if(length(title)>1) { +.header <- function(zz, title, level, id = NULL) { + if (length(title) > 1) { warning("Multiline entry to title detected. Only first line will be used!") title <- title[1] } - if(!is.null(id)) id <- paste0(" {#id-",id,"}") - if(level<3) { - writeLines(paste0(title,id),zz) - symbol <- ifelse(level==1,"=","-") - writeLines(paste(rep(symbol,nchar(title)), collapse=""),zz) + if (!is.null(id)) id <- paste0(" {#id-", id, "}") + if (level < 3) { + writeLines(paste0(title, id), zz) + symbol <- ifelse(level == 1, "=", "-") + writeLines(paste(rep(symbol, nchar(title)), collapse = ""), zz) } else { - start <- paste(rep("#",level),collapse="") - writeLines(paste(start,title),zz) + start <- paste(rep("#", level), collapse = "") + writeLines(paste(start, title), zz) } .empty(zz) } @@ -68,7 +68,7 @@ #' @seealso \code{\link{goxygen}}, \code{\link{createModulePage}} #' .section <- function(data, zz, title, level, id = NULL) { - if(!is.null(data)){ + if (!is.null(data)) { .header(zz, title, level, id) .write(zz, data) } @@ -84,12 +84,12 @@ #' @author Jan Philipp Dietrich #' @seealso \code{\link{goxygen}}, \code{\link{createModulePage}} #' -.interfaceplot <- function(zz,name,docfolder) { - file <- paste0("images/interfaces_",sub("^[^_]*_","",name),".png") - if(file.exists(paste0(docfolder,"/",file))) { - .write(zz,paste0("![Interfaces to other modules](",file,"){ height=50% width=100% }")) +.interfaceplot <- function(zz, name, docfolder) { + file <- paste0("images/interfaces_", sub("^[^_]*_", "", name), ".png") + if (file.exists(paste0(docfolder, "/", file))) { + .write(zz, paste0("![Interfaces to other modules](", file, "){ height=50% width=100% }")) } else { - .write(zz,"**Interface plot missing!**") + .write(zz, "**Interface plot missing!**") } } @@ -104,14 +104,14 @@ #' @author Jan Philipp Dietrich #' @seealso \code{\link{goxygen}}, \code{\link{createModulePage}} #' -.limitations <- function(zz,limitations, emptyIfNULL=FALSE) { - if(is.null(limitations)) { - if(emptyIfNULL) return() +.limitations <- function(zz, limitations, emptyIfNULL = FALSE) { + if (is.null(limitations)) { + if (emptyIfNULL) return() limitations <- "There are no known limitations." } - limitations <- c("**Limitations**",limitations) - limitations <- paste(">",limitations) - .write(zz,limitations) + limitations <- c("**Limitations**", limitations) + limitations <- paste(">", limitations) + .write(zz, limitations) } @@ -124,8 +124,6 @@ #' @author Jan Philipp Dietrich #' @seealso \code{\link{goxygen}}, \code{\link{createModulePage}} #' -.updateImagePaths <- function(x){ - return(gsub("\\(([^/]*\\.(png|jpg))\\)","(images/\\1)",x)) +.updateImagePaths <- function(x) { + return(gsub("\\(([^/]*\\.(png|jpg))\\)", "(images/\\1)", x)) } - - diff --git a/README.md b/README.md index f6294ab..aeb10e7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # In-Code Documentation for 'GAMS' -R package **goxygen**, version **1.3.3** +R package **goxygen**, version **1.4.0** [![CRAN status](https://www.r-pkg.org/badges/version/goxygen)](https://cran.r-project.org/package=goxygen) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1411404.svg)](https://doi.org/10.5281/zenodo.1411404) [![R build status](https://github.com/pik-piam/goxygen/workflows/check/badge.svg)](https://github.com/pik-piam/goxygen/actions) [![codecov](https://codecov.io/gh/pik-piam/goxygen/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/goxygen) [![r-universe](https://pik-piam.r-universe.dev/badges/goxygen)](https://pik-piam.r-universe.dev/builds) @@ -48,7 +48,7 @@ In case of questions / problems please contact Jan Philipp Dietrich , R package version 1.3.3, . +Dietrich J, Karstens K, Klein D, Baumstark L (2023). _goxygen: In-Code Documentation for 'GAMS'_. doi:10.5281/zenodo.1411404 , R package version 1.4.0, . A BibTeX entry for LaTeX users is @@ -57,7 +57,7 @@ A BibTeX entry for LaTeX users is title = {goxygen: In-Code Documentation for 'GAMS'}, author = {Jan Philipp Dietrich and Kristine Karstens and David Klein and Lavinia Baumstark}, year = {2023}, - note = {R package version 1.3.3}, + note = {R package version 1.4.0}, doi = {10.5281/zenodo.1411404}, url = {https://github.com/pik-piam/goxygen}, } diff --git a/man/createModulePage.Rd b/man/createModulePage.Rd index 6dcda0c..6e6c794 100644 --- a/man/createModulePage.Rd +++ b/man/createModulePage.Rd @@ -7,7 +7,7 @@ createModulePage(data, docfolder) } \arguments{ -\item{data}{a list of data entries for the resulting markdown page. Following +\item{data}{a list of data entries for the resulting markdown page. Following entries can be provided: \describe{ \item{name}{Name of the module} diff --git a/man/dot-section.Rd b/man/dot-section.Rd new file mode 100644 index 0000000..bae0b6e --- /dev/null +++ b/man/dot-section.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helper_functions.R +\name{.section} +\alias{.section} +\title{.section} +\usage{ +.section(data, zz, title, level, id = NULL) +} +\arguments{ +\item{data}{a character vector to be written to the markdown document} + +\item{zz}{a connection object of class "textConnection" containing the markdown document} + +\item{title}{the title to be used (character vector of length 1)} + +\item{level}{level of the heading (1 means main header, higher numbers reflect lower levels)} + +\item{id}{ID given to the title (relevant for anchors)} +} +\description{ +helper function which creates a section consisting of header and content in a markdown document +and skips section when content is empty +} +\seealso{ +\code{\link{goxygen}}, \code{\link{createModulePage}} +} +\author{ +Falk Benke +} diff --git a/man/extractDocumentation.Rd b/man/extractDocumentation.Rd index e213517..b8c7486 100644 --- a/man/extractDocumentation.Rd +++ b/man/extractDocumentation.Rd @@ -24,10 +24,10 @@ of the line. In case of @realization also GAMS code is read and interpreted, in only the specific documentation comment is evaluated. } \examples{ -mainfile <- paste0(system.file("dummymodel",package="gms"),"/main.gms") -calcfile <- paste0(system.file("dummymodel",package="gms"), +mainfile <- paste0(system.file("dummymodel", package = "gms"), "/main.gms") +calcfile <- paste0(system.file("dummymodel", package = "gms"), "/modules/02_crazymodule/complex/calculations.gms") -# extracting information from the main file of the model +# extracting information from the main file of the model extractDocumentation(mainfile) # extracting information from a file with some equations in it extractDocumentation(calcfile) diff --git a/vignettes/goxygen.Rmd b/vignettes/goxygen.Rmd index 235373d..4830ef9 100644 --- a/vignettes/goxygen.Rmd +++ b/vignettes/goxygen.Rmd @@ -37,8 +37,8 @@ setwd(tempdir()) We take the GAMS code example from this package and save it to `dummymodel-plain`: ```{r eval=FALSE} -# copy the folder containing a simple dummy model with goxygen comments -file.copy(from = system.file("dummymodel-plain",package="goxygen"), to = ".", recursive = TRUE) +# copy the folder containing a simple dummy model with goxygen comments +file.copy(from = system.file("dummymodel-plain", package = "goxygen"), to = ".", recursive = TRUE) ``` and execute `goxygen` on this GAMS file to produce the documentation in HTML as well as PDF format. @@ -108,7 +108,7 @@ Goxygen is tailored to extract the documentation from this modular structure and ```{r eval=FALSE} # copy all files and folders containing the modular dummy model -file.copy(from = system.file("dummymodel",package="gms"), to = ".", recursive = TRUE) +file.copy(from = system.file("dummymodel", package = "gms"), to = ".", recursive = TRUE) ``` Now execute `goxygen` on the modular GAMS model: