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

164 Add the list of all possible methods (blocks) for ReportCard #272

Merged
merged 15 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 0 additions & 1 deletion R/LoadReporterModule.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ load_json_report <- function(reporter, zip_path, filename) {
)
}
)

} else {
shiny::showNotification("Failed to load the Reporter file.", type = "error")
}
Expand Down
6 changes: 2 additions & 4 deletions R/SimpleReporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ NULL
#' @rdname simple_reporter
#' @export
simple_reporter_ui <- function(
id
) {
id) {
kartikeyakirar marked this conversation as resolved.
Show resolved Hide resolved
ns <- shiny::NS(id)
shiny::tagList(
shiny::singleton(
Expand Down Expand Up @@ -73,8 +72,7 @@ simple_reporter_srv <- function(
author = "NEST", title = "Report",
date = as.character(Sys.Date()), output = "html_document",
toc = FALSE
)
) {
)) {
shiny::moduleServer(
id,
function(input, output, session) {
Expand Down
Binary file added vignettes/images/blocks.png
pawelru marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions vignettes/teal-reporter-blocks-overview.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: "Comprehensive Overview of Content Blocks in `teal.reporter`"
kartikeyakirar marked this conversation as resolved.
Show resolved Hide resolved
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Comprehensive Overview of Content Blocks in teal.reporter}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

## Overview of Content Blocks
This document serves as a comprehensive guide to the various types of content blocks available in the `teal.reporter`.
These blocks allow users to structure and customize reports.

## Table: Content Blocks in `teal.reporter`
The following table outlines the different blocks that can be included in a `ReportCard`,
along with descriptions and usage examples:

| **Block Type** | **Description** | **Usage Example** |
kartikeyakirar marked this conversation as resolved.
Show resolved Hide resolved
|----------------|----------------|-------------------|
| **`ReportCard`** | Combines various content blocks into a single card. | `report_card <- ReportCard$new()` |
| **`TextBlock`** | Adds text-based content to the report. | `report_card$append_text(<text>)` |
| **`PictureBlock`** | Contains graphical content like plots or diagrams. | `report_card$append_plot(<plot>)` |
kartikeyakirar marked this conversation as resolved.
Show resolved Hide resolved
| **`RcodeBlock`** | Embeds R code directly into the report. | `report_card$append_rcode(<code text>, echo = FALSE)` |
| **`NewpageBlock`** | Marks a new page in the report for organization purposes. | `report_card$append_content(<ContentBlock e.g NewpageBlock$new()>)` |
| **`TableBlock`** | Holds and displays tabular data. | `report_card$append_table(<table>)` |

These blocks form the building blocks of a `ReportCard`, each serving a specific function that contributes to the overall layout and content of the report. The `ReportCard` object utilizes `append_*` methods to integrate various blocks such as `TextBlock`, `PictureBlock`, `RcodeBlock`, and `TableBlock`.

The following diagram illustrates the inheritance relationship between the different blocks:
```{r echo=FALSE, out.width='60%'}
knitr::include_graphics("./images/blocks.png")
```

## Global `knitr` Options
To ensure consistency and control over the rendering of markdown elements within reports, teal.reporter adheres to the following default global `knitr` options:

To access the default values for the `global_knitr` defaults include:
* echo: displays the code along with its output (`echo = TRUE`).
* tidy: formats the `R` code for readability using the `formatR` package if installed (`tidy = TRUE`), otherwise set to `FALSE`.
* width cutoff: sets the maximum number of characters per line in the code output (`tidy.opts = list(width.cutoff = 60)`).

You can access and modify these settings as follows:
```{r}
library(teal.reporter)
getOption("teal.reporter.global_knitr")
```

## Example Report Using Multiple Content Blocks
Below is a complete example demonstrating how to create a report combining various content blocks:

```{r}
library(ggplot2)

report_card <- ReportCard$new()

report_card$append_text("Header 2 text", "header2")
report_card$append_text("A paragraph of default text")
report_card$append_plot(
ggplot(airquality, aes(x = Ozone, y = Solar.R)) +
geom_line(na.rm = TRUE)
)
report_card$append_table(airquality)
report_card$append_rcode("airquality_new <- airquality", echo = FALSE)
report_card$append_metadata(key = "lm", value = lm(Ozone ~ Solar.R, airquality))
report_card$get_content()
```
Loading