Class: Jazzy::Markdown::JazzyDeclarationHTML
- Inherits:
-
JazzyHTML
- Object
- Redcarpet::Render::HTML
- JazzyHTML
- Jazzy::Markdown::JazzyDeclarationHTML
- Defined in:
- lib/jazzy/jazzy_markdown.rb
Overview
Spot and capture returns & param HTML for separate display.
Constant Summary collapse
- INTRO_PAT =
'\A(?<intro>\s*(<p>\s*)?)'.freeze
- OUTRO_PAT =
'(?<outro>.*)\z'.freeze
- RETURNS_REGEX =
/#{INTRO_PAT}returns:#{OUTRO_PAT}/im
- IDENT_PAT =
'(?<param>\S+)'.freeze
- PARAM_PAT1 =
Param formats: normal swift, objc via sourcekitten, and possibly inside ‘Parameters:’
"(parameter +#{IDENT_PAT}\\s*:)".freeze
- PARAM_PAT2 =
"(parameter:\\s*#{IDENT_PAT}\\s+)".freeze
- PARAM_PAT3 =
"(#{IDENT_PAT}\\s*:)".freeze
- PARAM_PAT =
"(?:#{PARAM_PAT1}|#{PARAM_PAT2}|#{PARAM_PAT3})".freeze
- PARAM_REGEX =
/#{INTRO_PAT}#{PARAM_PAT}#{OUTRO_PAT}/im
Constants inherited from JazzyHTML
Jazzy::Markdown::JazzyHTML::ELIDED_LI_TOKEN, Jazzy::Markdown::JazzyHTML::GENERAL_CALLOUTS, Jazzy::Markdown::JazzyHTML::SPECIAL_LIST_TYPES, Jazzy::Markdown::JazzyHTML::SPECIAL_LIST_TYPE_REGEX, Jazzy::Markdown::JazzyHTML::UNIQUELY_HANDLED_CALLOUTS
Instance Attribute Summary collapse
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#returns ⇒ Object
readonly
Returns the value of attribute returns.
Instance Method Summary collapse
Methods inherited from JazzyHTML
Instance Attribute Details
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
114 115 116 |
# File 'lib/jazzy/jazzy_markdown.rb', line 114 def parameters @parameters end |
#returns ⇒ Object (readonly)
Returns the value of attribute returns.
114 115 116 |
# File 'lib/jazzy/jazzy_markdown.rb', line 114 def returns @returns end |
Instance Method Details
#list_item(text, _list_type) ⇒ Object
138 139 140 141 142 143 144 145 146 |
# File 'lib/jazzy/jazzy_markdown.rb', line 138 def list_item(text, _list_type) if text =~ RETURNS_REGEX @returns = render_param_returns(Regexp.last_match) elsif text =~ PARAM_REGEX @parameters[Regexp.last_match(:param)] = render_param_returns(Regexp.last_match) end super end |
#render_param_returns(matches) ⇒ Object
148 149 150 151 152 153 |
# File 'lib/jazzy/jazzy_markdown.rb', line 148 def render_param_returns(matches) body = matches[:intro].strip + matches[:outro].strip body = "<p>#{body}</p>" unless body.start_with?('<p>') # call smartypants for pretty quotes etc. postprocess(body) end |
#reset ⇒ Object
116 117 118 119 |
# File 'lib/jazzy/jazzy_markdown.rb', line 116 def reset @returns = nil @parameters = {} end |