Referencia rápida

Chuleta de TomDoc

Guía de referencia rápida del estándar de documentación TomDoc para Ruby: encabezados de métodos, declaraciones de argumentos y etiquetas.

· Publicado

TomDoc es una especificación de documentación para redactar comentarios de código claros y legibles para humanos.

Ejemplo de encabezado de método (Method Header)

# Public: Duplicate some text an arbitrary number of times.
#
# text  - The String to be duplicated.
# count - The Integer number of times to duplicate the text.
#
# Examples
#
#   multiplex('Tom', 4)
#   # => 'TomTomTomTom'
#
# Returns the duplicated String.
def multiplex(text, count)
  text * count
end

Etiquetas de visibilidad (Visibility Tags)

  • Public: Disponible para su consumo por usuarios externos de la biblioteca.
  • Internal: Utilizado internamente entre módulos; no forma parte de la API pública.
  • Deprecated: Programado para ser eliminado en versiones futuras.

Argumentos y opciones (Arguments and Options)

# options - The Hash options used to refine selection (default: {}):
#           :color  - The String color to restrict by (optional).
#           :weight - The Float weight in grams (optional).

Declaraciones Yields y Return

# Yields the Integer index of the current iteration.
#
# Returns the duplicated String.
# Returns nothing.
# Raises Errno::ENOENT if the file cannot be located.

Firmas de métodos (Method Signatures)

# Signature
#
#   find_by_<field>[_and_<field>...](args)

Referencias

Temas relacionados