Sha256: a14c69d7ccf4b76f6b6e2efab45e47b90670a0defc3942b4a04aaad7b02626bb
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 KB
Contents
# frozen_string_literal: true module YARD # Helper methods to use for yard documentation module DocsHelper def one_of(enumerable, lower: false, sort: true) # Sort the array if requested if sort compare = ->(a, b) { a.class == b.class ? a <=> b : a.class.to_s <=> b.class.to_s } enumerable = enumerable.sort { |a, b| compare.call(a, b) } end 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 def link_to_accessibility "[Accessibility](#system-arguments)" end def link_to_system_arguments_docs "[System arguments](/system-arguments)" end def link_to_typography_docs "[Typography](/system-arguments#typography)" end def link_to_component(component) short_name = component.name.gsub(/Primer|::|Alpha|Beta|Component/, "") "[#{short_name}](/components/#{short_name.downcase})" end def link_to_octicons "[Octicon](https://primer.style/octicons/)" end def link_to_heading_practices "[Learn more about best heading practices (WAI Headings)](https://www.w3.org/WAI/tutorials/page-structure/headings/)" end def pretty_value(val) case val when nil "`nil`" when Symbol "`:#{val}`" else "`#{val}`" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
primer_view_components-0.0.48 | lib/yard/docs_helper.rb |
primer_view_components-0.0.47 | lib/yard/docs_helper.rb |