Skip to content

Commit

Permalink
Merge pull request #3 from Schiano-NOAA/style-doc-code
Browse files Browse the repository at this point in the history
Style code and document
  • Loading branch information
Schiano-NOAA authored Mar 29, 2024
2 parents f75d187 + 52b4907 commit eb87050
Show file tree
Hide file tree
Showing 19 changed files with 516 additions and 495 deletions.
12 changes: 6 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ Version: 0.0.0.9000
Authors@R:
person("Samantha", "Schiano", , "samantha.schiano@noaa.gov", role = c("aut", "cre"),
comment = c(ORCID = "0009-0003-3744-6428"))
Description: Build a full or update stock assessment report for any stock
assessment model. Parameterization allows the user to call a
template based on their regional science center, species, area, ect.
Description: Build a full or update stock assessment report for any stock
assessment model. Parameterization allows the user to call a template
based on their regional science center, species, area, ect.
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Imports:
dplyr,
flextable,
Expand All @@ -22,3 +19,6 @@ Imports:
openxlsx,
purrr,
readr
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
17 changes: 7 additions & 10 deletions R/add_section.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,25 @@
#' @export
#'
#' @examples add_section(title = "Ecosystem Considerations", location = "after-discussion")

add_section <- function(
title = NULL,
location = NULL,
multi = FALSE
){
multi = FALSE) {
# Location options
# before-section
# after-section
# in-section (will always apend to the end of the section)
# before-section
# after-section
# in-section (will always apend to the end of the section)
section_name <- forstringr::str_extract_part(location, "-", before = FALSE)

if(grepl("before-", location)){
if (grepl("before-", location)) {

}

if(grepl("in-", location)){
if (grepl("in-", location)) {

}

if(grepl("after-", location)){
if (grepl("after-", location)) {

}

}
17 changes: 9 additions & 8 deletions R/chunkr.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ chunkr <- function(
warnings = "false",
eval = "true",
add_option = FALSE,
chunk_op = NULL){
chunk_op = NULL) {
chunk <- paste0(
"```{r} \n",
# Add output options
"#| echo: ", echo, " \n",
"#| warning: ", warnings, " \n",
"#| eval: ", eval, " \n")
if(add_option==TRUE){
for (i in 1:length(chunk_op)) {
chunk <- paste0(chunk, "#| ", chunk_op[i], " \n")
}
"#| eval: ", eval, " \n"
)
if (add_option == TRUE) {
for (i in 1:length(chunk_op)) {
chunk <- paste0(chunk, "#| ", chunk_op[i], " \n")
}
chunk <- paste0(chunk, x, "\n", "``` \n")
return(chunk)
}
chunk <- paste0(chunk, x, "\n", "``` \n")
return(chunk)
}
21 changes: 8 additions & 13 deletions R/convert_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,27 @@
#' adapt results among regional assessments.
#'
#' @examples
#' convert_output(output.file = "CumReport.sso", outdir = "~", model = 'ss', file.format = 'multi', multi.file = FALSE)
#' convert_output(output.file = "CumReport.sso", outdir = "~", model = "ss", file.format = "multi", multi.file = FALSE)
#'
#' @export
#'
convert_output <- function(
output.file = NULL,
outdir = NULL,
model = NULL){

if(model=="ss"){
model = NULL) {
if (model == "ss") {
# Fxn adapted from r4ss::SS_output

}

if(model=='bam'){
dat <- dget(output.file)
if (model == "bam") {
dat <- dget(output.file)
}

if(model=='asap'){

if (model == "asap") {
# This is how Bai read the ASAP output
# asap_output conversion written by Bai Li
asap_output <- dget(file.path(casedir, "output", subdir, paste("s", keep_sim_id[om_sim], sep=""), "asap3.rdat"))
setwd(file.path(casedir, "output", subdir, paste("s", keep_sim_id[om_sim], sep="")))
asap_output <- dget(file.path(casedir, "output", subdir, paste("s", keep_sim_id[om_sim], sep = ""), "asap3.rdat"))
setwd(file.path(casedir, "output", subdir, paste("s", keep_sim_id[om_sim], sep = "")))
asap_std <- readRep("asap3", suffix = ".std")

}

}
19 changes: 9 additions & 10 deletions R/create_style_css.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
create_styles_css <- function(
species = NULL,
savedir = NULL
){
#Add species image to title
savedir = NULL) {
# Add species image to title
spp_name <- sub(" ", "_", species)
spp_image <- list.files(path = here::here('inst', 'resources', 'spp_img'), pattern = spp_name)
spp_image <- list.files(path = here::here("inst", "resources", "spp_img"), pattern = spp_name)
styles_css <- paste(
".quarto-title-block .quarto-title-banner {", "\n",
" ", "background-image: ", spp_image, ";", "\n",
" ", "background-size: 300px;", "\n",
" ", "background-position: left;", "\n",
" ", "background-repeat: no-repeat;", "\n",
" ", "padding-left: 10px;", "\n",
" ", "background-origin: content-box;", "\n",
" ", "background-image: ", spp_image, ";", "\n",
" ", "background-size: 300px;", "\n",
" ", "background-position: left;", "\n",
" ", "background-repeat: no-repeat;", "\n",
" ", "padding-left: 10px;", "\n",
" ", "background-origin: content-box;", "\n",
"}", "\n"
)

Expand Down
Loading

0 comments on commit eb87050

Please sign in to comment.