Skip to content

Documentation conventions

samehmetias edited this page Apr 11, 2014 · 1 revision

Documenting a method in ruby Here are examples of how we should be documenting our methods in ruby and our html files

Ruby methods:

Author: Sameh Metias

Team: 3

Method name: multiplex

Function: Duplicate some text an abitrary number of times.

Parameters:

text - The String to be duplicated.

count - The Integer number of times to duplicate the text.

Example:

multiplex('Tom', 4)

# => 'TomTomTomTom'

Returns the duplicated String.

def multiplex(text, count) text * count end


Documenting HTML/JavaScript files Comment at the beginning of important tags indicating the function of that specific tag. Do not document each single tag (e.g tags that start and end on the same line) but tags containing many lines of code

<% @items.each do |item| %>

<%= item.name %> <%= item.price %> <%= item.category %> <%= item.amount %> <%= item.status %> <%= item.description %> <%= item.rating %> <%= link_to 'Show', item %> <%= link_to 'Edit', edit_item_path(item) %> <%= link_to 'Destroy', item, method: :delete, data: { confirm: 'Are you sure?' } %> <%= button_to 'Pause', item %> <%= button_to 'Resume', item %> <% end %>