RDoc와 YARD는 소스 주석을 구문 분석하여 API 문서를 생성하는 Ruby의 표준 문서화 도구입니다.
메서드 문서화 패턴
# Calculates total order price after applying discount vouchers.
#
# @example Applying a seasonal voucher
# calculator = PriceCalculator.new(order)
# calculator.final_total(voucher: 'SUMMER20') #=> 80.0
#
# @param voucher [String, nil] The voucher code to apply.
# @param tax_rate [Float] Applicable sales tax rate (default: 0.1).
# @return [Float] Total rounded price in USD.
# @raise [InvalidVoucherError] If voucher is expired or unrecognized.
def final_total(voucher: nil, tax_rate: 0.1)
# ...
end
인라인 마크업 서식
*bold text*
_emphasized text_
+code or monospace+
{ClassName} # 클래스 링크
{ClassName#method} # 인스턴스 메서드 링크
{ClassName.method} # 클래스 메서드 링크
특수 지시문 (Directives)
# 생성된 문서에서 메서드나 클래스 숨기기
def internal_secret # :nodoc:
end
# 특정 호출 서명 명시
# :call-seq:
# format(val) -> String
# format(val, options) -> String