Skip to content

Commit

Permalink
#166 - Add default if it exists but no documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zelos Zhu committed Nov 11, 2022
1 parent a18bc5c commit d9bef1b
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions R/addin_format_function_default.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,35 @@ roxygen_clean_default <- function(path) {
paste("#' *Default*: ", "`", defaultval, "`", sep = "")
)
) %>%
ungroup() %>%
filter(str_detect(tolower(lines), "default") & (lines != defaultstatement))
ungroup()

#If default documentation already exists
recommended_fix <- final %>%
filter(str_detect(tolower(lines), "default") & (lines != defaultstatement)) %>%
select(defaultstatement, line_number) %>%
mutate(line_number = line_number + 0.01) %>%
rename(lines = defaultstatement)

file_content_new <- all_lines %>%
rbind(., recommended_fix) %>%
rbind(., recommended_fix)

#If no default documentation exists, but defaults exist
if(nrow(recommended_fix) == 0){

recommended_fix2 <- final %>%
filter(!is.na(defaultval)) %>%
group_by(fun, param) %>%
filter(line_number == max(line_number)) %>%
ungroup() %>%
select(defaultstatement, line_number) %>%
mutate(line_number = line_number + 0.02) %>%
rename(lines = defaultstatement)

file_content_new <- file_content_new %>%
rbind(., recommended_fix2)
}

file_content_new <- file_content_new %>%
arrange(line_number) %>%
pull(lines)

Expand Down

0 comments on commit d9bef1b

Please sign in to comment.