Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added problem set template and bibliography statistics helpers #95

Merged
merged 66 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
f777db2
Fixed #91 by removing roxigen2, covr, and magrittr
Jul 6, 2021
14fe5c5
Fixed #93 by amending pkgdown section of pushrelease workflow
Jul 6, 2021
690acd7
Added flipbookr reference to vignette
Jul 20, 2021
8b8eb35
Added some basic bibliographic statistic functions
jhollway Jul 23, 2021
ab392f1
Closed #93 and #71 by adding total_pages() to bibliographic statistics
jhollway Jul 23, 2021
13af67b
Fixed author in iheiddown bibentry
jhollway Jul 23, 2021
69a19f1
Fixed #92 by setting link colors to black
Jul 24, 2021
462c606
Fixed #76 by adding line numbering to the latex template with the lin…
Jul 26, 2021
f11cf4f
Set draft option to false in skeleton for correct rendering by Github…
Jul 27, 2021
1b07147
Fixed #94 by adding a simple problem set template
Aug 9, 2021
c39b454
Re #94 Added rendering step for problem set example
Aug 9, 2021
c28ed98
Re #94 Added problem set example to PushRelease workflow
Aug 9, 2021
3af5abb
Re #94 Created "Walkthrough vignette" for the problem set template
Aug 9, 2021
8c4a71c
Updated vignettes following package release on CRAN
Aug 9, 2021
f90c771
Added problem set vignette to pkgdown website
Aug 9, 2021
5ab120f
Re #94 Amended NAMESPACE
Aug 9, 2021
88cd02e
Fixed warning from preview_stop() test
Aug 9, 2021
6d6f02b
Addressed lintr issues in tests
Aug 9, 2021
7e7eb87
Adressed lintr issues
Aug 9, 2021
c644dcd
Changed grid color to grey85 for iheid_theme()
Aug 9, 2021
9f32050
Updated README
Aug 9, 2021
68bb1f9
Added better handling of bibliographic quotation marks
jhollway Aug 13, 2021
1a6d9cd
Added fix_bib() for making small corrections to the bib files created…
jhollway Aug 13, 2021
c3fbc05
Fixed various bugs in bibstats based on recent version of bib2df
jhollway Aug 15, 2021
1e2009e
Added get_used_bib() for obtaining only used references
jhollway Aug 15, 2021
16df285
Re #92 Added "howpublished" tag to citations for URL link to show up
Aug 16, 2021
4288071
Re #92 Switched URL colors to red again for syllabus
Aug 16, 2021
14541a7
# Re #92 Set link-citations to false since we don't render the biblio…
Aug 16, 2021
fdcb5b2
Fixed Lintr issues
Aug 16, 2021
6429498
Updated NEWS.md
Aug 16, 2021
c5701b3
Bumped version number and date
Aug 16, 2021
f47db37
Minor edit to pkgdown config
Aug 16, 2021
af44008
Added remove_bullets() to get_used_bib()
jhollway Aug 17, 2021
9df8600
Fixed namespace errors
jhollway Aug 17, 2021
75348bc
Fixed global variable errors
jhollway Aug 17, 2021
b60e5fd
Minor PR check fix: installed roxygen2 before documenting the package
Aug 17, 2021
f379bfb
Added covr installation step to PR check workflow
Aug 17, 2021
613b912
Added lintr to PR check workflow
Aug 17, 2021
c06ff4d
Fixed lintr issues
Aug 17, 2021
149622b
More lintr issues fixed
Aug 17, 2021
cb6acb4
Miscellaneous updates to gitignore and buildignore to ignore html fil…
Aug 17, 2021
4a1dceb
Removed lintr from workflow
Aug 17, 2021
bd15b83
Cleaned up solved todo call
Aug 17, 2021
f56c23b
Added new line at the end of every bib file
Aug 17, 2021
5cdf6a0
Minor fix to percent_female()
Aug 17, 2021
f468e00
Added tests for bibstats and bibfix functions
Aug 17, 2021
8b64667
Only compute code coverage on macOS
Aug 17, 2021
43d5890
Re Only run code coverage on macOS
Aug 17, 2021
d8405bf
percent_female() now takes an argument to calculate across all author…
jhollway Aug 19, 2021
75f5a8b
Fixed identation issues
Aug 19, 2021
34a3e33
Updated description
Aug 19, 2021
eacd08d
Fixed bug in bibstats and amended documentation
Aug 19, 2021
631129f
Updated NEWS with bibstat function description
Aug 20, 2021
f5de0df
Updated documentation for bibstats
Aug 20, 2021
c45083a
Fixed bug in percent_female()
Aug 21, 2021
2b27f43
Updated tests for percent_female()
Aug 21, 2021
7d97ee1
Fixed identation issues in bib files
Aug 21, 2021
297cf58
Fixed missing newline
Aug 21, 2021
b563d88
Hid get_used_bib as it is a helper function
Aug 21, 2021
7c1f276
Updated date in DESCRIPTION
Aug 21, 2021
0196c4d
Edited some bibstat function descriptions
jhollway Aug 21, 2021
94ecf82
Regularised template naming
jhollway Aug 21, 2021
1d4872a
Changed fonts for problem set template to be consistent with the thes…
Aug 21, 2021
3af430e
Trimmed down the number of packages used in problem set template
Aug 22, 2021
cb002c5
Added siunitx package to deal with undefined control sequence \num{}
Aug 23, 2021
94a1b13
Fixed CodeFactor issues
Aug 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
^pkgdown$
^cran-comments\.md$
^CRAN-RELEASE$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
3 changes: 3 additions & 0 deletions .github/workflows/prchecks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ jobs:
remotes::install_github("crsh/citr")
remotes::install_github("gadenbuie/xaringanExtra")
remotes::install_github("giocomai/ganttrify")
utils::install.packages("roxygen2")
utils::install.packages("covr")
shell: Rscript {0}

