Module: PDoc::Generators::Html::Helpers::MenuHelper
- Included in:
- DocPage
- Defined in:
- lib/pdoc/generators/html/helpers.rb
Constant Summary collapse
- NODES =
[ :namespaces, :classes, :mixins, :utilities ]
- LEAVES =
[ :constants, :class_methods, :class_properties, :instance_methods, :instance_properties ]
Instance Method Summary collapse
- #class_names_for(obj, options = {}) ⇒ Object
- #leaf_submenu(obj) ⇒ Object
- #menu(obj) ⇒ Object
- #menu_item(obj, options = {}) ⇒ Object
- #node_submenu(obj) ⇒ Object
Instance Method Details
#class_names_for(obj, options = {}) ⇒ Object
239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/pdoc/generators/html/helpers.rb', line 239 def class_names_for(obj, = {}) classes = [] classes << obj.type.gsub(/\s+/, '-') classes << "deprecated" if obj.deprecated? if doc_instance if obj == doc_instance classes << "current" elsif obj.ancestor_of?(doc_instance) classes << "current-parent" end end classes.join(' ') end |
#leaf_submenu(obj) ⇒ Object
224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/pdoc/generators/html/helpers.rb', line 224 def (obj) items = [] if obj.respond_to?(:constructor) && obj.constructor items << content_tag(:li, (obj.constructor, :name => :short)) end LEAVES.each do |prop| if obj.respond_to?(prop) obj.send(prop).sort!.map do |item| items << content_tag(:li, (item, :name => :short)) end end end content_tag(:ul, items.join("\n")) end |
#menu(obj) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/pdoc/generators/html/helpers.rb', line 180 def (obj) if obj.parent html = (obj, :name => :long) html << (obj) if obj == doc_instance && obj.respond_to?(:constants) html << (obj) elsif doc_instance && doc_instance.respond_to?(:parent) parent = doc_instance.parent html << (parent) if parent == obj && obj.respond_to?(:constants) end content_tag(:li, html) else #root (obj) end end |
#menu_item(obj, options = {}) ⇒ Object
218 219 220 221 222 |
# File 'lib/pdoc/generators/html/helpers.rb', line 218 def (obj, = {}) = .dup [:class] = class_names_for(obj, ) content_tag(:div, auto_link(obj, ), :class => 'menu-item') end |
#node_submenu(obj) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/pdoc/generators/html/helpers.rb', line 199 def (obj) children = [] = {} NODES.each do |prop| children.concat(obj.send(prop)) if obj.respond_to?(prop) end list_items = children.sort.map { |item| (item) } if obj.respond_to?(:sections) obj.sections.each { |section| list_items << (section) } [:class] = "menu-items" [:id] = "api_menu" elsif obj.type == "section" [:class] = "menu-section" end list_items.empty? ? '' : content_tag(:ul, list_items.join("\n"), ) end |