@@ -36,6 +36,7 @@ copy_codecheck_report_template <- function(target = ".") {
36
36
# #' @param root Path to the root folder of the project.
37
37
# #' @return A list containing the metadata found in the codecheck.yml file
38
38
# #' @author Stephen Eglen
39
+ # #' @importFrom yaml read_yaml
39
40
# #' @export
40
41
codecheck_metadata <- function (root ) {
41
42
read_yaml( file.path(root , " codecheck.yml" ) )
@@ -61,6 +62,7 @@ codecheck_metadata <- function(root) {
61
62
# #' @export
62
63
copy_manifest_files <- function (root , metadata , dest_dir ,
63
64
keep_full_path = FALSE ) {
65
+ manifest = metadata $ manifest
64
66
outputs = sapply(manifest , function (x ) x $ file )
65
67
src_files = file.path(root , outputs )
66
68
missing = ! file.exists(src_files )
@@ -99,15 +101,25 @@ copy_manifest_files <- function(root, metadata, dest_dir,
99
101
# # https://daringfireball.net/2010/07/improved_regex_for_matching_urls
100
102
# # To use the URL in R, I had to escape the \ characters and " -- this version
101
103
# # does not work:
102
- # # .url_regexp = "(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’ ]))"
104
+ # # .url_regexp = "(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?... ]))"
103
105
104
- .url_regexp = " (?i)\\ b((?:[a-z][\\ w-]+:(?:/{1,3}|[a-z0-9%])|www\\ d{0,3}[.]|[a-z0-9.\\ -]+[.][a-z]{2,4}/)(?:[^\\ s()<>]+|\\ (([^\\ s()<>]+|(\\ ([^\\ s()<>]+\\ )))*\\ ))+(?:\\ (([^\\ s()<>]+|(\\ ([^\\ s()<>]+\\ )))*\\ )|[^\\ s`!()\\ [\\ ]{};:'\" .,<>?«»“”‘’]))"
106
+ # # Have also converted the unicode into \uxxxx escapes to keep
107
+ # # devtools::check() happy
108
+ # # « -> \u00ab
109
+ # # » -> \u00bb
110
+ # # “ -> \u201c
111
+ # # ” -> \u201d
112
+ # # ‘ -> \u2018
113
+ # # ’ -> \u2019
114
+
115
+ .url_regexp = " (?i)\\ b((?:[a-z][\\ w-]+:(?:/{1,3}|[a-z0-9%])|www\\ d{0,3}[.]|[a-z0-9.\\ -]+[.][a-z]{2,4}/)(?:[^\\ s()<>]+|\\ (([^\\ s()<>]+|(\\ ([^\\ s()<>]+\\ )))*\\ ))+(?:\\ (([^\\ s()<>]+|(\\ ([^\\ s()<>]+\\ )))*\\ )|[^\\ s`!()\\ [\\ ]{};:'\" .,<>?\u 00ab\u 00bb\u 201c\u 201d\u 2018\u 2019]))"
105
116
106
117
# #' Wrap URL for LaTeX
107
118
# #'
108
- # #' @param url - TRUE to keep relative pathname of figures .
119
+ # #' @param x - A string that may contain URLs that should be hyperlinked .
109
120
# #' @return A string with the passed url as a latex `\url{}`
110
121
# #' @author Stephen Eglen
122
+ # #' @importFrom stringr str_replace_all
111
123
as_latex_url <- function (x ) {
112
124
wrapit <- function (url ) { paste0(" \\ url{" , url , " }" ) }
113
125
str_replace_all(x , .url_regexp , wrapit )
@@ -147,6 +159,7 @@ as_latex_url <- function(x) {
147
159
# #' @param metadata - the codecheck metadata list.
148
160
# #' @return The latex table, suitable for including in the Rmd
149
161
# #' @author Stephen Eglen
162
+ # #' @importFrom xtable xtable
150
163
# #' @export
151
164
latex_summary_of_metadata <- function (metadata ) {
152
165
summary_entries = list (
@@ -172,13 +185,15 @@ latex_summary_of_metadata <- function(metadata) {
172
185
# #'
173
186
# #' Format a latex table that summarises the main CODECHECK manifest
174
187
# #' @title Print a latex table to summarise CODECHECK metadata
188
+ # #' @param metadata - the codecheck metadata list.
175
189
# #' @param manifest_df - The manifest data frame
176
190
# #' @param root - root directory of the project
177
191
# #' @param align - alignment flags for the table.
178
192
# #' @return The latex table, suitable for including in the Rmd
179
193
# #' @author Stephen Eglen
194
+ # #' @importFrom xtable xtable
180
195
# #' @export
181
- latex_summary_of_manifest <- function (manifest_df ,
196
+ latex_summary_of_manifest <- function (metadata , manifest_df ,
182
197
root ,
183
198
align = c(' l' , ' p{6cm}' , ' p{6cm}' , ' p{2cm}' )
184
199
) {
@@ -243,9 +258,10 @@ citation <- function(metadata) {
243
258
# #' @param zen - Object from zen4R to interact with Zenodo
244
259
# #' @return Number of zenodo record created.
245
260
# #' @author Stephen Eglen
261
+ # #'
246
262
# #' @export
247
263
create_zenodo_record <- function (zen ) {
248
- myrec <- zenodo $ createEmptyRecord()
264
+ myrec <- zen $ createEmptyRecord()
249
265
this_doi = myrec $ metadata $ prereserve_doi $ doi
250
266
cat(" The following URL is your Zenodo DOI.\n " )
251
267
cat(" Please add this to codecheck.yml in report: field\n " )
@@ -268,6 +284,7 @@ create_zenodo_record <- function(zen) {
268
284
# #' @param report - string containing the report URL on Zenodo.
269
285
# #' @return the Zenodo record number (a number with at least 7 digits).
270
286
# #' @author Stephen Eglen
287
+ # #' @importFrom stringr str_match
271
288
# #' @export
272
289
get_zenodo_record <- function (report ) {
273
290
result = str_match(report , " 10\\ .5281/zenodo\\ .([0-9]{7,})" )[2 ]
0 commit comments