- name: Document
Expand All @@ -76,3 +78,4 @@ jobs:

- name: Calculate code coverage
run: Rscript -e "covr::codecov()"
if: runner.os == 'macOS'
40 changes: 34 additions & 6 deletions .github/workflows/pushrelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ jobs:
with:
name: SyllabusExample
path: Untitled/

- name: Save problem set sample as artifact
if: runner.os == 'macOS'
uses: actions/upload-artifact@v2
with:
name: ProblemSetExample
path: UntitledPS/

- name: Remove Thesis project
if: runner.os == 'macOS'
Expand All @@ -140,6 +147,10 @@ jobs:
if: runner.os == 'macOS'
run: Rscript -e 'unlink("Untitled", recursive = TRUE)'

- name: Remove problem set project
if: runner.os == 'macOS'
run: Rscript -e 'unlink("UntitledPS", recursive = TRUE)'

- name: Calculate code coverage
run: Rscript -e "covr::codecov()"

Expand Down Expand Up @@ -203,6 +214,17 @@ jobs:
asset_name: IHEIDSyllabusExample.pdf
asset_content_type: application/pdf

- name: Upload problem set Example Asset
id: upload-PS-example
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ProblemSetExample/IHEIDProblemSetExample.pdf
asset_name: IHEIDProblemSetExample.pdf
asset_content_type: application/pdf

