Class: RTFDoc::Section
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Anchorable
#anchor
#content_to_html, included
Constructor Details
#initialize(name, raw_content, resource: nil) ⇒ Section
Returns a new instance of Section.
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# File 'lib/rtfdoc.rb', line 162
def initialize(name, raw_content, resource: nil)
@name = name
@resource = resource
metadata = nil
if raw_content.start_with?('---')
idx = raw_content.index('---', 4)
raise 'bad format' unless idx
parse_metadata(YAML.load(raw_content.slice!(0, idx + 3)))
end
raise 'missing metadata' if resource && !meta_section? && !@path && !@method
@content, @example = raw_content.split('$$$')
end
|
Instance Attribute Details
#method ⇒ Object
Returns the value of attribute method.
160
161
162
|
# File 'lib/rtfdoc.rb', line 160
def method
@method
end
|
#name ⇒ Object
Returns the value of attribute name.
160
161
162
|
# File 'lib/rtfdoc.rb', line 160
def name
@name
end
|
#path ⇒ Object
Returns the value of attribute path.
160
161
162
|
# File 'lib/rtfdoc.rb', line 160
def path
@path
end
|
Instance Method Details
#anchor_id ⇒ Object
182
183
184
|
# File 'lib/rtfdoc.rb', line 182
def anchor_id
@resource ? "#{@resource}-#{id}" : id
end
|
#example_to_html ⇒ Object
198
199
200
201
|
# File 'lib/rtfdoc.rb', line 198
def example_to_html
res = super
@resource && res && !meta_section? ? res.sub('RESPONSE', sig) : res
end
|
#id ⇒ Object
178
179
180
|
# File 'lib/rtfdoc.rb', line 178
def id
@id ||= name
end
|
190
191
192
|
# File 'lib/rtfdoc.rb', line 190
def
"<li>#{anchor(menu_title)}</li>"
end
|
#resource_name ⇒ Object
186
187
188
|
# File 'lib/rtfdoc.rb', line 186
def resource_name
@resource
end
|
#signature ⇒ Object
194
195
196
|
# File 'lib/rtfdoc.rb', line 194
def signature
anchor(sig)
end
|