Created
August 6, 2012 09:42
-
-
Save xaviervia/3272882 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Demonstration | |
# Description of the method | |
def the_method required_argument, optional_one = true | |
"Do something, not much" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load "demonstration.rb" | |
lines = File.read("demonstration.rb").lines.to_a | |
methods = Demonstration.instance_methods false | |
summaries = {} | |
methods.each do |m_sym| | |
m = Demonstration.instance_method m_sym | |
line = lines[m.source_location.last - 1] | |
possible_comment = lines[m.source_location.last - 2].strip | |
comment = possible_comment if possible_comment.start_with? "#" # Repeat for previous line, do not forget! | |
params = m.parameters | |
summaries[m.name] = { :params => params, | |
:desc => comment } | |
end | |
puts summaries | |
# There. I just need to add some spice to the class, like Thor::Actions, and rendering for the comment, like Redcarpet::ANSI (Blackcarpet) | |
# The only question remaining is, Thor or not Thor? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment