Class: RDocF95::RI::DefaultDisplay
- Inherits:
-
Object
- Object
- RDocF95::RI::DefaultDisplay
- Includes:
- Display
- Defined in:
- lib/rdoc-f95/ri/display.rb
Overview
A paging display module. Uses the RDocF95::RI::Formatter class to do the actual presentation.
Instance Method Summary collapse
- #display_class_info(klass, ri_reader) ⇒ Object
- #display_class_list(namespaces) ⇒ Object
- #display_method_info(method) ⇒ Object
-
#display_method_list(methods) ⇒ Object
Display a list of method names.
-
#initialize(formatter, width, use_stdout) ⇒ DefaultDisplay
constructor
A new instance of DefaultDisplay.
- #list_known_classes(classes) ⇒ Object
- #list_known_names(names) ⇒ Object
Methods included from Display
Constructor Details
#initialize(formatter, width, use_stdout) ⇒ DefaultDisplay
Returns a new instance of DefaultDisplay.
35 36 37 38 |
# File 'lib/rdoc-f95/ri/display.rb', line 35 def initialize(formatter, width, use_stdout) @use_stdout = use_stdout @formatter = formatter.new $stdout, width, " " end |
Instance Method Details
#display_class_info(klass, ri_reader) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/rdoc-f95/ri/display.rb', line 56 def display_class_info(klass, ri_reader) page do superclass = klass.superclass_string if superclass superclass = " < " + superclass else superclass = "" end @formatter.draw_line(klass.display_name + ": " + klass.full_name + superclass) display_flow(klass.comment) @formatter.draw_line unless klass.includes.empty? @formatter.blankline @formatter.display_heading("Includes:", 2, "") incs = [] klass.includes.each do |inc| inc_desc = ri_reader.find_class_by_name(inc.name) if inc_desc str = inc.name + "(" str << inc_desc.instance_methods.map{|m| m.name}.join(", ") str << ")" incs << str else incs << inc.name end end @formatter.wrap(incs.sort.join(', ')) end unless klass.constants.empty? @formatter.blankline @formatter.display_heading("Constants:", 2, "") len = 0 klass.constants.each { |c| len = c.name.length if c.name.length > len } len += 2 klass.constants.each do |c| @formatter.wrap(c.value, @formatter.indent+((c.name+":").ljust(len))) end end unless klass.class_methods.empty? @formatter.blankline @formatter.display_heading("Class methods:", 2, "") @formatter.wrap(klass.class_methods.map{|m| m.name}.sort.join(', ')) end unless klass.class_method_extensions.empty? @formatter.blankline @formatter.display_heading("Class Method Extensions:", 2, "") @formatter.wrap(klass.class_method_extensions.map{|m| m.name}.sort.join(', ')) end unless klass.instance_methods.empty? @formatter.blankline @formatter.display_heading("Instance methods:", 2, "") @formatter.wrap(klass.instance_methods.map{|m| m.name}.sort.join(', ')) end unless klass.instance_method_extensions.empty? @formatter.blankline @formatter.display_heading("Instance Method Extensions:", 2, "") @formatter.wrap(klass.instance_method_extensions.map{|m| m.name}.sort.join(', ')) end unless klass.attributes.empty? @formatter.blankline @formatter.wrap("Attributes:", "") @formatter.wrap(klass.attributes.map{|a| a.name}.sort.join(', ')) end end end |
#display_class_list(namespaces) ⇒ Object
145 146 147 148 149 150 151 |
# File 'lib/rdoc-f95/ri/display.rb', line 145 def display_class_list(namespaces) page do @formatter.raw_print_line("More than one class or module matched your request. You can refine") @formatter.raw_print_line("your search by asking for information on one of:\n\n") @formatter.wrap(namespaces.map {|m| m.full_name}.join(", ")) end end |
#display_method_info(method) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rdoc-f95/ri/display.rb', line 40 def display_method_info(method) page do @formatter.draw_line(method.full_name) display_params(method) @formatter.draw_line display_flow(method.comment) if method.aliases && !method.aliases.empty? @formatter.blankline aka = "(also known as " aka << method.aliases.map {|a| a.name }.join(", ") aka << ")" @formatter.wrap(aka) end end end |
#display_method_list(methods) ⇒ Object
Display a list of method names
137 138 139 140 141 142 143 |
# File 'lib/rdoc-f95/ri/display.rb', line 137 def display_method_list(methods) page do @formatter.raw_print_line("More than one method matched your request. You can refine") @formatter.raw_print_line("your search by asking for information on one of:\n\n") @formatter.wrap(methods.map {|m| m.full_name} .join(", ")) end end |
#list_known_classes(classes) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/rdoc-f95/ri/display.rb', line 153 def list_known_classes(classes) if classes.empty? warn_no_database else page do @formatter.draw_line("Known classes and modules") @formatter.blankline @formatter.wrap(classes.sort.join(", ")) end end end |
#list_known_names(names) ⇒ Object
165 166 167 168 169 170 171 172 173 |
# File 'lib/rdoc-f95/ri/display.rb', line 165 def list_known_names(names) if names.empty? warn_no_database else page do names.each {|n| @formatter.raw_print_line(n)} end end end |