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

refactor report deployment #10

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 2 additions & 14 deletions R/deploy_reports.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,10 @@
#'

deploy_report <- function(report_links) {
report_links <- stringr::str_detect(report_links, "Rmd|qmd", negate = TRUE) |>
(\(x) report_links[x])()

directory_name <- dirname(report_links) |> basename() |> unique()

file_name <- basename(report_links)

to <- file.path("docs", directory_name)

dir.create(path = to, showWarnings = FALSE)
to <- dirname(report_links) |> basename() |> unique()

file.copy(from = report_links, to = to, recursive = TRUE)


file.path(
"https://oxford-ihtm.io/fair-equitable-research",
directory_name, file_name
)
file.path("https://oxford-ihtm.io/fair-equitable-research", file_name)
}
18 changes: 18 additions & 0 deletions R/render_quarto.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#'
#' Render quarto reports
#'
#' @param input The input file or project directory to be rendered.
#'
#' @returns File path to rendered report
#'

render_quarto_report <- function(input) {
quarto::quarto_render(input = input)

file_names <- paste(
tools::file_path_sans_ext(basename(input)),
c("html", "pdf"), sep = "."
)

file.path(dirname(input), "docs", file_names)
}
11 changes: 9 additions & 2 deletions _targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ output_targets <- tar_plan(

### Reporting targets
report_targets <- tar_plan(
tar_quarto(
# tar_quarto(
# name = ferc_scoping_review_report,
# path = "reports/scoping-review/ferc_scoping_review.qmd"
# )
tar_target(
name = ferc_scoping_review_report,
path = "reports/scoping-review/ferc_scoping_review.qmd"
command = render_quarto_report(
input = "reports/scoping-review/ferc_scoping_review.qmd"
),
format = "file"
)
)

Expand Down
Binary file removed docs/scoping-review/ferc_scoping_review.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions reports/scoping-review/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.quarto/
26 changes: 26 additions & 0 deletions reports/scoping-review/_quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
project:
output-dir: docs

bibliography: ../references.bib

format:
html:
toc: true
toc-location: left
embed-resources: true
grid:
body-width: 900px
margin-width: 300px
code-tools:
source: https://github.com/OxfordIHTM/fair-equitable-research/blob/main/reports/ferc_scoping_review.qmd
pdf:
documentclass: scrartcl
papersize: a4
toc: true
toc-title: Contents
lof: true
lot: true
number-sections: true
number-depth: 3
highlight-style: breeze

Original file line number Diff line number Diff line change
Expand Up @@ -3102,7 +3102,7 @@ <h2 id="toc-title">Table of contents</h2>
</ul></li>
<li><a href="#bibliography" id="toc-bibliography" class="nav-link" data-scroll-target="#bibliography">Bibliography</a></li>
</ul>
<div class="quarto-alternate-formats"><h2>Other Formats</h2><ul><li><a href="../../ferc_scoping_review.pdf"><i class="bi bi-file-pdf"></i>PDF</a></li></ul></div></nav>
<div class="quarto-alternate-formats"><h2>Other Formats</h2><ul><li><a href="ferc_scoping_review.pdf"><i class="bi bi-file-pdf"></i>PDF</a></li></ul></div></nav>
</div>
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar zindex-bottom">
</div>
Expand Down
Binary file not shown.
Binary file removed reports/scoping-review/ferc_scoping_review.docx
Binary file not shown.
4,453 changes: 0 additions & 4,453 deletions reports/scoping-review/ferc_scoping_review.html

This file was deleted.

29 changes: 0 additions & 29 deletions reports/scoping-review/ferc_scoping_review.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,6 @@ subtitle: A Scoping Review
# - name: Centre for Tropical Medicine and Global Health, Nuffield Department of Medicine, University of Oxford
# city: Oxford
date: "`r format(Sys.Date(), '%d %B %Y')`"
bibliography: ../references.bib
format:
html:
toc: true
toc-location: left
embed-resources: true
grid:
body-width: 900px
margin-width: 300px
code-tools:
source: https://github.com/OxfordIHTM/fair-equitable-research/blob/main/reports/ferc_scoping_review.qmd
# docx:
# toc: true
# toc-depth: 3
# toc-title: Table of Contents
# number-sections: true
# number-depth: 3
# reference-doc: ../reference_doc.docx
# highlight-style: breeze
pdf:
documentclass: scrartcl
papersize: a4
toc: true
toc-title: Contents
lof: true
lot: true
number-sections: true
number-depth: 3
highlight-style: breeze
---

```{r setup}
Expand Down