- name: Rename Mac release
run: mv ./macOS/*.tgz iheiddown_macOS.tgz

Expand Down Expand Up @@ -258,7 +280,7 @@ jobs:
# install packages needed
- name: install required packages
run: Rscript -e 'install.packages(c("rmarkdown"))'

# Render README.md using rmarkdown
- name: render README
run: Rscript -e 'rmarkdown::render("README.Rmd", output_format = "md_document")'
Expand All @@ -277,6 +299,8 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false # add for deployment to work correctly

- uses: r-lib/actions/setup-r@v1

Expand Down Expand Up @@ -305,9 +329,13 @@ jobs:
- name: Install package
run: R CMD INSTALL .

- name: Deploy package
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
- name: Build site # build pkgdown site in separate step
run: Rscript -e 'pkgdown::build_site()'

- name: Deploy # deploy the docs folder to gh-pages
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: docs
CLEAN: true
28 changes: 17 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ Title: For Writing Graduate Institute Geneva Documents
Description: A set of tools to support writing various documents
according to the Graduate Institute of International and Development Studies
conventions and regulations.
The most common use will be for writing and compiling theses or thesis chapters,
as drafts or for examination with all the correct preamble content.
However, the package also offers the creation of html presentation slides via 'xaringan',
and, for course instructors, also the ability to create a syllabus as a PDF.
The most common use will be for writing and compiling theses or thesis
chapters, as drafts or for examination with all the correct preamble
content. However, the package also offers the creation of html presentation
slides via 'xaringan', the capacity to write problem sets and, for course
instructors, the ability to create syllabi.
The package includes additional functions for institutional color palettes
and an institutional 'ggplot' theme, as well as a function for word counts.
Date: 2021-06-24
Version: 0.8.2
and an institutional 'ggplot' theme, as well as a function for word counts
and a bibliographical analysis toolkit.
Date: 2021-08-20
Version: 0.8.3
Authors@R:
c(person(given = "James",
family = "Hollway",
Expand All @@ -30,10 +32,7 @@ License: MIT + file LICENSE
Imports:
bookdown,
dplyr,
roxygen2,
covr,
ggplot2,
magrittr,
rmarkdown,
xaringan,
crayon,
Expand All @@ -42,7 +41,14 @@ Imports:
readr,
rstudioapi,
tibble,
tidytext
tidytext,
bib2df,
purrr,
stringr,
fs,
usethis,
gender,
remotes
jhollway marked this conversation as resolved.
Show resolved Hide resolved
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
Expand Down
22 changes: 22 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,30 @@ export(advdate)
export(bookdown_profile)
export(chapter_pdf)
export(count_words)
export(fix_bib)
export(get_used_bib)
export(iheid_palette)
export(iheid_palettes)
export(mean_pages)
export(mean_year)
export(percent_female)
export(preview_start)
export(preview_stop)
export(problemset_pdf)
export(syllabus_pdf)
export(theme_iheid)
export(thesis_pdf)
export(total_pages)
import(crayon)
import(dplyr)
importFrom(bib2df,bib2df)
importFrom(bib2df,df2bib)
importFrom(bookdown,pdf_book)
importFrom(bookdown,preview_chapter)
importFrom(bookdown,render_book)
importFrom(dplyr,filter)
importFrom(dplyr,mutate)
importFrom(fs,path_dir)
importFrom(ggplot2,element_blank)
importFrom(ggplot2,element_line)
importFrom(ggplot2,element_rect)
Expand All @@ -28,13 +40,23 @@ importFrom(graphics,image)
importFrom(graphics,par)
importFrom(graphics,rect)
importFrom(graphics,text)
importFrom(purrr,map)
importFrom(readr,read_lines)
importFrom(rlang,.data)
importFrom(rmarkdown,pdf_document)
importFrom(rstudioapi,getSourceEditorContext)
importFrom(servr,daemon_list)
importFrom(servr,daemon_stop)
importFrom(stats,na.omit)
importFrom(stringr,fixed)
importFrom(stringr,str_detect)
importFrom(stringr,str_remove)
importFrom(stringr,str_replace)
importFrom(stringr,str_replace_all)
importFrom(stringr,str_split)
importFrom(tibble,as_tibble)
importFrom(tidytext,unnest_tokens)
importFrom(usethis,ui_info)
importFrom(utils,file.edit)
importFrom(utils,install.packages)
importFrom(xaringan,inf_mr)
14 changes: 14 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# iheiddown 0.8.3

## Problem set template
- Closed #94 by adding a problem set template to `{iheiddown}`

## Thesis
- Closed #76 by adding an option for line numbering for thesis output when the draft option is set to true

## Package
- Fixed #90 by solving the remaining issues of the package website deployment workflow
- Closed #91 by removing unnecessary package dependencies following CRAN notes
- Closed #93 by adding bibliography statistics family of functions

BBieri marked this conversation as resolved.
Show resolved Hide resolved

# iheiddown 0.8.2

- This release attends to the changes requested by CRAN:
Expand Down
40 changes: 33 additions & 7 deletions R/_render.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ iheiddown::thesis_pdf("index.Rmd")
#Come back to the original WD and copy the output while also renaming it
setwd("..")
date <- Sys.Date()
name <- paste0("Thesis_Name_", date,".pdf")
name <- paste0("Thesis_Name_", date, ".pdf")
target_path <- "00-Example/versions"
file.rename(file.path(target_path, name), file.path(target_path, "IHEIDThesisExample.pdf"))
file.rename(file.path(target_path, name), file.path(target_path,
"IHEIDThesisExample.pdf"))

############
# Syllabus
############

# Automatic rendering of thesis_pdf will run on a Windows VM
# Automatic rendering of syllabus_pdf will run on a Windows VM
#Step 1 Create an example project
rmarkdown::draft(file = "Untitled", template = "Syllabus",
package = "iheiddown", create_dir = TRUE, edit = FALSE)
Expand All @@ -33,9 +34,29 @@ iheiddown::syllabus_pdf("Untitled.Rmd")
#Come back to the original WD and copy the output while also renaming it
setwd("..")
date <- Sys.Date()
name <- paste0("MINT001_Syllabus_", date,".pdf")
name <- paste0("MINT001_Syllabus_", date, ".pdf")
target_path <- "Untitled"
file.rename(file.path(target_path, name), file.path(target_path, "IHEIDSyllabusExample.pdf"))
file.rename(file.path(target_path, name), file.path(target_path,
"IHEIDSyllabusExample.pdf"))

##############
# Problem Set
##############

# Automatic rendering of problemset_pdf will run on a Windows VM
#Step 1 Create an example project
rmarkdown::draft(file = "UntitledPS", template = "Problem_Set",
package = "iheiddown", create_dir = TRUE, edit = FALSE)
setwd("UntitledPS") # Since we can only knit from the WD
#Step 2 render the example project and replace in template folder
iheiddown::problemset_pdf("UntitledPS.Rmd")
#Come back to the original WD and copy the output while also renaming it
setwd("..")
date <- Sys.Date()
name <- paste0("MINT001_ProblemSet_", date, ".pdf")
target_path <- "UntitledPS"
file.rename(file.path(target_path, name),
file.path(target_path, "IHEIDProblemSetExample.pdf"))

############
# Presentation
Expand All @@ -59,13 +80,18 @@ setwd("..")
target_dir <- "docs/sample_output"
dir.create(target_dir)
# Thesis
file.copy("00-Example/versions/IHEIDThesisExample.pdf", target_dir, overwrite = TRUE)
file.copy("00-Example/versions/IHEIDThesisExample.pdf",
target_dir,
overwrite = TRUE)
# Syllabus
file.copy("Untitled/IHEIDSyllabusExample.pdf", target_dir, overwrite = TRUE)
# Problem Set
file.copy("UntitledPS/IHEIDProblemSetExample.pdf", target_dir, overwrite = TRUE)
# Presentation
file.copy("index/index.html", target_dir, overwrite = TRUE)
file.copy("index/index_cache", target_dir, recursive = TRUE, overwrite = TRUE)
file.copy("index/index_files", target_dir, recursive = TRUE, overwrite = TRUE)
file.copy("index/assets", target_dir, recursive = TRUE, overwrite = TRUE)

# Note, the directories generated will be erased further down the GitHub workflow
# Note, the directories generated will be erased further down the GitHub
# workflow
56 changes: 56 additions & 0 deletions R/bibfix.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#' @rdname bibstats
#' @importFrom stringr str_replace_all str_replace fixed
#' @importFrom bib2df bib2df df2bib
#' @importFrom purrr map
#' @export
fix_bib <- function(bib_file) {
if (missing(bib_file)) bib_file <- find_bib()
bib <- suppressMessages(bib2df::bib2df(bib_file))
bib$PAGES <- stringr::str_replace_all(bib$PAGES,
stringr::fixed("{\\textendash}"), "--")
bib$AUTHOR <- purrr::map(bib$AUTHOR, function(x) {
x <- stringr::str_replace(x, "^", "{")
x <- stringr::str_replace(x, "\\{\\{", "{")
x <- stringr::str_replace(x, "$", "}")
x <- stringr::str_replace(x, "\\}\\}", "}")
})
bib$EDITOR <- purrr::map(bib$EDITOR, function(x) {
x <- stringr::str_replace(x, "^", "{")
x <- stringr::str_replace(x, "\\{\\{", "{")
x <- stringr::str_replace(x, "$", "}")
x <- stringr::str_replace(x, "\\}\\}", "}")
})
bib2df::df2bib(bib, bib_file)
}
BBieri marked this conversation as resolved.
Show resolved Hide resolved

#' @rdname bibstats
#' @importFrom readr read_lines
#' @importFrom tibble as_tibble
#' @importFrom dplyr mutate filter
#' @importFrom stringr str_remove
#' @export
get_used_bib <- function(bib_file, rmd_file) {
if (missing(bib_file)) bib_file <- find_bib()
if (missing(rmd_file)) rmd_file <- rstudioapi::getSourceEditorContext()$path
bib <- suppressMessages(bib2df::bib2df(bib_file))
current_bibs <- readr::read_lines(rmd_file) %>%
tibble::as_tibble() %>%
remove_front_matter() %>%
remove_code_chunks() %>%
remove_inline_code() %>%
remove_html_comment() %>%
remove_bullets() %>%
get_biblines() %>%
dplyr::mutate(value = stringr::str_remove(.data$value, "@")) %>%
select(.data$value) %>%
as.vector()
current_bibs$value
}
BBieri marked this conversation as resolved.
Show resolved Hide resolved

remove_bullets <- function(x) {
dplyr::mutate(x, value = stringr::str_remove(.data$value, "^-[:space:]+"))
}

get_biblines <- function(x) {
dplyr::filter(x, grepl("@", .data$value))
}
Loading