Module: Rcodetools::XMPDocFilter::UseMethodAnalyzer

Defined in:
lib/rcodetools/doc.rb

Constant Summary collapse

METHOD_ANALYSIS =
"method_analysis"

Instance Method Summary collapse

Instance Method Details

#_doc(code, lineno, column = nil) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/rcodetools/doc.rb', line 117

def _doc(code, lineno, column=nil)
  find_method_analysis do |ma_file|
    methods = open(ma_file, "rb"){ |f| Marshal.load(f)}
    line = File.readlines(@filename)[lineno-1]
    current_method = line[ /^.{#{column}}\w*/][ /\w+[\?!]?$/ ].sub(/:+/,'')
    filename = @filename  # FIXME
    begin 
      methods[filename][lineno].grep(Regexp.new(Regexp.quote(current_method)))[0]
    rescue NoMethodError
      raise "doc/method_analyzer:cannot find #{current_method}"
    end

  end
end

#find_method_analysis {|File.join(here, METHOD_ANALYSIS)| ... } ⇒ Object

Yields:



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/rcodetools/doc.rb', line 100

def find_method_analysis
  here = Dir.pwd
  oldpwd = here
  begin
    while ! have_method_analysis
      Dir.chdir("..")
      if Dir.pwd == here
        return nil          # not found
      end
      here = Dir.pwd
    end
  ensure
    Dir.chdir oldpwd
  end
  yield(File.join(here, METHOD_ANALYSIS))
end

#have_method_analysisObject



96
97
98
# File 'lib/rcodetools/doc.rb', line 96

def have_method_analysis
  File.file? METHOD_ANALYSIS
end