Module: YARD::Markdown::ArefHelper
- Defined in:
- lib/yard/markdown/aref_helper.rb
Overview
Computes anchor ids that match the generated Markdown headings.
Class Method Summary collapse
-
.anchor_component(value) ⇒ String
Encodes a value so it can be embedded safely in an HTML anchor id.
-
.aref(object) ⇒ String
Returns the primary anchor id for a documented object.
Class Method Details
.anchor_component(value) ⇒ String
Encodes a value so it can be embedded safely in an HTML anchor id.
13 14 15 16 17 |
# File 'lib/yard/markdown/aref_helper.rb', line 13 def self.anchor_component(value) value.to_s.each_char.map do |char| char.match?(/[A-Za-z0-9_-]/) ? char : format("-%X", char.ord) end.join end |
.aref(object) ⇒ String
Returns the primary anchor id for a documented object.
23 24 25 |
# File 'lib/yard/markdown/aref_helper.rb', line 23 def self.aref(object) aref_for(object, object.type, object.name) end |