Skip to content

Commit d8f9dad

Browse files
committed
chore: update helper files
1 parent b253e4b commit d8f9dad

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

AGENTS.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,22 @@ Rscript -e "devtools::check()"
7575
- Every user-facing function should be exported and have roxygen2 documentation.
7676
- Wrap roxygen comments at 120 characters.
7777
- Write one sentence per line.
78-
- If a sentence exceeds the limit, break at a comma or other appropriate point.
78+
- If a sentence exceeds the limit, break at a comma, "and", "or", "but", or other appropriate point.
7979
- Internal functions should not have roxygen documentation.
8080
- Always re-document the package after changing a roxygen2 comment.
8181
- Don’t hand-edit generated artifacts: `man/`, or `NAMESPACE`.
82-
- Roxygen templates live in `man-roxygen/`
82+
- Never edit `README.md` directly -- it is generated from `README.Rmd`. Always edit `README.Rmd` and then run `devtools::build_readme()` to regenerate `README.md`.
83+
- When adding a new S3 method (such as `print.<ClassName>`), always run `devtools::document()` afterwards to re-generate the NAMESPACE.
84+
- Environment variables and options are documented in package-level documentation (typically `R/package.R`).
85+
- Roxygen templates live in `man-roxygen/`. Use `@template` to avoid duplicating common parameter descriptions.
86+
Only create new templates for sections that will likely be re-used.
87+
- For functions, always document the return value (section `#' @return`).
8388
- Bibliographic references go in `R/bibentries.R` and are cited with `` `r format_bib("key")` ``.
8489

90+
## Pkgdown
91+
92+
- When adding a new exported function, ensure it's in the `_pkgdown.yml` file.
93+
8594
## `NEWS.md`
8695

8796
- Every user-facing change should be given a bullet in `NEWS.md`.
@@ -104,6 +113,6 @@ Rscript -e "devtools::check()"
104113
- Use cspell to check against typos, and add needed words to .cspell/project-words.txt if reasonable
105114

106115
## Further agents files
107-
- Read and respect all files in the `.agents` folder
116+
- Read and respect all files in the `extra-rules` folder
108117

109118

.agents/mlr3.md renamed to extra-rules/mlr3.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,32 @@ There is a distinction between `default` and `init` values:
5959
- A parameter tagged `"required"` causes an error if not set. A required parameter cannot have a `default` (that would be contradictory).
6060
- paradox does type-checking and range-checking automatically; `get_values()` checks that required params are present. Additional feasibility checks are rarely needed.
6161

62+
#### Public fields as active bindings
63+
64+
Public fields on R6 classes are exposed as active bindings backed by a private `.field`.
65+
66+
For mutable fields, the binding returns the private value when called without arguments and validates the new value with an `assert_*()` call when set:
67+
68+
```r
69+
id = function(rhs) {
70+
if (missing(rhs)) {
71+
return(private$.id)
72+
}
73+
private$.id = assert_id(rhs)
74+
},
75+
```
76+
77+
For read-only fields, call `assert_ro_binding(rhs)` to raise an error on any assignment attempt:
78+
79+
```r
80+
task_type = function(rhs) {
81+
assert_ro_binding(rhs)
82+
private$.data$task_type
83+
},
84+
```
85+
86+
The private slot must be declared in the `private` list as `.id = NULL` (or an appropriate default).
87+
6288
#### Core dependencies
6389

6490
`data.table`, `checkmate`, `mlr3misc`, `paradox`, `R6`, and `cli` are imported wholesale. Use their functions directly without `::`. Key mlr3misc utilities: `map()`, `map_chr()`, `invoke()`, `calculate_hash()`, `str_collapse()`, `%nin%`, `%??%`.

0 commit comments

Comments
 (0)