Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
fairify
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
UMR G-EAU
fairify
Commits
af863009
Commit
af863009
authored
1 year ago
by
David Dorchies
Browse files
Options
Downloads
Patches
Plain Diff
fix: bugs in render_reports
parent
0f80ad90
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
R/render_report.R
+8
-7
8 additions, 7 deletions
R/render_report.R
R/render_reports.R
+13
-15
13 additions, 15 deletions
R/render_reports.R
man/render_reports.Rd
+17
-8
17 additions, 8 deletions
man/render_reports.Rd
with
38 additions
and
30 deletions
R/render_report.R
+
8
−
7
View file @
af863009
#' @rdname render_reports
#' @inheritParams bookdown::render_book
#' @export
render_report
<-
function
(
path_repor
t
,
path_publish
,
render_report
<-
function
(
inpu
t
,
output_dir
,
output_format
=
Sys.getenv
(
"BOOKDOWN_FORMAT"
,
"bookdown::gitbook"
),
clean_cache
=
FALSE
,
...
)
{
...
...
@@ -11,23 +12,23 @@ render_report <- function(path_report,
if
(
output_format
==
"bookdown::pdf_book"
)
{
if
(
!
require
(
"tinytex"
))
install.packages
(
"tinytex"
)
}
message
(
"output_format="
,
output_format
)
if
(
clean_cache
)
{
cache_dir
<-
list.files
(
path
=
path
,
cache_dir
<-
list.files
(
path
=
input
,
pattern
=
"_cache$"
,
include.dirs
=
TRUE
,
full.names
=
TRUE
)
unlink
(
cache_dir
,
recursive
=
TRUE
)
}
cfg_bookdown
<-
yaml
::
read_yaml
(
file.path
(
path
,
"_bookdown.yml"
))
unlink
(
file.path
(
path
,
paste0
(
cfg_bookdown
$
book_filename
,
".*"
)))
output_dir
<-
file.path
(
path_publish
,
file
)
yaml
::
read_yaml
(
file.path
(
input
,
"_bookdown.yml"
))
unlink
(
file.path
(
input
,
paste0
(
cfg_bookdown
$
book_filename
,
".*"
)))
dir.create
(
output_dir
,
recursive
=
TRUE
,
showWarnings
=
FALSE
)
attached_packages
<-
(
.packages
())
bookdown
::
render_book
(
path
,
bookdown
::
render_book
(
input
,
output_format
=
output_format
,
output_dir
=
output_dir
,
envir
=
new.env
(),
...
...
This diff is collapsed.
Click to expand it.
R/render_reports.R
+
13
−
15
View file @
af863009
#' Render reports
#'
#' @param path_reports [character] path for the reports
#' @param path_report [character] report path
#' @param reports_dir [character] path for the reports
#' @param reports [character] subfolders containing each report
#' @param path_publish [character] rendering output path
#' @param publish_dir [character] rendering output path relatively to the report
#' folder which is in format `"./reports/my_report"`
#' @param output_format output format, see [bookdown::render_book]. Only
#' `"bookdown::gitbook"` and `"bookdown::pdf_book"` are currently handled
#' @param clean_cache [logical] clean Rmarkdown cache files
...
...
@@ -14,26 +14,24 @@
#' @rdname render_reports
#'
#' @examples
render_reports
<-
function
(
path_
reports
=
"./reports"
,
reports
=
list.
files
(
path_reports
,
pattern
=
"^[0-9]{2}-.*$"
),
path_
publish
=
"
./public/reports"
,
render_reports
<-
function
(
reports
_dir
=
"./reports"
,
reports
=
list.
dirs
(
reports_dir
),
publish
_dir
=
"../.
./public/reports"
,
...
)
{
options
(
knitr.duplicate.label
=
'allow'
)
message
(
"output_format="
,
output_format
)
message
(
"folder list:"
)
invisible
(
sapply
(
file
s
,
message
))
invisible
(
sapply
(
report
s
,
message
))
for
(
file
in
file
s
){
for
(
report
in
report
s
){
message
(
"*******************************************************************"
)
message
(
"** RENDER "
,
file
)
message
(
"** RENDER "
,
report
)
message
(
"*******************************************************************"
)
path
<-
file.path
(
path_reports
,
file
)
render_report
()
path
<-
render_report
(
input
=
file.path
(
reports_dir
,
report
),
output_dir
=
file.path
(
publish_dir
,
report
),
...
)
}
NULL
}
This diff is collapsed.
Click to expand it.
man/render_reports.Rd
+
17
−
8
View file @
af863009
...
...
@@ -6,24 +6,31 @@
\title{Render reports}
\usage{
render_report(
path_repor
t,
path_publish
,
inpu
t,
output_dir
,
output_format = Sys.getenv("BOOKDOWN_FORMAT", "bookdown::gitbook"),
clean_cache = FALSE,
...
)
render_reports(
path_
reports = "./reports",
reports = list.files(
path_
reports, pattern = "^[0-9]{2}-.*$"),
path_
publish = "./public/reports",
reports
_dir
= "./reports",
reports = list.files(reports
_dir
, pattern = "^[0-9]{2}-.*$"),
publish
_dir
= "./public/reports",
...
)
}
\arguments{
\item{path_report}{\link{character} report path}
\item{input}{A directory, an input filename or multiple filenames. For a
directory, \file{index.Rmd} will be used if it exists in this (book)
project directory. For filenames, if \code{preview = TRUE}, only files
specified in this argument are rendered, otherwise all R Markdown files
specified by the book are rendered.}
\item{path_publish}{\link{character} rendering output path}
\item{output_dir}{The output directory. If \code{NULL}, a field named
\code{output_dir} in the configuration file \file{_bookdown.yml} will be
used (possibly not specified, either, in which case a directory name
\file{_book} will be used).}
\item{output_format}{output format, see \link[bookdown:render_book]{bookdown::render_book}. Only
\code{"bookdown::gitbook"} and \code{"bookdown::pdf_book"} are currently handled}
...
...
@@ -32,9 +39,11 @@ render_reports(
\item{...}{Parameters passed to \link{render_report} and \link[bookdown:render_book]{bookdown::render_book}}
\item{
path_
reports}{\link{character} path for the reports}
\item{reports
_dir
}{\link{character} path for the reports}
\item{reports}{\link{character} subfolders containing each report}
\item{publish_dir}{\link{character} rendering output path}
}
\value{
\code{NULL}, this function is used for side effect.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment