Snabbreferens

TomDoc Fusklapp

Snabbreferens för kod-dokumentationsstandarden TomDoc i Ruby: metodrubriker, argumentdeklarationer och synlighetstaggar.

· Publicerad

TomDoc är en dokumentationsspecifikation för att skriva tydliga och lättlästa kodkommentarer.

Exempel på metodhuvud (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

Synlighetstaggar (Visibility Tags)

  • Public: Tillgänglig för externa användare av biblioteket.
  • Internal: Används internt mellan moduler; inte en del av det offentliga API:et.
  • Deprecated: Planerad att tas bort i framtida versioner.

Argument och alternativ (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).

Yields- och Return-satser

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

Metodsignaturer (Method Signatures)

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

Referenser

Relaterade ämnen