RDoc i YARD to standardowe narzędzia dokumentacyjne w Ruby, generujące dokumentację API z komentarzy.
Wzorzec dokumentowania metod
# 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
Formatowanie znaczników inline
*bold text*
_emphasized text_
+code or monospace+
{ClassName} # Link do klasy
{ClassName#method} # Link do metody instancji
{ClassName.method} # Link do metody klasy
Specjalne dyrektywy
# Ukrycie metody lub klasy przed generowaniem dokumentacji
def internal_secret # :nodoc:
end
# Dokumentowanie sygnatury wywołania
# :call-seq:
# format(val) -> String
# format(val, options) -> String