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
cd5e7c7c
Commit
cd5e7c7c
authored
1 year ago
by
David Dorchies
Browse files
Options
Downloads
Patches
Plain Diff
feat: add render_reports function
parent
0f2447b5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
DESCRIPTION
+5
-0
5 additions, 0 deletions
DESCRIPTION
NAMESPACE
+2
-0
2 additions, 0 deletions
NAMESPACE
R/render_report.R
+42
-0
42 additions, 0 deletions
R/render_report.R
R/render_reports.R
+39
-0
39 additions, 0 deletions
R/render_reports.R
man/render_reports.Rd
+44
-0
44 additions, 0 deletions
man/render_reports.Rd
with
132 additions
and
0 deletions
DESCRIPTION
+
5
−
0
View file @
cd5e7c7c
...
...
@@ -8,3 +8,8 @@ License: AGPL (>= 3)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
Imports:
bookdown,
yaml
Suggests:
tinytex
This diff is collapsed.
Click to expand it.
NAMESPACE
+
2
−
0
View file @
cd5e7c7c
...
...
@@ -5,4 +5,6 @@ export(add_gitignore)
export(getDataPath)
export(iconv_filename)
export(loadConfig)
export(render_report)
export(render_reports)
importFrom(magrittr,"%>%")
This diff is collapsed.
Click to expand it.
R/render_report.R
0 → 100644
+
42
−
0
View file @
cd5e7c7c
#' @rdname render_reports
#' @export
render_report
<-
function
(
path_report
,
path_publish
,
output_format
=
Sys.getenv
(
"BOOKDOWN_FORMAT"
,
"bookdown::gitbook"
),
clean_cache
=
FALSE
,
...
)
{
stopifnot
(
output_format
%in%
c
(
"bookdown::gitbook"
,
"bookdown::pdf_book"
))
if
(
output_format
==
"bookdown::pdf_book"
)
{
if
(
!
require
(
"tinytex"
))
install.packages
(
"tinytex"
)
}
if
(
clean_cache
)
{
cache_dir
<-
list.files
(
path
=
path
,
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
)
dir.create
(
output_dir
,
recursive
=
TRUE
,
showWarnings
=
FALSE
)
attached_packages
<-
(
.packages
())
bookdown
::
render_book
(
path
,
output_format
=
output_format
,
output_dir
=
output_dir
,
envir
=
new.env
(),
...
)
# detach all packages used in the knit
sapply
(
setdiff
((
.packages
()),
attached_packages
),
function
(
x
)
detach
(
paste0
(
"package:"
,
x
),
unload
=
TRUE
,
character.only
=
TRUE
))
NULL
}
This diff is collapsed.
Click to expand it.
R/render_reports.R
0 → 100644
+
39
−
0
View file @
cd5e7c7c
#' Render reports
#'
#' @param path_reports [character] path for the reports
#' @param path_report [character] report path
#' @param reports [character] subfolders containing each report
#' @param path_publish [character] rendering output path
#' @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
#' @param ... Parameters passed to [render_report] and [bookdown::render_book]
#'
#' @return `NULL`, this function is used for side effect.
#' @export
#' @rdname render_reports
#'
#' @examples
render_reports
<-
function
(
path_reports
=
"./reports"
,
reports
=
list.files
(
path_reports
,
pattern
=
"^[0-9]{2}-.*$"
),
path_publish
=
"./public/reports"
,
...
)
{
options
(
knitr.duplicate.label
=
'allow'
)
message
(
"output_format="
,
output_format
)
message
(
"folder list:"
)
invisible
(
sapply
(
files
,
message
))
for
(
file
in
files
){
message
(
"*******************************************************************"
)
message
(
"** RENDER "
,
file
)
message
(
"*******************************************************************"
)
path
<-
file.path
(
path_reports
,
file
)
render_report
()
}
NULL
}
This diff is collapsed.
Click to expand it.
man/render_reports.Rd
0 → 100644
+
44
−
0
View file @
cd5e7c7c
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/render_report.R, R/render_reports.R
\name{render_report}
\alias{render_report}
\alias{render_reports}
\title{Render reports}
\usage{
render_report(
path_report,
path_publish,
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",
...
)
}
\arguments{
\item{path_report}{\link{character} report path}
\item{path_publish}{\link{character} rendering output path}
\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}
\item{clean_cache}{\link{logical} clean Rmarkdown cache files}
\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}{\link{character} subfolders containing each report}
}
\value{
\code{NULL}, this function is used for side effect.
}
\description{
Render reports
}
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