一键导入
document
Document package functions. Use when asked to document functions.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Document package functions. Use when asked to document functions.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Creates GitHub issues for the package repository. Use when asked to create, file, or open a GitHub issue, or when planning new features or functions that need to be tracked.
Test-driven development workflow. Use when writing any R code (writing new features, fixing bugs, refactoring, or reviewing tests).
Test-driven development workflow. Use when writing any R code (writing new features, fixing bugs, refactoring, or reviewing tests).
Creates GitHub issues for the package repository. Use when asked to create, file, or open a GitHub issue, or when planning new features or functions that need to be tracked.
| name | document |
| trigger | document functions |
| description | Document package functions. Use when asked to document functions. |
All R functions in R/ should be documented in roxygen2 #' style, including internal/unexported functions.
air format . then devtools::document() after changing any roxygen2 docs.R/import-standalone-*.R are imported from other packages and have their own conventions. Do not modify their documentation.devtools::document(roclets = c('rd', 'collate', 'namespace'))._pkgdown.yml exists and contains a reference section:
_pkgdown.yml.pkgdown::check_pkgdown() to check that all topics are included in the reference index.Parameters used in more than one function go in R/aaa-shared_params.R under @name .shared-params. Functions inherit them with @inheritParams .shared-params. See R/aaa-shared_params.R for current definitions (if it exists).
Shared params blocks: alphabetize parameters, use @name .shared-params (with leading dot), include @keywords internal, end with NULL.
Multiple shared-params groups (e.g. .shared-params-io, .shared-params-parsing) are appropriate when parameters are only shared within a file and closely related files.
#' @param param_name (`TYPE`) Brief description (usually 1-3 sentences. Can
#' include [cross_references()]. Additional details on continuation lines if
#' needed.
Function-specific @param definitions always appear before any @inheritParams lines. If all parameters are defined locally, omit @inheritParams entirely.
These are non-exhaustive examples. Other classes (such as httr2_response) are possible
| Notation | Meaning |
|---|---|
(`character`) | Character vector |
(`character(1)`) | Single string |
(`logical(1)`) | Single logical |
(`integer`) | Integer vector |
(`integer(1)`) | Single integer |
(`double`) | Double vector |
(`vector(0)`) | A prototype (zero-length vector) |
(`vector`) | A vector of unspecified type |
(`list`) | List |
(`data.frame`) | Data frame or tibble |
(`tibble`) | Explicit tibble (when we KNOW the return is always a tibble) |
(`NULL`) | NULL only |
(`function` or `NULL`) | A function or NULL |
(`my_class`) | A class-specific type (use the actual class name) |
(`any`) | Any type |
(`NULL`, invisibly) | For returns, note invisible() returns with the type |
When a parameter takes one of a fixed set of values, document them with a bullet list:
#' @param method (`character(1)`) The aggregation method. Can be one of:
#' * `"mean"`: Arithmetic mean.
#' * `"median"`: Median value.
#' * `"sum"`: Total sum.
Use @returns (not @return). Include a type or types:
#' @returns (`tibble`) A summary tibble.
#' @returns (`logical(1)`) `TRUE` if `x` is a valid record.
#' @returns (`tibble` or `list`) Either a tibble or a list, depending on the input.
#' @returns (`NULL`, invisibly) Called for warning side effect.
Structured returns with columns:
#' @returns (`tibble`) A [tibble::tibble()] with columns:
#' - `name`: Record name.
#' - `value`: Numeric value.
#' - `status`: Status (`"active"` or `"inactive"`).
#' Title in sentence case
#'
#' Description paragraph providing context and details.
#'
#' @param param_name (`TYPE`) Description.
#' @inheritParams .shared-params
#'
#' @returns (`TYPE`) Description of return value.
#' @seealso [related_function()]
#' @export
#'
#' @examples
#' example_code()
#' lines separate: title/description, description/params, and @export/@examples.@seealso (optional) goes between @returns and @export.@details can supplement the description when needed.Internal helpers (identified by a dot prefix, e.g. .parse_response()) use abbreviated documentation. Mark them with @keywords internal and omit @export:
#' Title in sentence case
#'
#' @param one_off_param (`TYPE`) Description.
#' @inheritParams .shared-params
#' @returns (`TYPE`) What it returns.
#' @keywords internal
Description paragraph is optional (only include when usage isn't obvious), fewer blank #' lines, and no @examples.
@rdname groupingUse @rdname to group related functions under one help page. This applies to:
@rdname + @export.@rdname + @export.#' Format a summary object
#'
#' @param x (`any`) The object to format.
#' @param ... Additional arguments passed to methods.
#' @returns (`character(1)`) A formatted summary string.
#' @keywords internal
.format_summary <- function(x, ...) {
UseMethod(".format_summary")
}
#' @rdname .format_summary
#' @export
.format_summary.data_summary <- function(x, ...) {
# method implementation
}
S3 methods we don't own (generic from another package) need standalone documentation:
#' Title describing the method
#'
#' @param x (`TYPE`) Description.
#' @param ... Additional arguments (ignored).
#' @returns (`TYPE`) Description.
#' @exportS3Method pkg::generic
method.class <- function(x, ...) { ... }
Cross-references: Use square brackets — [fetch_records()] (internal), [tibble::tibble()] (external), [topic_name] (topics).
Section comment headers optionally organize code within a file, lowercase with dashes to column 80:
# helpers ----------------------------------------------------------------------
Only use such headers in complex files. The need for section comment headers might indicate that the file should be split into multiple files.
Examples: Exported functions include @examples. Use @examplesIf interactive() for network-dependent or slow functions. Use section-style comments (# Section ---) to organize longer example blocks. Internal functions do not get examples.