Class: YARD::Parser::SourceParser

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/parser/source_parser.rb

Class Method Summary collapse

Class Method Details

.order_by_cucumber_standards(*files) ⇒ Object

Following the conventions of ordering as Cucumber performs it

environment files - 'directory/support/env.rb,env_*.rb'
support files     - 'directory/support/*.rb' (but not env prefixed)
directory files   - 'directory/*.rb'

feature files     - 'directory/*.feature'


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/yard/parser/source_parser.rb', line 15

def order_by_cucumber_standards(*files)
  
  non_feature_files = files.reject {|x| x =~ /^.+\.feature$/}
  feature_files = files.find_all {|x| x =~ /^.+\.feature$/ }
  
  support_files = non_feature_files.find_all {|file| file =~ /support\/.+\.rb$/ }
  other_files = non_feature_files - support_files
  
  environment_files = support_files.find_all {|file| file =~ /support\/env.*\.rb$/ }
  environment_files.sort_by {|x| x.length if x }
  
  support_files = support_files - environment_files
  
  environment_files + support_files + other_files + feature_files
end

.parse_in_order(*files) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/yard/parser/source_parser.rb', line 31

def parse_in_order(*files)
  
  files = order_by_cucumber_standards(*files)
  
  while file = files.shift
    begin
      if file.is_a?(Array) && file.last.is_a?(Continuation)
        log.debug("Re-processing #{file.first}")
        file.last.call
      elsif file.is_a?(String)
        log.debug("Processing #{file}...")
        new(parser_type, true).parse(file)
      end
    rescue LoadOrderError => e
      # Out of order file. Push the context to the end and we'll call it
      files.push([file, e.message])
    end
  end
end