forked from PSLmodels/tax-microdata-benchmarking
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request PSLmodels#328 from PSLmodels/pr-parameterize-exami…
…ne-reports PR parameterize examine reports
- Loading branch information
Showing
30 changed files
with
264 additions
and
2,872 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ | |
# folders to ignore | ||
.Rproj.user/ | ||
/.quarto/ | ||
_examine/ | ||
_cd/ | ||
_state/ | ||
_freeze/ | ||
site_libs/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Create one local web site with examination results for each area type (state, | ||
# cd, or both) passed to the function render_area_reports(). The most efficient | ||
# and effective way to do this appears to be to create a single site (in the | ||
# _site folder) and then copy it to an appropriately named folder. | ||
|
||
# Optionally deploy the web site to netlify. | ||
|
||
# To run, source this file and then run render_area_reports() from the console. | ||
|
||
library(quarto) | ||
library(fs) | ||
library(stringr) | ||
library(tidyverse) | ||
|
||
generate_quarto_yaml <- function(book_title) { | ||
template <- readLines("_quarto_template.yml") | ||
rendered <- stringr::str_replace(template, coll("{{book_title}}"), book_title) | ||
writeLines(rendered, "_quarto.yml") | ||
} | ||
|
||
render_area_reports <- function(area_types = c("state", "cd"), eval_data = TRUE, deploy = FALSE) { | ||
|
||
for(area_type in area_types) { | ||
print(paste0("Area type: ", area_type)) | ||
|
||
output_dir <- paste0("_", area_type) | ||
fs::dir_create(output_dir, recurse = TRUE) | ||
|
||
if(area_type == "state") {suffix <- "states"} else | ||
if(area_type == "cd") {suffix <- "Congressional Districts"} | ||
|
||
book_title <- paste0("Examination report for ", suffix) | ||
generate_quarto_yaml(book_title) | ||
|
||
# Render entire project with parameters | ||
quarto::quarto_render( | ||
as_job = FALSE, # Ensures synchronous execution | ||
execute_params = list( | ||
area_type = area_type, | ||
eval_data = eval_data | ||
) | ||
) | ||
|
||
# Move all generated files | ||
fs::dir_copy("_site", output_dir, overwrite = TRUE) | ||
fs::dir_delete("_site") | ||
|
||
# Conditionally deploy to Netlify | ||
if(deploy){ | ||
siteid <- case_when(area_type=="state" ~ "4842eca7-3a3b-4183-8b73-5635ad95101d", | ||
area_type == "cd" ~ "573ad544-144b-4535-88cb-f2c41792fe84", | ||
.default = "ERROR") | ||
system2("netlify", | ||
args = c("deploy", | ||
"--prod", | ||
paste0("--dir=", output_dir), | ||
paste0(" --site=", siteid))) | ||
} | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,25 @@ | ||
project: | ||
type: book | ||
output-dir: _examine | ||
|
||
# https://prerelease.quarto.org/ # quarto documentation at this link | ||
|
||
# publishing with netllify cli: | ||
# open terminal in examine | ||
# quarto render && netlify deploy --prod --dir=_examine | ||
|
||
execute: | ||
eval: true | ||
echo: true | ||
output: true | ||
freeze: false # auto: during global project renders, re-render only when source changes | ||
output-dir: _site | ||
|
||
# netlify deploy --prod --dir=_state for https://tmd-examine-state.netlify.app/ | ||
# netlify deploy --prod --dir=_cd for https://tmd-examine-cds.netlify.app/ | ||
|
||
book: | ||
title: "Examine results using area weights" | ||
subtitle: "Create csv file" | ||
# author: "Don Boyd" | ||
date: today | ||
date-format: long | ||
chapters: | ||
- index.qmd | ||
- part: "Examine Congressional Districts" | ||
chapters: | ||
- cd_data_preparation.qmd | ||
- cd_summary_analysis.qmd | ||
- cd_individual_reports.qmd | ||
- part: "Examine states" | ||
chapters: | ||
- state_data_preparation.qmd | ||
- state_summary_analysis.qmd | ||
- state_individual_reports.qmd | ||
# netlify deploy --prod --dir=_state --site=4842eca7-3a3b-4183-8b73-5635ad95101d | ||
# netlify deploy --prod --dir=_cd --site=573ad544-144b-4535-88cb-f2c41792fe84 | ||
|
||
format: | ||
html: | ||
theme: cosmo | ||
code-fold: true | ||
|
||
editor_options: | ||
chunk_output_type: console | ||
code-fold: true | ||
|
||
# R packages using old 209 libxml | ||
# gt, | ||
|
||
|
||
# rendering commands | ||
# quarto render | ||
# quarto publish netlify --no-prompt --no-render --no-browser | ||
|
||
# possibly use this at start of each doc | ||
# --- | ||
# output: html_document | ||
# editor_options: | ||
# chunk_output_type: console | ||
# --- | ||
book: | ||
title: "Examination report for Congressional Districts" | ||
date: now | ||
date-format: "MMM D, YYYY hh:mm a" | ||
chapters: | ||
- index.qmd | ||
- data_preparation.qmd | ||
- summary_analysis.qmd | ||
- individual_reports.qmd | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
project: | ||
type: book | ||
output-dir: _site | ||
|
||
# netlify deploy --prod --dir=_state for https://tmd-examine-state.netlify.app/ | ||
# netlify deploy --prod --dir=_cd for https://tmd-examine-cds.netlify.app/ | ||
|
||
# netlify deploy --prod --dir=_state --site=4842eca7-3a3b-4183-8b73-5635ad95101d | ||
# netlify deploy --prod --dir=_cd --site=573ad544-144b-4535-88cb-f2c41792fe84 | ||
|
||
format: | ||
html: | ||
theme: cosmo | ||
code-fold: true | ||
|
||
book: | ||
title: "{{book_title}}" | ||
date: now | ||
date-format: "MMM D, YYYY hh:mm a" | ||
chapters: | ||
- index.qmd | ||
- data_preparation.qmd | ||
- summary_analysis.qmd | ||
- individual_reports.qmd | ||
|
Oops, something went wrong.