Module: JaxrsDoc::ResourceParser

Defined in:
lib/parse.rb

Class Method Summary collapse

Class Method Details

.parse(file) ⇒ Object



49
50
51
52
53
# File 'lib/parse.rb', line 49

def self.parse(file)
  @java_file = JavaUnit.new(file.path)
  @filename = File.basename(file.path)
  parse_content
end

.parse_contentObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/parse.rb', line 55

def self.parse_content
  verbs_annotations = {:gets => [], :posts => [], :puts => [], :deletes => []}
  descriptions = {}
  type_annotations = AnnotationScanner.scan_annotations(@java_file.head.content)
  descriptions.update(ParamDescriptionScanner.scan_params_descriptions(@java_file.head.content))
  type_description = remove_params_description(@java_file.head.javadoc)
  @java_file.method_blocks.each { |section| 
    group = AnnotationScanner.scan_annotations(section.content)
    group.javadoc = remove_params_description(section.javadoc)
    descriptions.update(ParamDescriptionScanner.scan_params_descriptions(section.content))
    unless group.empty?
      verbs_annotations[:gets] << group if(group.get)
      verbs_annotations[:posts] << group if(group.post)
      verbs_annotations[:puts] << group if(group.put)
      verbs_annotations[:deletes] << group if(group.delete)
    end
  }
  JaxrsDoc::Resource.new(@filename, type_annotations, verbs_annotations, type_description, descriptions)
end