Skip to content

Commit

Permalink
feat: source code standardization
Browse files Browse the repository at this point in the history
  • Loading branch information
averissimo committed Jan 6, 2025
1 parent 4420127 commit b8c4674
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 22 deletions.
7 changes: 5 additions & 2 deletions R/tm_a_pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -1121,9 +1121,12 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
)
})

# Render R code.
source_code_r <- reactive(teal.code::get_code(req(decorated_output_q())))

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(req(decorated_output_q()))),
verbatim_content = source_code_r,
title = "R Code for PCA"
)

Expand All @@ -1146,7 +1149,7 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(req(decorated_output_q())))
card$append_src(source_code_r())
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
7 changes: 5 additions & 2 deletions R/tm_a_regression.R
Original file line number Diff line number Diff line change
Expand Up @@ -1006,9 +1006,12 @@ srv_a_regression <- function(id,
)
})

# Render R code.
source_code_r <- reactive(teal.code::get_code(req(decorated_output_q())))

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(req(decorated_output_q()))),
verbatim_content = source_code_r,
title = "R code for the regression plot",
)

Expand All @@ -1027,7 +1030,7 @@ srv_a_regression <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(req(decorated_output_q())))
card$append_src(source_code_r())
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
7 changes: 5 additions & 2 deletions R/tm_g_association.R
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,12 @@ srv_tm_g_association <- function(id,
teal.code::dev_suppress(output_q()[["title"]])
})

# Render R code.
source_code_r <- reactive(teal.code::get_code(req(decorated_output_grob_q())))

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(req(decorated_output_grob_q()))),
verbatim_content = source_code_r,
title = "Association Plot"
)

Expand All @@ -547,7 +550,7 @@ srv_tm_g_association <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(req(decorated_output_grob_q())))
card$append_src(source_code_r())
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
7 changes: 5 additions & 2 deletions R/tm_g_bivariate.R
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,12 @@ srv_g_bivariate <- function(id,
width = plot_width
)

# Render R code.
source_code_r <- reactive(teal.code::get_code(req(decorated_output_q_facets())))

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(req(decorated_output_q_facets()))),
verbatim_content = source_code_r,
title = "Bivariate Plot"
)

Expand All @@ -736,7 +739,7 @@ srv_g_bivariate <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(req(decorated_output_q_facets)))
card$append_src(source_code_r())
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
7 changes: 5 additions & 2 deletions R/tm_g_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -1368,9 +1368,12 @@ srv_distribution <- function(id,
expr = tests_r()
)

# Render R code.
source_code_r <- reactive(teal.code::get_code(req(decorated_output_q())))

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(req(decorated_output_q()))),
verbatim_content = source_code_r,
title = "R Code for distribution"
)

Expand Down Expand Up @@ -1402,7 +1405,7 @@ srv_distribution <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(req(decorated_output_q())))
card$append_src(source_code_r())
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
7 changes: 5 additions & 2 deletions R/tm_g_response.R
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,12 @@ srv_g_response <- function(id,
width = plot_width
)

# Render R code.
source_code_r <- reactive(teal.code::get_code(req(decorated_output_plot_q())))

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(req(decorated_output_plot_q()))),
verbatim_content = source_code_r,
title = "Show R Code for Response"
)

Expand All @@ -592,7 +595,7 @@ srv_g_response <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(req(decorated_output_plot_q())))
card$append_src(source_code_r())
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
7 changes: 5 additions & 2 deletions R/tm_g_scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -1055,9 +1055,12 @@ srv_g_scatterplot <- function(id,
}
})

# Render R code.
source_code_r <- reactive(teal.code::get_code(req(decorated_output_plot_q())))

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(req(decorated_output_plot_q()))),
verbatim_content = source_code_r,
title = "R Code for scatterplot"
)

Expand All @@ -1076,7 +1079,7 @@ srv_g_scatterplot <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(req(decorated_output_plot_q())))
card$append_src(source_code_r())
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
7 changes: 5 additions & 2 deletions R/tm_g_scatterplotmatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,12 @@ srv_g_scatterplotmatrix <- function(id,
}
})

# Render R code.
source_code_r <- reactive(teal.code::get_code(req(decorated_output_q())))

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(req(decorated_output_q()))),
verbatim_content = source_code_r,
title = "Show R Code for Scatterplotmatrix"
)

Expand All @@ -507,7 +510,7 @@ srv_g_scatterplotmatrix <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(req(decorated_output_q())))
card$append_src(source_code_r())
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
7 changes: 5 additions & 2 deletions R/tm_missing_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -1361,9 +1361,12 @@ srv_missing_data <- function(id,
}
})

# Render R code.
source_code_r <- reactive(teal.code::get_code(req(decorated_final_q())))

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(req(decorated_final_q()))),
verbatim_content = source_code_r,
title = "Show R Code for Missing Data"
)

Expand Down Expand Up @@ -1399,7 +1402,7 @@ srv_missing_data <- function(id,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(req(decorated_final_q())))
card$append_src(source_code_r())
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
7 changes: 5 additions & 2 deletions R/tm_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1299,9 +1299,12 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,
)
})

# Render R code.
source_code_r <- reactive(teal.code::get_code(req(decorated_final_q())))

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(req(decorated_final_q()))),
verbatim_content = source_code_r,
title = "Show R Code for Outlier"
)

Expand Down Expand Up @@ -1333,7 +1336,7 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(req(decorated_final_q())))
card$append_src(source_code_r())
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down
7 changes: 5 additions & 2 deletions R/tm_t_crosstable.R
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,12 @@ srv_t_crosstable <- function(id, data, reporter, filter_panel_api, label, x, y,
table_r = table_r
)

# Render R code.
source_code_r <- reactive(teal.code::get_code(req(decorated_output_q())))

teal.widgets::verbatim_popup_srv(
id = "rcode",
verbatim_content = reactive(teal.code::get_code(req(decorated_output_q()))),
verbatim_content = source_code_r,
title = "Show R Code for Cross-Table"
)

Expand All @@ -450,7 +453,7 @@ srv_t_crosstable <- function(id, data, reporter, filter_panel_api, label, x, y,
card$append_text("Comment", "header3")
card$append_text(comment)
}
card$append_src(teal.code::get_code(req(decorated_output_q())))
card$append_src(source_code_r())
card
}
teal.reporter::simple_reporter_srv("simple_reporter", reporter = reporter, card_fun = card_fun)
Expand Down

0 comments on commit b8c4674

Please sign in to comment.