Huxtable R Package Development
Development assistant for working with the huxtable R package codebase. Huxtable creates styled tables in multiple output formats (HTML, LaTeX, RTF, Word, Excel, PowerPoint) with a modern interface for manipulating borders, size, position, captions, colors, text styles, and number formatting.
Behavioral Guidelines
Reduce sycophancy - avoid constantly saying "perfect" or similar phrasesChallenge assumptions about the code or R when appropriateBe open to the possibility that the developer may be wrongProvide direct, honest technical feedbackDevelopment Commands
Testing
Run tests using these commands:
All tests: `devtools::test()`Skip fuzz tests: `devtools::test(filter = "^(?!.*fuzz)", perl = TRUE)`Single test file: `devtools::test(filter = "test-file-name")`Set `NOT_CRAN=true` environment variable to avoid `skip_on_cran()` during testingTest files location: `tests/testthat/`Building and Documentation
Build package: `devtools::build()`Build without vignettes: `devtools::build(build_opts = "--no-build-vignettes")`R CMD check: `devtools::check(document = FALSE, remote = TRUE)`Generate documentation: `devtools::document()`Release and Coverage
Coverage analysis: see `run-covr.R` scriptCRAN release workflow: see `build-cran.R` script (includes vignettes, reverse dependency checks, cross-platform testing)Architecture Overview
Core Object Structure
Main constructor: `huxtable()` (alias: `hux()`) in `R/creation.R`Internal constructor: `new_huxtable()` in `R/creation-internal.R`Huxtable objects are data frames with matrix/vector attributes for formattingDefault properties stored in `huxtable_env$huxtable_default_attrs`Key Component Files
**Property Management:**
`R/property-helpers.R` - property system and helper functionsFour property categories: cell, column, row, table-levelConsistent getter/setter interface with mapping functions**Content Processing:**
`R/clean-contents.R` - number formatting, markdown rendering, escaping**Output Renderers:**
`R/html.R` - HTML generation`R/latex.R` - LaTeX with floating environments`R/typst.R` - Typst format`R/rtf.R` - RTF format`R/md.R` - Markdown output**Integration and Utilities:**
`R/knitr.R` - knitr/RMarkdown integration with format detection`R/subset-extract.R` - subsetting operations`R/merge.R` - cell merging`R/bind-insert.R` - row/column operations`R/quick-functions.R` - one-liner output functions`R/huxreg.R` - automated regression tablesOutput Pipeline
1. Content cleaning via `clean_contents()` (formatting, markdown, escaping)
2. Format-specific rendering (HTML, LaTeX, etc.)
3. Integration with document systems (knitr, RMarkdown, Quarto)
Development Guidelines
Code Organization
Group functions by responsibility in separate R filesFollow naming conventions: `get_*`, `set_*` for propertiesMirror R file organization in test files with `test-` prefixTesting Requirements
Write tests for user-visible bugs with "Bugfix: ..." titlesPlace tests in the most relevant existing test fileUse `skip_if_not_installed()` for optional dependenciesNote: `test-yy-end-to-end.R` and `test-zz-fuzz.R` may take longerDocumentation Standards
All new functions require Roxygen documentationUse `@noRd` tag for internal functionsAdd user-visible changes to NEWS.mdRun `devtools::document()` after documentation changesBranch Naming
Use short branch names with prefixes: `feature`, `bugfix`, `refactor`, or `chore`
Important Constraints
**Do not change the API without explicit permission**Update `design.md` for architectural insightsUpdate `agent-notes.md` for general development notesInstall optional packages from DESCRIPTION Suggests as neededSome packages (flextable, lmtest) may be missing - install if neededKey Reference Files
`design.md` - detailed architecture overview`agent-notes.md` - notes from previous development work`AGENTS.md` - LLM agent instructions (written for OpenAI Codex, not all accurate)`README.md` - user-facing documentation`DESCRIPTION` - package metadata and dependenciesExternal Resources
Typst documentation: https://github.com/typst/typst/tree/main/docsExample Workflow
When implementing a new feature:
1. Create a feature branch: `feature/short-description`
2. Write tests in appropriate `tests/testthat/test-*.R` file
3. Implement functionality in relevant `R/*.R` file
4. Add Roxygen documentation
5. Run `devtools::document()` to update docs
6. Run `devtools::test()` to verify tests pass
7. Add entry to NEWS.md for user-visible changes
8. Run `devtools::check(document = FALSE, remote = TRUE)`
When fixing bugs:
1. Create bugfix branch: `bugfix/issue-description`
2. Write test with "Bugfix: ..." title demonstrating the issue
3. Implement fix
4. Verify test passes
5. Update NEWS.md
6. Run full check before committing