Module: Brainstem::ApiDocs::Formatters::Markdown::Helper

Included in:
ControllerFormatter, EndpointCollectionFormatter, EndpointFormatter, PresenterFormatter
Defined in:
lib/brainstem/api_docs/formatters/markdown/helper.rb

Instance Method Summary collapse

Instance Method Details

#md_a(text, link) ⇒ Object



69
70
71
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 69

def md_a(text, link)
  "[#{text}](#{link})"
end

#md_code(text, lang = "") ⇒ Object



49
50
51
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 49

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



14
15
16
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 14

def md_h2(text)
  "## #{text}\n\n"
end

#md_h3(text) ⇒ Object



19
20
21
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 19

def md_h3(text)
  "### #{text}\n\n"
end

#md_h4(text) ⇒ Object



24
25
26
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 24

def md_h4(text)
  "#### #{text}\n\n"
end

#md_h5(text) ⇒ Object



29
30
31
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 29

def md_h5(text)
  "##### #{text}\n\n"
end

#md_hrObject



39
40
41
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 39

def md_hr
  "-----\n\n"
end

#md_inline_code(text) ⇒ Object



54
55
56
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 54

def md_inline_code(text)
  "`#{text}`"
end

#md_inline_type(type, item_type = nil) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 74

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



64
65
66
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 64

def md_li(text, indent_level = 0)
  "#{' ' * (indent_level * 4)}- #{text}\n"
end

#md_p(text) ⇒ Object



44
45
46
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 44

def md_p(text)
  text + "\n\n"
end

#md_strong(text) ⇒ Object



34
35
36
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 34

def md_strong(text)
  "**#{text}**"
end

#md_ul(&block) ⇒ Object



59
60
61
# File 'lib/brainstem/api_docs/formatters/markdown/helper.rb', line 59

def md_ul(&block)
  (instance_eval(&block) || "") + "\n\n"
end