Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add javadoc like documentation (rake doc:app) #52

Open
oveits opened this issue Mar 14, 2016 · 0 comments
Open

Add javadoc like documentation (rake doc:app) #52

oveits opened this issue Mar 14, 2016 · 0 comments

Comments

@oveits
Copy link
Owner

oveits commented Mar 14, 2016

This link of Chris Powell shows, how a method can be documented similar to javadoc (alternatively, evaluate, what rdoc can do for us).

At least for new methods, I should follow his design rules and document the method similar to his example:

# This is an example method commented the way I like. 
# It sums the three arguments and returns that value.
#
# Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
# do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
# Ut enim ad minim veniam, quis nostrud exercitation ullamco 
# laboris nisi ut aliquip ex ea commodo consequat.
#
# * *Args*    :
#   - +apples+ -> the number of apples
#   - +oranges+ -> the number of oranges
#   - +pears+ -> the number of pears
# * *Returns* :
#   - the total number of fruit as an integer
# * *Raises* :
#   - +ArgumentError+ -> if any value is nil or negative
#
def sum_fruit(apples, oranges, pears)
  raise ArgumentError, "No value can be absent" unless (apples.present? && oranges.present? && pears.present?)
  raise ArgumentError, "All values must be positive" unless (apples >= 0 && oranges >= 0 && pears >= 0)

  return apples+oranges+pears
end

The rake doc:app task then creates a documentation like
image

@oveits oveits changed the title Improve Documentation through Improve Documentation through javadoc like task: rake doc:app Mar 14, 2016
@oveits oveits changed the title Improve Documentation through javadoc like task: rake doc:app Add javadoc like documentation (task: rake doc:app) Mar 14, 2016
@oveits oveits changed the title Add javadoc like documentation (task: rake doc:app) Add javadoc like documentation (rake doc:app) Mar 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant