Class: RDocF95::RI::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc-f95/ri/reader.rb

Instance Method Summary collapse

Constructor Details

#initialize(ri_cache) ⇒ Reader

Returns a new instance of Reader.


8
9
10
# File 'lib/rdoc-f95/ri/reader.rb', line 8

def initialize(ri_cache)
  @cache = ri_cache
end

Instance Method Details

#all_namesObject

Return a list of all classes, modules, and methods


79
80
81
82
# File 'lib/rdoc-f95/ri/reader.rb', line 79

def all_names
  res = []
  find_names_in(res, @cache.toplevel)
end

#find_class_by_name(full_name) ⇒ Object


24
25
26
27
28
29
30
31
32
# File 'lib/rdoc-f95/ri/reader.rb', line 24

def find_class_by_name(full_name)
  names = full_name.split(/::/)
  ns = @cache.toplevel
  for name in names
    ns = ns.contained_class_named(name)
    return nil if ns.nil?
  end
  get_class(ns)
end

#find_methods(name, is_class_method, namespaces) ⇒ Object


34
35
36
37
38
39
40
# File 'lib/rdoc-f95/ri/reader.rb', line 34

def find_methods(name, is_class_method, namespaces)
  result = []
  namespaces.each do |ns|
    result.concat ns.methods_matching(name, is_class_method)
  end
  result
end

#full_class_namesObject

Return the names of all classes and modules


71
72
73
74
# File 'lib/rdoc-f95/ri/reader.rb', line 71

def full_class_names
  res = []
  find_classes_in(res, @cache.toplevel)
end

#get_class(class_entry) ⇒ Object

Return a class description


54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rdoc-f95/ri/reader.rb', line 54

def get_class(class_entry)
  result = nil
  for path in class_entry.path_names
    path = RiWriter.class_desc_path(path, class_entry)
    desc = File.open(path) {|f| RI::Description.deserialize(f) }
    if result
      result.merge_in(desc)
    else
      result = desc
    end
  end
  result
end

#get_method(method_entry) ⇒ Object

Return the MethodDescription for a given MethodEntry by deserializing the YAML


46
47
48
49
# File 'lib/rdoc-f95/ri/reader.rb', line 46

def get_method(method_entry)
  path = method_entry.path_name
  File.open(path) { |f| RI::Description.deserialize(f) }
end

#lookup_namespace_in(target, namespaces) ⇒ Object


16
17
18
19
20
21
22
# File 'lib/rdoc-f95/ri/reader.rb', line 16

def lookup_namespace_in(target, namespaces)
  result = []
  for n in namespaces
    result.concat(n.contained_modules_matching(target))
  end
  result
end

#top_level_namespaceObject


12
13
14
# File 'lib/rdoc-f95/ri/reader.rb', line 12

def top_level_namespace
  [ @cache.toplevel ]
end