Module: PDoc::Generators::Html::Helpers::CodeHelper
- Included in:
- DocPage
- Defined in:
- lib/pdoc/generators/html/helpers.rb
Instance Method Summary collapse
- #breadcrumb(obj, options = {}) ⇒ Object
- #method_synopsis(object) ⇒ Object
- #methodize_full_name(obj) ⇒ Object
- #methodize_signature(sig) ⇒ Object
Instance Method Details
#breadcrumb(obj, options = {}) ⇒ Object
154 155 156 157 158 159 160 161 162 |
# File 'lib/pdoc/generators/html/helpers.rb', line 154 def (obj, = {}) = {:name => :short}.merge() result = [] begin result << auto_link(obj, .dup) obj = obj.parent end until obj.is_a?(Models::Root) result.reverse! end |
#method_synopsis(object) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/pdoc/generators/html/helpers.rb', line 141 def method_synopsis(object) result = [] object.signatures.each do |signature| if return_value = signature.return_value types = auto_link_types(return_value, :name => :long).join(' | ') result << "#{signature.name} → #{types}" else # Constructors result << signature.name end end result end |
#methodize_full_name(obj) ⇒ Object
137 138 139 |
# File 'lib/pdoc/generators/html/helpers.rb', line 137 def methodize_full_name(obj) obj.full_name.sub(/\.([^.]+)$/, '#\1') end |
#methodize_signature(sig) ⇒ Object
128 129 130 131 132 133 134 135 |
# File 'lib/pdoc/generators/html/helpers.rb', line 128 def methodize_signature(sig) sig.sub(/\.([\w\d\$]+)\((.*?)(,\s*|\))/) do first_arg = $2.to_s.strip prefix = first_arg[-1, 1] == '[' ? '([' : '(' rest = $3 == ')' ? $3 : '' "##{$1}#{prefix}#{rest}" end end |