-
Notifications
You must be signed in to change notification settings - Fork 10
[Hotfix]: issues with rerendering and custom sections #412
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
base: main
Are you sure you want to change the base?
Conversation
New version checklist
|
Checklist
|
Code Metrics Report
Code coverage of files in pull request scope (48.2%)
Reported by octocov |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This hotfix addresses issues with the rerendering process and custom section placement that were discovered during workshop examples. The changes include fixes for parameter handling, region extraction, file path references, and section ordering.
Changes:
- Fixed conditional logic for author addition and region parameter handling in YAML creation
- Corrected species name extraction and region handling during template rerendering
- Fixed custom section ordering to properly include tables and figures documents
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| R/create_yaml.R | Fixed author list conditional check, updated species parameter matching, added region parameter handling, and corrected output file naming |
| R/create_title.R | Added null check for spp_latin parameter before applying LaTeX formatting |
| R/create_template.R | Fixed region extraction, species name handling, citation updates, year fallback logic, and custom section ordering |
| R/create_citation.R | Removed commented-out code for authorship lookup |
| R/add_authors.R | Fixed loop iteration to use correct vector length |
Comments suppressed due to low confidence (1)
R/create_template.R:812
- This entire params_chunk creation block (lines 791-813) is duplicated from the else branch above (lines 767-789). The code should be refactored to avoid this duplication, perhaps by moving this logic outside the if-else statement.
paste0(
"# Parameters \n",
"spp <- params$species \n",
"SPP <- params$spp \n",
"species <- params$species \n",
"spp_latin <- params$spp_latin \n",
"office <- params$office",
if (!is.null(region)) {
paste0(
"\n",
"region <- params$region"
)
},
if (!is.null(param_names)) {
paste0(
"\n",
paste0(param_names, " <- ", "params$", param_names, collapse = " \n")
)
}
),
label = "doc_parameters"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ) | ||
| } | ||
| if (!is.null(param_values) & !is.null(param_names)) { | ||
| for (i in length(param_value)) { |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop uses length(param_value) which creates a sequence from 1 to a single number, but the variable name is param_value (singular) instead of param_values (plural) which is the actual parameter name. This should be for (i in seq_along(param_values)).
| for (i in length(param_value)) { | |
| for (i in seq_along(param_values)) { |
| if (length(add_authors) > 0) { | ||
| add_authors <- unlist(stringr::str_split(author_list, "\n")) | ||
| # remove trailing \n from each author entry | ||
| add_authors <- gsub("\n", "", add_authors) |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable add_authors is checked for length before it is defined. This will cause an error since add_authors is first created on line 89. Move the length check to after the variable is created, or initialize add_authors before this check.
| if (length(add_authors) > 0) { | |
| add_authors <- unlist(stringr::str_split(author_list, "\n")) | |
| # remove trailing \n from each author entry | |
| add_authors <- gsub("\n", "", add_authors) | |
| add_authors <- unlist(stringr::str_split(author_list, "\n")) | |
| # remove trailing \n from each author entry | |
| add_authors <- gsub("\n", "", add_authors) | |
| if (length(add_authors) > 0) { |
| region = region, | ||
| type = type, | ||
| year = year | ||
| year = ifelse(is.na(year), format(as.POSIXct(Sys.Date(), format = "%YYYY-%mm-%dd"), "%Y"), year) |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The date format string '%YYYY-%mm-%dd' is incorrect. It should be '%Y-%m-%d' (single Y, single m, single d). The incorrect format will cause the POSIXct conversion to fail.
|
Reran the answers to the advanced create_template() exercises. This worked! This left an empty Also, the bug in this issue was resolved! #410 |
sbreitbart-NOAA
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't done as extensive testing as I usually would, but I tested out a few distinct situations, including the code in the workshop, and it either works perfectly or seems good enough (see my comment). Nice job!!
What is the feature?
How have you implemented the solution?
Does the PR impact any other area of the project, maybe another repo?
*no