diff --git a/doc.rb b/doc.rb index 08e48e9287e2cfd73c71c19afe7824aa3ea77dda..5e26393ef1c5d4a825f0178f10ee9a66f49fcc85 100755 --- a/doc.rb +++ b/doc.rb @@ -42,7 +42,7 @@ class Lexer elsif @input.check(/\/\*\*/) then @tokens << { :type => :doc_comment, - :value => @input.scan_until(/\*\//) + :value => DocComment.new(@input.scan_until(/\*\//)) } elsif @input.check(/"/) then @tokens << { @@ -90,6 +90,33 @@ class Lexer end +class DocComment + def initialize(input) + @input = purify(input) + end + + # Extracts content inside /** ... */ + def purify(input) + result = [] + input.each_line do |line| + if line =~ /\A\/\*\*/ || line =~ /\*\/\Z/ then + # ignore first and last line + elsif line =~ /^ *\* ?(.*)\Z/ then + result << $1 + else + result << line + end + end + return result.join("\n") + end + + def to_s + @input + end +end + + + lex = Lexer.new($stdin.read) while !lex.empty? do if lex.look(:doc_comment) then @@ -106,6 +133,7 @@ while !lex.empty? do # name: function(){ puts "function " + lex.next end + puts else lex.next end diff --git a/test.js b/test.js index e2189fe86cf6ea890ed16a354e6222ad5f435128..16559d8887b18ba1677655b417e2217d9fadb0ab 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,5 @@ /** * Creates new DateRange - * * @param {Date} beginDate * @param {Date} endDate */