In Files

  • doc/language/mrbdoc/lib/mrbdoc_analyze.rb
  • doc/language/mrbdoc/lib/mrbdoc_docu.rb

MRBDoc

Constants

MRBLIB_DIR
SRC_DIR

Public Instance Methods

analyze_code(dir, &block) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_analyze.rb, line 5
def analyze_code dir, &block
  @mrb_files = {}
  @dir = File.expand_path(dir)

  block.call "MRBDOC\tanalyze #{@dir}"

  analyze(dir) do |progress|
    block.call progress
  end
end
            
each_file(&block) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_analyze.rb, line 16
def each_file(&block); @mrb_files.each {|k,v| block.call k,v}; end
            
find_c_file(rb_obj_name, c_func_name) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_analyze.rb, line 26
def find_c_file(rb_obj_name, c_func_name)
  last_file_name_match = ''
  each_file do |file_name, file|
    c_func = file.c_funcs(c_func_name)
    if c_func and file.rb_class(rb_obj_name) or file.rb_module(rb_obj_name)
      return file_name
    elsif c_func
      last_file_name_match = file_name
    end
  end
  last_file_name_match
end
            
find_c_file_by_class(name) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_analyze.rb, line 39
def find_c_file_by_class(name)
  each_file do |file_name, file|
    rb_class = file.rb_class(name)
    return file_name unless rb_class.nil?
  end
  'nil'
end
            
find_c_file_by_module(name) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_analyze.rb, line 47
def find_c_file_by_module(name)
  each_file do |file_name, file|
    rb_module = file.rb_module(name)
    return file_name unless rb_module.nil?
  end
  'nil'
end
            
find_c_func(c_func_name) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_analyze.rb, line 18
def find_c_func(c_func_name)
  each_file do |file_name, file|
    c_func = file.c_funcs(c_func_name)
    return c_func unless c_func.nil?
  end
  {}
end
            
write_documentation(dir, cfg, &block) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_docu.rb, line 2
def write_documentation dir, cfg, &block
  block.call "MRBDOC\twrite to #{File.expand_path(dir)}"

  write(dir, cfg) do |progress|
    block.call progress
  end
end
            

Private Instance Methods

analyze(dir, &block) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_analyze.rb, line 57
def analyze dir, &block
  collect_all_files dir, &block
end
            
collect_all_files(dir, &block) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_analyze.rb, line 61
def collect_all_files dir, &block
  l = lambda {|f| block.call "  - #{f.name}"}
  collect_files(src_code_dir(dir), /\.c$/, &l)
  collect_files(mrb_code_dir(dir), /\.rb$/, &l)
end
            
collect_files(dir, rxp, &block) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_analyze.rb, line 67
def collect_files dir, rxp, &block
  Dir.foreach(dir) do |file|
    next unless file =~ rxp

    file_path = "#{dir}/#{file}"
    mrb_file = MRBFile.new "#{file_path}"
    @mrb_files["#{file_path}"] = mrb_file

    block.call mrb_file
  end
end
            
get_core_list(id) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_docu.rb, line 19
def get_core_list id
  core_list = {}
  each_file do |file_path, mrb_file|
    mrb_file.send(id) do |name, cls_hsh|
      core_list[name] = {:data => cls_hsh, :methods => {}, :class_methods => {}}
      mrb_file.each_method name do |met_name, met_hsh|
        core_list[name][:methods][met_name] = met_hsh
      end
      mrb_file.each_class_method name do |met_name, met_hsh|
        core_list[name][:class_methods][met_name] = met_hsh
      end
    end
  end
  core_list
end
            
mrb_code_dir(dir;) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_analyze.rb, line 80
def mrb_code_dir dir; File.expand_path MRBLIB_DIR, dir; end
            
src_code_dir(dir;) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_analyze.rb, line 79
def src_code_dir dir; File.expand_path SRC_DIR, dir; end
            
write(dir, cfg) click to toggle source
 
               # File doc/language/mrbdoc/lib/mrbdoc_docu.rb, line 12
def write dir, cfg
  File.open(File.expand_path('Core.md', dir), 'wb+') do |io|
    print_core_classes(io, cfg)
    print_core_modules(io, cfg)
  end
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus