Title: | Enhance 'Quarto' Project Workflows and Standards |
---|---|
Description: | Streamlines 'Quarto' workflows by providing tools for consistent project setup and documentation. Enables portability through reusable metadata, automated project structure creation, and standardized templates. Features include enhanced project initialization, pre-formatted 'Quarto' documents, comprehensive data protection settings, custom styling, and structured documentation generation. Designed to improve efficiency and collaboration in R data science projects by reducing repetitive setup tasks while maintaining consistent formatting across multiple documents. There are many valuable resources providing in-depth explanations of customizing 'Quarto' templates and theme styling by the Posit team: <https://quarto.org/docs/output-formats/html-themes.html#customizing-themes> & <https://quarto.org/docs/output-formats/html-themes-more.html>, and at the Bootstrap community's GitHub at <https://github.com/twbs/bootstrap/blob/main/scss/_variables.scss>. |
Authors: | Kyle Grealis [aut, cre] |
Maintainer: | Kyle Grealis <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0 |
Built: | 2025-02-20 06:16:14 UTC |
Source: | https://github.com/kylegrealis/frogger |
This function creates a new 'Quarto' project directory with additional froggeR
features. It first calls quarto::quarto_create_project()
to set up the
basic structure, then enhances it with froggeR-specific files and settings.
quarto_project(name, path = here::here(), custom_yaml = TRUE)
quarto_project(name, path = here::here(), custom_yaml = TRUE)
name |
Character string. The name of the 'Quarto' project directory and
initial |
path |
Character string. Path to the project directory. |
custom_yaml |
Logical. If TRUE (default), uses a custom YAML header in the initial
|
This function creates a 'Quarto' project with the following enhancements:
_variables.yml
: Stores reusable YAML variables (if custom_yaml =
TRUE
)
.gitignore
: Enhanced settings for R projects
README.md
: Template README file
dated_progress_notes.md
: For project progress tracking
custom.scss
: Custom 'Quarto' styling (if custom_yaml = TRUE
)
.Rproj
: RStudio project file
If froggeR settings don't exist, it will prompt to create them.
Invisibly returns the path to the created project directory.
if (quarto::quarto_version() >= "1.4") { # Create a temporary directory for testing tmp_dir <- tempdir() # Create the Quarto project with custom YAML & associated files quarto_project("frogs", path = tempdir(), custom_yaml = TRUE) # Confirms files were created (optional, for user confirmation) file.exists(file.path(tmp_dir, "frogs.rproj")) # Rproj file file.exists(file.path(tmp_dir, "frog.qmd")) # Quarto doc file.exists(file.path(tmp_dir, "_quarto.yml")) # project YAML file # Create a new Quarto project with standard Quarto YAML # quarto_project('frogs_standard', path = tempdir(), custom_yaml = FALSE) # Clean up: Remove the created temp directory and all files unlink(list.files(tempdir(), full.names = TRUE), recursive = TRUE) }
if (quarto::quarto_version() >= "1.4") { # Create a temporary directory for testing tmp_dir <- tempdir() # Create the Quarto project with custom YAML & associated files quarto_project("frogs", path = tempdir(), custom_yaml = TRUE) # Confirms files were created (optional, for user confirmation) file.exists(file.path(tmp_dir, "frogs.rproj")) # Rproj file file.exists(file.path(tmp_dir, "frog.qmd")) # Quarto doc file.exists(file.path(tmp_dir, "_quarto.yml")) # project YAML file # Create a new Quarto project with standard Quarto YAML # quarto_project('frogs_standard', path = tempdir(), custom_yaml = FALSE) # Clean up: Remove the created temp directory and all files unlink(list.files(tempdir(), full.names = TRUE), recursive = TRUE) }
This function provides useful instructions and information regarding 'froggeR' settings.
settings()
settings()
This function can only run in an interactive environment. Choose to: - Check for the existence of project- and global-level configuration files - Display current project-level settings - Feedback for updating settings - Instructions how to reuse settings across multiple 'froggeR' Quarto projects.
No return value; called for side-effects.
# Only run in an interactive environment if (interactive()) froggeR::settings()
# Only run in an interactive environment if (interactive()) froggeR::settings()
.gitignore
fileThis function creates a .gitignore
file with enhanced security
measures designed to help prevent accidental data leaks. The template includes
comprehensive rules for common data file types and sensitive information.
write_ignore(path = here::here(), .initialize_proj = FALSE)
write_ignore(path = here::here(), .initialize_proj = FALSE)
path |
Character string. Path to the project directory. |
.initialize_proj |
Logical. TRUE only if starting a
|
If a .gitignore
file already exists, the user will be prompted before any
overwriting occurs. The template provides substantial security enhancements
over basic .gitignore
files.
WARNING: Always consult your organization's data security team before using git with any sensitive or protected health information (PHI). This template helps prevent accidental data exposure but should not be considered a complete security solution.
A .gitignore
file with enhanced security rules. The file includes:
* R data files (.RData, .rda, .rds)
* Common data formats (CSV, Excel, text)
* System and temporary files
* IDE-specific files
# Create a temporary directory for testing tmp_dir <- tempdir() # Write the .gitignore file write_ignore(path = tmp_dir) # Confirm the file was created (optional, for user confirmation) file.exists(file.path(tmp_dir, ".gitignore")) # Clean up: Remove the created file unlink(file.path(tmp_dir, ".gitignore"))
# Create a temporary directory for testing tmp_dir <- tempdir() # Write the .gitignore file write_ignore(path = tmp_dir) # Confirm the file was created (optional, for user confirmation) file.exists(file.path(tmp_dir, ".gitignore")) # Clean up: Remove the created file unlink(file.path(tmp_dir, ".gitignore"))
This function streamlines project documentation by creating a dated progress notes file.
write_notes(path = here::here(), .initialize_proj = FALSE)
write_notes(path = here::here(), .initialize_proj = FALSE)
path |
Character string. Path to the project directory. |
.initialize_proj |
Logical. TRUE only if starting a
|
The dated_progress_notes.md file is initialized with the current date and is designed to help track project milestones chronologically. If the progress notes file already exists, the function will stop and warn the user.
CA chronological project progress notes tracker.
# Create a temporary directory for testing tmp_dir <- tempdir() # Write the progress notes file write_notes(path = tmp_dir) # Confirm the file was created (optional, for user confirmation) file.exists(file.path(tmp_dir, "dated_progress_notes.md")) # Clean up: Remove the created file unlink(file.path(tmp_dir, "dated_progress_notes.md"))
# Create a temporary directory for testing tmp_dir <- tempdir() # Write the progress notes file write_notes(path = tmp_dir) # Confirm the file was created (optional, for user confirmation) file.exists(file.path(tmp_dir, "dated_progress_notes.md")) # Clean up: Remove the created file unlink(file.path(tmp_dir, "dated_progress_notes.md"))
This function creates a new 'Quarto' document (.qmd file) with either a custom or standard YAML header. When using a custom header, it integrates with 'froggeR::settings()' for reusable metadata across documents.
write_quarto( filename = "frogs", path = here::here(), custom_yaml = TRUE, .initialize_proj = FALSE )
write_quarto( filename = "frogs", path = here::here(), custom_yaml = TRUE, .initialize_proj = FALSE )
filename |
Character string. The name of the file without the '.qmd' extension. Only letters, numbers, hyphens, and underscores are allowed. |
path |
Character string. Path to the project directory. |
custom_yaml |
Logical. If TRUE (default), creates a 'Quarto' document with a custom YAML header using values from '_variables.yml'. If FALSE, creates a standard 'Quarto' document. |
.initialize_proj |
Logical. TRUE only if starting a
|
When 'custom_yaml = TRUE', the function will check if '_variables.yml' exists. This file is needed to supply Quarto document metadata in the 'path' project. The user will be prompted with help if they don't already exist, and a Quarto document with the default template will be supplied instead.
Invisibly returns NULL after creating the 'Quarto' document.
# Create a temporary directory for testing tmp_dir <- tempdir() # Write the Quarto & associated files for a custom YAML with reusable metadata write_quarto(path = tempdir(), filename = "frog_analysis") # Write the Quarto file with a template requiring more DIY write_quarto(path = tempdir(), filename = "frog_analysis_basic", custom_yaml = FALSE) # Confirm the file was created (optional, for user confirmation) file.exists(file.path(tmp_dir, "frog_analysis.qmd")) file.exists(file.path(tmp_dir, "frog_analysis_basic.qmd")) # Clean up: Remove the created file unlink(list.files(tempdir(), full.names = TRUE), recursive = TRUE)
# Create a temporary directory for testing tmp_dir <- tempdir() # Write the Quarto & associated files for a custom YAML with reusable metadata write_quarto(path = tempdir(), filename = "frog_analysis") # Write the Quarto file with a template requiring more DIY write_quarto(path = tempdir(), filename = "frog_analysis_basic", custom_yaml = FALSE) # Confirm the file was created (optional, for user confirmation) file.exists(file.path(tmp_dir, "frog_analysis.qmd")) file.exists(file.path(tmp_dir, "frog_analysis_basic.qmd")) # Clean up: Remove the created file unlink(list.files(tempdir(), full.names = TRUE), recursive = TRUE)
This function streamlines project documentation by a README.md file.
write_readme(path = here::here(), .initialize_proj = FALSE)
write_readme(path = here::here(), .initialize_proj = FALSE)
path |
Character string. Path to the project directory. |
.initialize_proj |
Logical. TRUE only if starting a
|
The README.md template includes structured sections for:
Project description (study name, principal investigator, author)
Project setup steps for reproducibility
File and directory descriptions
Miscellaneous project notes
Creates a comprehensive README template for project documentation.
# Create a temporary directory for testing tmp_dir <- tempdir() # Write the README file write_readme(path = tmp_dir) # Confirm the file was created (optional, for user confirmation) file.exists(file.path(tmp_dir, "README.md")) # Clean up: Remove the created file unlink(file.path(tmp_dir, "README.md"))
# Create a temporary directory for testing tmp_dir <- tempdir() # Write the README file write_readme(path = tmp_dir) # Confirm the file was created (optional, for user confirmation) file.exists(file.path(tmp_dir, "README.md")) # Clean up: Remove the created file unlink(file.path(tmp_dir, "README.md"))
This function creates the .scss
file so that any 'Quarto' project can be easily
customized with SCSS styling variables, mixins, and rules.
write_scss(path = here::here(), .initialize_proj = FALSE)
write_scss(path = here::here(), .initialize_proj = FALSE)
path |
Character string. Path to the project directory. |
.initialize_proj |
Logical. TRUE only if starting a
|
The function includes a robust YAML handling mechanism that safely adds new SCSS file.
See vignette("customizing-quarto", package = "froggeR")
vignette for more help.
A SCSS file to customize 'Quarto' styling.
# Create a temporary directory for testing tmp_dir <- tempdir() # Write the SCSS file write_scss(path = tmp_dir) # Confirm the file was created (optional, for user confirmation) file.exists(file.path(tmp_dir, "custom.scss")) # Clean up: Remove the created file unlink(file.path(tmp_dir, "custom.scss"))
# Create a temporary directory for testing tmp_dir <- tempdir() # Write the SCSS file write_scss(path = tmp_dir) # Confirm the file was created (optional, for user confirmation) file.exists(file.path(tmp_dir, "custom.scss")) # Clean up: Remove the created file unlink(file.path(tmp_dir, "custom.scss"))
This function creates or updates the '_variables.yml' file in a Quarto project directory using froggeR settings, if they exist in the config path.
write_variables(path = here::here(), .initialize_proj = FALSE)
write_variables(path = here::here(), .initialize_proj = FALSE)
path |
Character string. Path to the project directory. |
.initialize_proj |
Logical. TRUE only if starting a
|
The function will attempt to use the current froggeR settings from the config path. If no global configurations exist, a template '_variables.yml' will be created.
Invisibly returns 'NULL' after creating or updating the '_variables.yml' file.
# Create a temporary directory for testing tmp_dir <- tempdir() # Write the _variables.yml file write_ignore(path = tmp_dir) # Confirm the file was created (optional, for user confirmation) file.exists(file.path(tmp_dir, "_variables.yml")) # Clean up: Remove the created file unlink(file.path(tmp_dir, "_variables.yml"))
# Create a temporary directory for testing tmp_dir <- tempdir() # Write the _variables.yml file write_ignore(path = tmp_dir) # Confirm the file was created (optional, for user confirmation) file.exists(file.path(tmp_dir, "_variables.yml")) # Clean up: Remove the created file unlink(file.path(tmp_dir, "_variables.yml"))