Class: ReadmeYard::ExampleTag
- Inherits:
-
Object
- Object
- ReadmeYard::ExampleTag
- Defined in:
- lib/readme_yard/example_tag.rb
Overview
The Example Tag leverages YARD's standard @example
tag syntax, allowing you to
include example code in your README directly from source files. This saves time and
ensures your README stays in sync with your YARD documentation
Class Method Summary collapse
- .format_ruby(text) ⇒ Object
- .format_tag(yard_object, tag) ⇒ Object
- .format_tags(yard_object, yard_tags) ⇒ Object
- .hello_world ⇒ Object
Class Method Details
.format_ruby(text) ⇒ Object
31 32 33 |
# File 'lib/readme_yard/example_tag.rb', line 31 def format_ruby(text) "```ruby\n#{text}\n```\n" end |
.format_tag(yard_object, tag) ⇒ Object
26 27 28 29 |
# File 'lib/readme_yard/example_tag.rb', line 26 def format_tag(yard_object, tag) text = tag.text.empty? ? yard_object.source : tag.text format_ruby(text) end |
.format_tags(yard_object, yard_tags) ⇒ Object
22 23 24 |
# File 'lib/readme_yard/example_tag.rb', line 22 def (yard_object, ) .map { |tag| format_tag(yard_object, tag) }.join("\n") end |
.hello_world ⇒ Object
18 19 20 |
# File 'lib/readme_yard/example_tag.rb', line 18 def hello_world "Hello 🌎 🌍 🌏" end |