Skip to content

Commit ca000cc

Browse files
authored
rticles::rjournal_article() is now defunct (#597)
* rticles::rjournal_article() is now defunct Remove ressources which will help reduce package size and allow cran release * remove from other docs and vignette * Update test * Other removal
1 parent a2a0853 commit ca000cc

19 files changed

Lines changed: 15 additions & 905 deletions

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,5 @@ Config/Needs/website: magick, pdftools, gifski, tidyverse/tidytemplate,
108108
Config/testthat/edition: 3
109109
Encoding: UTF-8
110110
Roxygen: list(markdown = TRUE)
111-
RoxygenNote: 7.3.2
111+
RoxygenNote: 7.3.3
112112
SystemRequirements: GNU make

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export(peerj_article)
3737
export(pihph_article)
3838
export(plos_article)
3939
export(pnas_article)
40-
export(rjournal_article)
4140
export(rsos_article)
4241
export(rss_article)
4342
export(sage_article)

R/rjournal_article.R

Lines changed: 4 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -3,169 +3,12 @@
33
#' @description
44
#' `r lifecycle::badge('deprecated')`
55
#'
6-
#' This function is now deprecated in favor of the [**rjtools**](https://rjournal.github.io/rjtools/) package
7-
#' which is now officialy recommanded by R Journal <https://rjournal.github.io/submissions.html>. See below for document
6+
#' This function is now defunct in favor of the [**rjtools**](https://rjournal.github.io/rjtools/) package
7+
#' which is now officialy recommanded by R Journal <https://rjournal.github.io/submissions.html>.
88
#'
9-
#' @details # About this format and the R Journal requirements
10-
#'
11-
#' Format for creating R Journal articles. Adapted from
12-
#' <https://journal.r-project.org/submissions.html>.
13-
#'
14-
#' This file is only a basic article template. For full details of _The R
15-
#' Journal_ style and information on how to prepare your article for submission,
16-
#' see the [Instructions for Authors](https://journal.r-project.org/share/author-guide.pdf)
17-
#'
18-
19-
#'
20-
#' `rticles::rjournal_article` will help you build the correct files requirements:
21-
#'
22-
#' - A R file will be generated automatically using `knitr::purl` - see
23-
#' https://bookdown.org/yihui/rmarkdown-cookbook/purl.html for more information.
24-
#' - A tex file will be generated from this Rmd file and correctly included in
25-
#' `RJwapper.tex` as expected to build `RJwrapper.pdf`.
26-
#' - All figure files will be kept in the default rmarkdown `*_files` folder. This
27-
#' happens because `keep_tex = TRUE` by default in `rticles::rjournal_article`
28-
#' - Only the bib filename is to be modified. An example bib file is included in the
29-
#' template (`RJreferences.bib`) and you will have to name your bib file as the
30-
#' tex, R, and pdf files.
31-
#'
32-
#' # About YAML header fields
33-
#'
34-
#' This section documents some of the YAML fields that can be used with this
35-
#' formats.
36-
#'
37-
#' ## The `author` field in the YAML header
38-
#'
39-
#' | FIELD | TYPE | DESCRIPTION |
40-
#' | ------ | ---- | ----------- |
41-
#' | `name` | *required* | name and surname of the author |
42-
#' | `affiliation` | *required* | name of the author's affiliation |
43-
#' | `address` | *required* | at least one address line for the affiliation |
44-
#' | `url` | *optional* | an additional url for the author or the main affiliation |
45-
#' | `orcid` | *optional* | the authors ORCID if available |
46-
#' | `email` | *required* | the author's e-mail address |
47-
#' | `affiliation2` | *optional* | name of the author's 2nd affiliation |
48-
#' | `address2` | *optional* | address lines belonging to the author's 2nd affiliation |
49-
#'
50-
#' *Please note: Only one `url`, `orcid` and `email` can be provided per author.*
51-
#'
52-
#' ## Other YAML fields
53-
#'
54-
#' | FIELD | TYPE | DESCRIPTION |
55-
#' | ----- | ---- | ----------- |
56-
#' | `bibliography` | *with default* | the BibTeX file with the reference entries |
57-
#'
58-
#' @inheritParams rmarkdown::pdf_document
59-
#' @param ... Arguments to [rmarkdown::pdf_document()].
60-
#' @export
9+
#' @keywords internal
6110
rjournal_article <- function(..., keep_tex = TRUE, citation_package = "natbib") {
6211

63-
lifecycle::deprecate_warn("0.25", "rjournal_article()", "rjtools::rjournal_pdf_article()", details = "See official recommandation at https://rjournal.github.io/submissions.html")
64-
rmarkdown::pandoc_available("2.2", TRUE)
65-
66-
base <- pdf_document_format(
67-
"rjournal",
68-
highlight = NULL, citation_package = citation_package,
69-
keep_tex = keep_tex, ...
70-
)
71-
72-
# Render will generate tex file, post-knit hook gerenates the R file,
73-
# post-process hook generates appropriate RJwrapper.tex and
74-
# use pandoc to build pdf from that
75-
base$pandoc$to <- "latex"
76-
base$pandoc$ext <- ".tex"
77-
78-
# Generates R file expected by R journal requirement.
79-
# We do that in the post-knit hook do access input file path.
80-
pk <- base$post_knit
81-
output_R <- NULL
82-
base$post_knit <- function(metadata, input_file, runtime, ...) {
83-
# run post_knit it exists
84-
if (is.function(pk)) pk(metadata, input_file, runtime, ...)
85-
86-
# purl the Rmd file to R code per requirement
87-
temp_R <- tempfile(fileext = ".R")
88-
output_R <<- knitr::purl(input_file, temp_R, documentation = 1, quiet = TRUE)
89-
# Add magic comment about '"do not edit" (rstudio/rstudio#2082)
90-
xfun::write_utf8(c(
91-
"# Generated by `rjournal_article()` using `knitr::purl()`: do not edit by hand",
92-
sprintf("# Please edit %s to modify this file", input_file),
93-
"",
94-
xfun::read_utf8(output_R)
95-
), output_R)
96-
97-
NULL
98-
}
99-
100-
base$post_processor <- function(metadata, utf8_input, output_file, clean, verbose) {
101-
filename <- basename(output_file)
102-
# underscores in the filename will be problematic in \input{filename};
103-
# pandoc will escape underscores but it should not, i.e., should be
104-
# \input{foo_bar} instead of \input{foo\_bar}
105-
if (filename != (filename2 <- gsub("_", "-", filename))) {
106-
file.rename(filename, filename2)
107-
filename <- filename2
108-
}
109-
110-
# Copy purl-ed R file with the correct name
111-
dest_file <- xfun::with_ext(filename, "R")
112-
our_file <- TRUE
113-
if (file.exists(dest_file)) {
114-
# we check this file is generated by us
115-
# otherwise we leave it as is and warn
116-
current_r <- xfun::read_utf8(dest_file)
117-
our_file <- grepl("Generated.*rjournal_article.*do not edit by hand", current_r[1])
118-
if (!our_file) {
119-
warning(
120-
sprintf("R file with name '%s' already exists.", dest_file),
121-
"\nIt will not be overwritten by the one generated",
122-
" during rendering using `knitr::purl()`.",
123-
"\nRemove the existing file to obtain the generated one.",
124-
call. = FALSE
125-
)
126-
}
127-
}
128-
if (our_file) {
129-
# we only overwrite if it is our file
130-
file.copy(output_R, xfun::with_ext(filename, "R"), overwrite = TRUE)
131-
}
132-
unlink(output_R)
133-
134-
# post process TEX file
135-
temp_tex <- xfun::read_utf8(filename)
136-
temp_tex <- post_process_authors(temp_tex)
137-
xfun::write_utf8(temp_tex, filename)
138-
139-
# check bibliography name
140-
bib_filename <- metadata$bibliography
141-
if (length(bib_filename) == 1 &&
142-
xfun::sans_ext(bib_filename) != xfun::sans_ext(filename)) {
143-
msg <- paste0(
144-
"Per R journal requirement, bibliography file and tex file should",
145-
" have the same name. Currently, you have a bib file ", bib_filename,
146-
" and a tex file ", filename, ". Don't forget to rename and change",
147-
" the bibliography field in the YAML header."
148-
)
149-
warning(msg, call. = FALSE)
150-
}
151-
152-
# Create RJwrapper.tex per R Journal requirement
153-
m <- list(filename = xfun::sans_ext(filename))
154-
h <- get_list_element(metadata, c("output", "rticles::rjournal_article", "includes", "in_header"))
155-
h <- c(h, if (length(preamble <- unlist(metadata[c("preamble", "header-includes")]))) {
156-
f <- tempfile(fileext = ".tex")
157-
on.exit(unlink(f), add = TRUE)
158-
xfun::write_utf8(preamble, f)
159-
f
160-
})
161-
t <- find_resource("rjournal", "RJwrapper.tex")
162-
template_pandoc(m, t, "RJwrapper.tex", h, verbose)
163-
164-
tinytex::latexmk("RJwrapper.tex", base$pandoc$latex_engine, clean = clean)
165-
}
166-
167-
# Mostly copied from knitr::render_sweave
168-
base$knitr$opts_chunk$comment <- "#>"
12+
lifecycle::deprecate_stop("0.25", "rjournal_article()", "rjtools::rjournal_pdf_article()", details = "See official recommandation at https://rjournal.github.io/submissions.html")
16913

170-
set_sweave_hooks(base)
17114
}

R/utils.R

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' These names can be useful in two ways:
66
#'
77
#' * You can add `_article` suffix to get the name of the output format (e.g.,
8-
#' [rjournal_article()]).
8+
#' [jss_article()]).
99
#'
1010
#' * You can use the name directly in the `template` argument of
1111
#' [rmarkdown::draft()].
@@ -47,13 +47,6 @@ merge_list <- function(x, y) {
4747
#' @param output Path to save output.
4848
#' @param in_header Paths to files to include in the header.
4949
#' @return (Invisibly) The path of the generate file.
50-
#' @examples
51-
#' x <- rticles:::template_pandoc(
52-
#' list(preamble = "%abc", filename = "wickham"),
53-
#' rticles:::find_resource("rjournal", "RJwrapper.tex"),
54-
#' tempfile()
55-
#' )
56-
#' if (interactive()) file.show(x)
5750
#' @noRd
5851
template_pandoc <- function(metadata, template, output,
5952
in_header = NULL, verbose = FALSE) {

inst/rmarkdown/templates/rjournal/resources/RJwrapper.tex

Lines changed: 0 additions & 170 deletions
This file was deleted.

0 commit comments

Comments
 (0)