Module: YARD::Markdown::HeadingHelper
- Includes:
- ArefHelper
- Defined in:
- lib/yard/markdown/heading_helper.rb
Overview
Builds headings and legacy anchors for rendered object sections.
Instance Method Summary collapse
-
#anchor_tag(id) ⇒ String
Builds an HTML anchor tag for a generated id.
-
#anchor_tags_for(object) ⇒ Array<String>
Returns all anchor tags that should be attached to a heading.
-
#heading_with_anchors(heading, object) ⇒ String
Appends the generated anchor tags to a Markdown heading.
-
#legacy_aref(object) ⇒ String?
Returns the legacy YARD anchor for an object when one exists.
Methods included from ArefHelper
Methods included from AnchorComponentHelper
Instance Method Details
#anchor_tag(id) ⇒ String
Builds an HTML anchor tag for a generated id.
47 48 49 |
# File 'lib/yard/markdown/heading_helper.rb', line 47 def anchor_tag(id) %(<a id="#{id}"></a>) end |
#anchor_tags_for(object) ⇒ Array<String>
Returns all anchor tags that should be attached to a heading.
29 30 31 32 |
# File 'lib/yard/markdown/heading_helper.rb', line 29 def (object) anchors = [aref(object), legacy_aref(object)].compact anchors.map { |id| anchor_tag(id) } end |
#heading_with_anchors(heading, object) ⇒ String
Appends the generated anchor tags to a Markdown heading.
39 40 41 |
# File 'lib/yard/markdown/heading_helper.rb', line 39 def heading_with_anchors(heading, object) "#{heading} #{(object).join(' ')}" end |
#legacy_aref(object) ⇒ String?
Returns the legacy YARD anchor for an object when one exists.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/yard/markdown/heading_helper.rb', line 13 def legacy_aref(object) type = object.type return "#{object.name}-constant" if type == :constant return "#{object.name}-classvariable" if type == :classvariable return nil unless object.respond_to?(:scope) return "#{object.name}-class_method" if object.scope == :class "#{object.name}-instance_method" end |