diff --git a/.github/workflows/connect-deploy.yaml b/.github/workflows/connect-deploy.yaml new file mode 100644 index 0000000000..8c063d5111 --- /dev/null +++ b/.github/workflows/connect-deploy.yaml @@ -0,0 +1,67 @@ +on: + push: + branches: + - master + pull_request: + branches: + - master + +name: quarto-connect-gt-examples-site + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - name: Set up Quarto + uses: quarto-dev/quarto-actions/setup@v2 + with: + version: pre-release + + - name: Print Quarto version + run: | + quarto --version + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: '4.2' + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + packages: | + gt + shiny + tidyverse + dplyr + tidyr + ggplot2 + lubridate + paletteer + janitor + rsconnect + any::sessioninfo + dependencies: '"hard"' + + - name: Install package + run: R CMD INSTALL . + + - name: Generate Quarto files for the website + run: | + Rscript -e 'gt:::write_gt_examples_qmd_files()' + + - name: Build Quarto site + run: | + quarto render gt_qmd_examples + + - name: Publish to Connect + uses: quarto-dev/quarto-actions/publish@v2 + with: + target: connect + path: gt_qmd_examples + render: false + CONNECT_SERVER: ${{ secrets.CONNECT_SERVER }} + CONNECT_API_KEY: ${{ secrets.CONNECT_API_KEY }} diff --git a/R/utils_examples.R b/R/utils_examples.R index cb557524b2..eda512e2ee 100644 --- a/R/utils_examples.R +++ b/R/utils_examples.R @@ -266,13 +266,13 @@ write_gt_examples_qmd_files <- function( index_tbl <- dplyr::bind_rows(index_tbl, index_tbl_i) } - index_tbl <- + index_tbl_gt <- index_tbl %>% dplyr::arrange(family, number) %>% dplyr::mutate( name = dplyr::case_when( type == "function" ~ paste0( - "[`", name, "()`](gt-", name , ".qmd)" + "[", name, "()](gt-", name , ".qmd)" ), .default = name ) @@ -299,17 +299,31 @@ write_gt_examples_qmd_files <- function( ) %>% gt(groupname_col = "group", process_md = TRUE) %>% fmt_markdown() %>% + fmt_url(columns = name, color = "#045AA2", target = "_self") %>% cols_hide(columns = c(type, family, number)) %>% + tab_style( + style = cell_text( + font = system_fonts("monospace-code"), + weight = 500 + ), + locations = cells_body(columns = name) + ) %>% tab_options(column_labels.hidden = TRUE) writeLines( text = c( "---", "format: html", + "html-table-processing: none", "---", "", + paste("The **gt** package has", nrow(index_tbl), "functions."), + "Each of these functions has documentation filled with examples.", + "The table below organizes all of the functions into families and ", + "links to separate pages of **gt** table examples by function.", + "", "```{=html}", - as_raw_html(index_tbl), + as_raw_html(index_tbl_gt), "```", "" ), @@ -320,14 +334,16 @@ write_gt_examples_qmd_files <- function( text = c( "project:", " type: website", + "", "render:", " - \"*.qmd\"", "", "website:", " title: \"The gt package\"", - "navbar:", - " left:", - " - href: index.qmd", + " navbar:", + " left:", + " - text: \"home\"", + " file: index.qmd", "", "format:", " html:", @@ -344,6 +360,7 @@ write_gt_examples_qmd_files <- function( text = c( "---", "format: html", + "html-table-processing: none", "toc: false", "---", "", @@ -358,6 +375,16 @@ write_gt_examples_qmd_files <- function( con = paste0(output_dir, "/gt-", topic, ".qmd") ) } + + writeLines( + text = c( + "- source: project", + " connect:", + " - id: b5709bdb-5712-42db-b265-2bfa02b5ffb6"#, + #" - url: https://colorado.posit.co/rsc/content/b5709bdb-5712-42db-b265-2bfa02b5ffb6/" + ), + con = paste0(output_dir, "/_publish.yml") + ) } #nocov end