Module: Brainstem::ApiDocs::Formatters::Markdown::Helper
- Included in:
- ControllerFormatter, EndpointCollectionFormatter, EndpointFormatter, PresenterFormatter, OpenApiSpecification::Version2::Endpoint::ParamDefinitionsFormatter
- Defined in:
- lib/brainstem/api_docs/formatters/markdown/helper.rb
Instance Method Summary collapse
- #md_a(text, link) ⇒ Object
- #md_code(text, lang = "") ⇒ Object
- #md_h1(text) ⇒ Object
- #md_h2(text) ⇒ Object
- #md_h3(text) ⇒ Object
- #md_h4(text) ⇒ Object
- #md_h5(text) ⇒ Object
- #md_hr ⇒ Object
- #md_inline_code(text) ⇒ Object
- #md_inline_type(type, item_type = nil) ⇒ Object
- #md_li(text, indent_level = 0) ⇒ Object
- #md_p(text) ⇒ Object
- #md_strong(text) ⇒ Object
- #md_ul(&block) ⇒ Object
Instance Method Details
#md_a(text, link) ⇒ Object
57 58 59 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 57 def md_a(text, link) "[#{text}](#{link})" end |
#md_code(text, lang = "") ⇒ Object
41 42 43 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 41 def md_code(text, lang = "") "```#{lang}\n#{text}\n```\n\n" end |
#md_h1(text) ⇒ Object
9 10 11 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 9 def md_h1(text) "# #{text}\n\n" end |
#md_h2(text) ⇒ Object
13 14 15 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 13 def md_h2(text) "## #{text}\n\n" end |
#md_h3(text) ⇒ Object
17 18 19 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 17 def md_h3(text) "### #{text}\n\n" end |
#md_h4(text) ⇒ Object
21 22 23 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 21 def md_h4(text) "#### #{text}\n\n" end |
#md_h5(text) ⇒ Object
25 26 27 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 25 def md_h5(text) "##### #{text}\n\n" end |
#md_hr ⇒ Object
33 34 35 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 33 def md_hr "-----\n\n" end |
#md_inline_code(text) ⇒ Object
45 46 47 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 45 def md_inline_code(text) "`#{text}`" end |
#md_inline_type(type, item_type = nil) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 61 def md_inline_type(type, item_type = nil) return "" if type.blank? text = type.to_s.capitalize text += "<#{item_type.to_s.capitalize}>" if item_type.present? " (#{md_inline_code(text)})" end |
#md_li(text, indent_level = 0) ⇒ Object
53 54 55 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 53 def md_li(text, indent_level = 0) "#{' ' * (indent_level * 4)}- #{text}\n" end |
#md_p(text) ⇒ Object
37 38 39 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 37 def md_p(text) text + "\n\n" end |
#md_strong(text) ⇒ Object
29 30 31 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 29 def md_strong(text) "**#{text}**" end |
#md_ul(&block) ⇒ Object
49 50 51 |
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 49 def md_ul(&block) (instance_eval(&block) || "") + "\n\n" end |