Module: YARD::DocsHelper
- Defined in:
- lib/yard/docs_helper.rb
Overview
Helper methods to use for yard documentation
Instance Method Summary collapse
- #link_to_component(component) ⇒ Object
- #link_to_heading_practices ⇒ Object
- #link_to_octicons ⇒ Object
- #link_to_system_arguments_docs ⇒ Object
- #link_to_typography_docs ⇒ Object
- #one_of(enumerable, lower: false) ⇒ Object
- #pretty_value(val) ⇒ Object
Instance Method Details
#link_to_component(component) ⇒ Object
33 34 35 36 |
# File 'lib/yard/docs_helper.rb', line 33 def link_to_component(component) short_name = component.name.gsub(/Primer|::|Component/, "") "[#{short_name}](/components/#{short_name.downcase})" end |
#link_to_heading_practices ⇒ Object
42 43 44 |
# File 'lib/yard/docs_helper.rb', line 42 def link_to_heading_practices "[Learn more about best heading practices (WAI Headings)](https://www.w3.org/WAI/tutorials/page-structure/headings/)" end |
#link_to_octicons ⇒ Object
38 39 40 |
# File 'lib/yard/docs_helper.rb', line 38 def link_to_octicons "[Octicon](https://primer.style/octicons/)" end |
#link_to_system_arguments_docs ⇒ Object
25 26 27 |
# File 'lib/yard/docs_helper.rb', line 25 def link_to_system_arguments_docs "[System arguments](/system-arguments)" end |
#link_to_typography_docs ⇒ Object
29 30 31 |
# File 'lib/yard/docs_helper.rb', line 29 def link_to_typography_docs "[Typography](/system-arguments#typography)" end |
#one_of(enumerable, lower: false) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/yard/docs_helper.rb', line 6 def one_of(enumerable, lower: false) values = case enumerable when Hash enumerable.map do |key, value| "#{pretty_value(key)} (#{pretty_value(value)})" end else enumerable.map do |key| pretty_value(key) end end prefix = "One of" prefix = prefix.downcase if lower "#{prefix} #{values.to_sentence(last_word_connector: ', or ')}." end |
#pretty_value(val) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/yard/docs_helper.rb', line 46 def pretty_value(val) case val when nil "`nil`" when Symbol "`:#{val}`" else "`#{val}`" end end |