The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
This vignette documents the internal functions of the
boilerplate
package. These functions are not exported but
are essential for understanding the package’s architecture and
contributing to its development.
sort_db_recursive()
Recursively sorts database entries alphabetically by key.
Parameters: - db
: Database to sort
Returns: Sorted database
Usage: Ensures consistent ordering of database entries for reproducibility and easier navigation.
merge_recursive_lists()
Deep merges two list structures, handling conflicts.
Parameters: - old_list
: Base list
structure - new_list
: List to merge in -
overwrite
: How to handle conflicts
Returns: Merged list
Usage: Used in database merging operations and imports.
apply_template_vars()
Substitutes template variables in text using {{variable}} syntax.
Parameters: - text
: Text containing
{{variables}} - vars_list
: Named list of variable
substitutions - category
: Optional category for
section-specific variables
Returns: Text with variables substituted
Usage: Core of the template system. Handles both global and section-specific variable substitution.
Example:
get_db_file_path()
Constructs standardised file paths for database files.
Parameters: - category
: Database
category (e.g., “methods”, “measures”) - path_data
: Base
path for data storage - timestamp
: Whether to include
timestamp
Returns: Standardised file path
Usage: Ensures consistent file naming across the package.
read_boilerplate_db()
Reads database from JSON or RDS format.
Parameters: - file
: Path to database
file
Returns: Database structure
Usage: Handles both legacy RDS and modern JSON formats transparently.
write_boilerplate_db()
Writes database to JSON or RDS format.
# Internal function in json-support.R
write_boilerplate_db(db, file, format = c("auto", "json", "rds"))
Parameters: - db
: Database to write -
file
: Output file path - format
: Output
format
Returns: Invisible NULL
Usage: Handles format selection and data preparation for serialisation.
get_default_db()
Generic function to retrieve any default database.
Parameters: - type
: Database type
(methods, measures, results, etc.)
Returns: Default database structure
Usage: Provides starter content for new databases.
get_default_methods_db()
: Default methods contentget_default_measures_db()
: Default measures
contentget_default_results_db()
: Default results contentget_default_discussion_db()
: Default discussion
contentget_default_appendix_db()
: Default appendix
contentget_default_template_db()
: Default template
variablesstandardise_json_structure()
Ensures JSON structure matches expected RDS format.
Parameters: - json_data
: Raw JSON data
- db_type
: Type of database
Returns: Standardised structure
Usage: Handles format differences between JSON and RDS representations.
parse_bibtex_keys()
Extracts citation keys from BibTeX files.
Parameters: - bib_file
: Path to .bib
file
Returns: Character vector of citation keys
Usage: Used for reference validation.
detect_database_type()
Determines database type from filename or structure.
Parameters: - file_or_db
: Filename or
database object
Returns: Database type string
Usage: Enables automatic type detection during migrations.
migrate_to_unified_json()
Migrates separate JSON files to unified format.
Parameters: - input_dir
: Directory with
separate JSON files - output_file
: Output unified JSON
file
Returns: Invisible TRUE on success
Usage: Consolidates multiple JSON files into single unified database.
transform_label()
Transforms measure labels using mapping rules.
Parameters: - label
: Original label -
transformations
: Named list of transformations
Returns: Transformed label
Usage: Applies standardised transformations to measure labels.
Error Handling: Most internal functions assume valid inputs. Always validate before calling.
Path Operations: Use dot notation consistently (e.g., “category.subcategory.item”)
Database Modifications: Always use
modify_nested_entry()
rather than direct list
manipulation
File I/O: Use the provided read/write functions to ensure format compatibility
Testing: Internal functions should be tested indirectly through their exported wrappers
When adding new internal functions:
@noRd
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.