Skip to content

Commit

Permalink
Add details argument
Browse files Browse the repository at this point in the history
  • Loading branch information
kazuyanagimoto committed May 4, 2024
1 parent 7040906 commit 83da569
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
^\.github$
^README\.qmd$
^README\.html$
README_files/*
README_files/*
^.vscode$
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ _quarto/*
docs/
*_files/
README.html
*.pdf
*.pdf
.vscode/
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: typstcv
Type: Package
Title: CV for Quarto & Typst
Version: 0.0.0.9003
Version: 0.0.0.9004
Authors@R:
person(given = "Kazuharu",
family = "Yanagimoto",
Expand Down
11 changes: 9 additions & 2 deletions R/typstcv.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' @param location The column name for the location. Default is "location"
#' @param date The column name for the date. Default is "date"
#' @param description The column name for the description. Default is "description"
#' @param details The column name for additional details. Default is NULL
#'
#' @return A string with the resume entry
#' @export
Expand All @@ -23,7 +24,8 @@ resume_entry <- function(data,
title = "title",
location = "location",
date = "date",
description = "description") {
description = "description",
details = NULL) {
strings <- apply(data, 1, function(row) {
s <- "#resume-entry("
if (!is.na(row[title])) {
Expand All @@ -39,8 +41,13 @@ resume_entry <- function(data,
s <- sprintf("%sdescription: \"%s\",", s, row[description])
}
s <- paste0(s, ")")

if (!is.null(details)) {
s <- paste0(s, "\n#resume-item[\n", paste0("- ", row[details], collapse = "\n"), "\n]")
}

return(s)
})

cat(paste0("```{=typst}\n", paste(strings, collapse = "\n"), "\n```"))
}
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ educ |>
)
```

You can add bullet points by `details` argument.

``` r
resume_entry(award, details = c("detail1", "detail2"))
# resume_entry(award, details = grep("^detail", names(award)))
```

### Date Formatter

`date_formatter()` is a helper function to format dates in the resume.
Expand Down
7 changes: 7 additions & 0 deletions README.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ educ |>
)
```

You can add bullet points by `details` argument.

```r
resume_entry(award, details = c("detail1", "detail2"))
# resume_entry(award, details = grep("^detail", names(award)))
```

### Date Formatter

`date_formatter()` is a helper function to format dates in the resume.
Expand Down
4 changes: 3 additions & 1 deletion data-raw/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ award <- data.frame(
title = c("Nobel Prize in Physics"),
location = c("Stockholm, Sweden"),
date = c("1921"),
description = c("For his services to Theoretical Physics, and especially for his discovery of the law of the photoelectric effect.")
description = c("For his services to"),
detail1 = c("Theoretical Physics"),
detail2 = c("Discovery of the law of the photoelectric effect")
)

skill <- data.frame(
Expand Down
Binary file modified data/award.rda
Binary file not shown.
Binary file modified data/educ.rda
Binary file not shown.
Binary file modified data/pub.rda
Binary file not shown.
Binary file modified data/skill.rda
Binary file not shown.
Binary file modified data/work.rda
Binary file not shown.
5 changes: 4 additions & 1 deletion man/resume_entry.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ $endif$
fill: color-darknight,
)
set par(leading: 0.65em)
set list(indent: 1em)
body
}

Expand Down
4 changes: 3 additions & 1 deletion vignettes/awesomecv/awesomecv.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ execute:
library(typstcv)
```


## Education

```{r}
Expand Down Expand Up @@ -65,7 +66,8 @@ work |>

```{r}
#| output: asis
resume_entry(award)
resume_entry(award, details = c("detail1", "detail2"))
#resume_entry(award, details = grep("^detail", names(award)))
```

## Skills
Expand Down

0 comments on commit 83da569

Please sign in to comment.