write-roxygen-docs
정보
이 Claude Skill은 R 패키지를 위한 포괄적인 roxygen2 문서를 생성하며, 함수, 데이터셋, 클래스, NAMESPACE 항목을 다루고 tidyverse 스타일을 따릅니다. 새로운 내보내기, 내부 도우미 함수, S3/S4/R6 메서드 문서화나 R CMD 검사 노트 수정에 이상적입니다. 이 스킬은 모든 표준 태그, 상호 참조, 예시를 처리하여 프로덕션 준비가 완료된 문서를 만들어냅니다.
빠른 설치
Claude Code
추천npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/write-roxygen-docsClaude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요
문서
Write Roxygen Documentation
Create complete roxygen2 documentation for R package functions, datasets, and classes.
When to Use
- Adding documentation to a new exported function
- Documenting internal helper functions
- Documenting package datasets
- Documenting S3/S4/R6 classes and methods
- Fixing documentation-related
R CMD checknotes
Inputs
- Required: R function, dataset, or class to document
- Optional: Related functions for cross-referencing (
@family,@seealso) - Optional: Whether the function should be exported
Procedure
Step 1: Write Function Documentation
Place roxygen comments directly above the function:
#' Compute the weighted mean of a numeric vector
#'
#' Calculates the arithmetic mean of `x` weighted by `w`. Missing values
#' in either `x` or `w` are handled according to the `na.rm` parameter.
#'
#' @param x A numeric vector of values.
#' @param w A numeric vector of weights, same length as `x`.
#' @param na.rm Logical. Should missing values be removed? Default `FALSE`.
#'
#' @return A single numeric value representing the weighted mean.
#'
#' @examples
#' weighted_mean(1:5, rep(1, 5))
#' weighted_mean(c(1, 2, NA, 4), c(1, 1, 1, 1), na.rm = TRUE)
#'
#' @export
#' @family summary functions
#' @seealso [stats::weighted.mean()] for the base R equivalent
weighted_mean <- function(x, w, na.rm = FALSE) {
# implementation
}
Got: Complete roxygen block with title, description, @param for each parameter, @return, @examples, and @export.
If fail: If unsure about a tag, check ?roxygen2::rd_roclet. Common omission is @return, which is required by CRAN for all exported functions.
Step 2: Essential Tags Reference
| Tag | Purpose | Required for export? |
|---|---|---|
#' Title | First line, one sentence | Yes |
#' Description | Paragraph after blank line | Yes |
@param | Parameter documentation | Yes |
@return | Return value description | Yes (CRAN) |
@examples | Usage examples | Strongly recommended |
@export | Add to NAMESPACE | Yes, for public API |
@family | Group related functions | Recommended |
@seealso | Cross-references | Optional |
@keywords internal | Mark as internal | For non-exported docs |
Got: All required tags for the function type are identified. Exported functions have @param, @return, @examples, and @export at minimum.
If fail: If a tag is unfamiliar, consult the roxygen2 documentation for usage and syntax.
Step 3: Document Datasets
Create R/data.R:
#' Example dataset of city temperatures
#'
#' A dataset containing daily temperature readings for major cities.
#'
#' @format A data frame with 365 rows and 4 variables:
#' \describe{
#' \item{date}{Date of observation}
#' \item{city}{City name}
#' \item{temp_c}{Temperature in Celsius}
#' \item{humidity}{Relative humidity percentage}
#' }
#' @source \url{https://example.com/data}
"city_temperatures"
Got: R/data.R contains roxygen blocks for each dataset with @format describing the structure and @source providing data provenance.
If fail: If R CMD check warns about undocumented datasets, ensure the quoted string (e.g., "city_temperatures") exactly matches the object name saved with usethis::use_data().
Step 4: Document the Package
Create R/packagename-package.R:
#' @keywords internal
"_PACKAGE"
## usethis namespace: start
## usethis namespace: end
NULL
Got: R/packagename-package.R exists with @keywords internal and the "_PACKAGE" sentinel. Running devtools::document() generates man/packagename-package.Rd.
If fail: If R CMD check reports a missing package documentation page, verify the file is named R/<packagename>-package.R and contains the "_PACKAGE" string.
Step 5: Handle Special Cases
Functions with dots in names (S3 methods):
#' @export
#' @rdname process
process.myclass <- function(x, ...) {
# S3 method
}
Reusing documentation with @inheritParams:
#' @inheritParams weighted_mean
#' @param trim Fraction of observations to trim.
trimmed_mean <- function(x, w, na.rm = FALSE, trim = 0.1) {
# implementation
}
No visible binding fix using .data pronoun:
#' @importFrom rlang .data
my_function <- function(df) {
dplyr::filter(df, .data$column > 5)
}
Got: Special cases (S3 methods, inherited params, .data pronoun) are documented correctly. @rdname groups S3 methods together. @inheritParams reuses parameter docs without duplication.
If fail: If R CMD check warns about "no visible binding for global variable," add #' @importFrom rlang .data or use utils::globalVariables() as a last resort.
Step 6: Generate Documentation
devtools::document()
Got: man/ directory updated with .Rd files for each documented object. NAMESPACE regenerated with correct exports and imports.
If fail: Check for roxygen syntax errors. Common issues: unclosed brackets in \describe{}, missing #' prefix on a line, or invalid tag names. Run devtools::document() again after fixing.
Validation
- Every exported function has
@param,@return, and@examples -
devtools::document()runs without errors -
devtools::check()shows no documentation warnings -
@familytags group related functions correctly - Examples run without errors (test with
devtools::run_examples())
Pitfalls
- Missing
@return: CRAN requires all exported functions to document their return value - Examples that need internet/auth: Wrap in
\dontrun{}with a comment explaining why - Slow examples: Use
\donttest{}for examples that work but take too long for CRAN - Markdown in roxygen: Enable with
Roxygen: list(markdown = TRUE)in DESCRIPTION - Forgetting to run
devtools::document(): Man pages are generated, not hand-written
Related Skills
create-r-package- initial package setup including roxygen configurationwrite-testthat-tests- test the functions you documentwrite-vignette- long-form documentation beyond function referencesubmit-to-cran- documentation requirements for CRAN
GitHub 저장소
연관 스킬
content-collections
메타이 스킬은 콘텐츠 콜렉션(Content Collections)을 위한 프로덕션 검증된 설정을 제공합니다. 콘텐츠 콜렉션은 Markdown/MDX 파일을 Zod 검증이 포함된 타입 안전한 데이터 콜렉션으로 변환해주는 TypeScript 최우선 도구입니다. 블로그, 문서 사이트 또는 콘텐츠 중심의 Vite + React 애플리케이션을 구축할 때 타입 안전성과 자동 콘텐츠 검증을 보장하기 위해 사용하세요. Vite 플러그인 구성과 MDX 컴파일부터 배포 최적화 및 스키마 검증에 이르기까지 모든 것을 다룹니다.
polymarket
메타이 스킬은 개발자들이 Polymarket 예측 시장 플랫폼을 활용한 애플리케이션을 구축할 수 있도록 지원하며, 거래 및 시장 데이터를 위한 API 통합 기능을 포함합니다. 또한 WebSocket을 통한 실시간 데이터 스트리밍을 제공하여 실시간 거래와 시장 활동을 모니터링할 수 있습니다. 이를 통해 거래 전략을 구현하거나 실시간 시장 업데이트를 처리하는 도구를 생성하는 데 활용할 수 있습니다.
creating-opencode-plugins
메타이 스킬은 개발자들이 명령어, 파일, LSP 작업 등 25개 이상의 이벤트 유형에 연결되는 OpenCode 플러그인을 만들 수 있도록 돕습니다. JavaScript/TypeScript 모듈을 위한 플러그인 구조, 이벤트 API 명세, 구현 패턴을 제공합니다. OpenCode AI 어시스턴트의 라이프사이클을 사용자 정의 이벤트 기반 로직으로 가로채거나, 모니터링하거나, 확장해야 할 때 사용하세요.
sglang
메타SGLang은 RadixAttention 프리픽스 캐싱을 활용하여 JSON, 정규식, 에이전트 워크플로우를 위한 고속 구조화 생성에 특화된 고성능 LLM 서빙 프레임워크입니다. 특히 반복되는 프리픽스가 있는 작업에서 상당히 빠른 추론 속도를 제공하여 복잡한 구조화 출력 및 다중 턴 대화에 이상적입니다. 제약 디코딩이 필요하거나 광범위한 프리픽스 공유가 있는 애플리케이션을 구축할 때는 vLLM과 같은 대안보다 SGLang을 선택하십시오.
