Module: Solargraph::YardMethods

Included in:
ApiMap
Defined in:
lib/solargraph/yard_methods.rb

Instance Method Summary collapse

Instance Method Details

#yard_filesObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/solargraph/yard_methods.rb', line 31

def yard_files
  if @yard_files.nil?
    @yard_files = []
    yard_options[:include].each do |glob|
      if File.file?(glob)
        @yard_files.push File.realpath(glob)
      elsif File.directory?(glob)
        @yard_files.concat Dir["#{glob}/**/*"].map{ |f| File.realpath(f) }
      else
        @yard_files.concat Dir[glob].map{ |f| File.realpath(f) }
      end
    end
    yard_options[:exclude].each do |glob|
      if File.file?(glob)
        @yard_files.delete File.realpath(glob)
      elsif File.directory?(glob)
        @yard_files -= Dir["#{glob}/**/*"].map{ |f| File.realpath(f) }
      else
        @yard_files -= Dir[glob].map{ |f| File.realpath(f) }
      end
    end
  end
  @yard_files
end

#yard_optionsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/solargraph/yard_methods.rb', line 3

def yard_options
  if @yard_options.nil?
    @yard_options = {
      include: [],
      exclude: [],
      flags: []
    }
    unless workspace.nil?
      yardopts_file = File.join(workspace, '.yardopts')
      if File.exist?(yardopts_file)
        yardopts = File.read(yardopts_file)
        yardopts.lines.each { |line|
          arg = line.strip
          if arg.start_with?('--exclude')
            @yard_options[:exclude].concat arg.split(/[\s]+/)[1..-1]
          elsif arg.start_with?('-')
            @yard_options[:flags].push arg
          else
            @yard_options[:include].push arg
          end
        }
      end
    end
    @yard_options[:include].concat ['app/**/*.rb', 'lib/**/*.rb'] if @yard_options[:include].empty?
  end
  @yard_options
end