Module: Sixfish::Patches

Defined in:
lib/sixfish/patches.rb

Constant Summary collapse

LIST_TYPE_TO_HTML =
{
	:BULLET => ['<ul>',                                      '</ul>'],
	:LABEL  => ['<dl class="rdoc-list label-list">',         '</dl>'],
	:LALPHA => ['<ol style="list-style-type: lower-alpha">', '</ol>'],
	:NOTE   => [
		'<table class="rdoc-list note-list table"><tbody>',
		'</tbody></table>'
	],
	:NUMBER => ['<ol>',                                      '</ol>'],
	:UALPHA => ['<ol style="list-style-type: upper-alpha">', '</ol>'],
}

Instance Method Summary collapse

Instance Method Details

#accept_heading(heading) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/sixfish/patches.rb', line 56

def accept_heading( heading )
	level = [6, heading.level].min
	label = heading.label @code_object

	@res << if @options.output_decoration
		"\n<h#{level} id=\"#{label}\">"
	else
		"\n<h#{level}>"
	end

	@res << to_html(heading.text)
	@res << "</h#{level}>\n"
end

#html_list_name(list_type, open_tag) ⇒ Object

Raises:

  • (RDoc::Error)


23
24
25
26
27
# File 'lib/sixfish/patches.rb', line 23

def html_list_name(list_type, open_tag)
	tags = Sixfish::Patches::LIST_TYPE_TO_HTML[list_type]
	raise RDoc::Error, "Invalid list type: #{list_type.inspect}" unless tags
	tags[open_tag ? 0 : 1]
end

#list_end_for(list_type) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/sixfish/patches.rb', line 44

def list_end_for(list_type)
	case list_type
	when :BULLET, :LALPHA, :NUMBER, :UALPHA then
		"</li>"
	when :LABEL, :NOTE then
		"</td></tr>"
	else
		raise RDoc::Error, "Invalid list type: #{list_type.inspect}"
	end
end

#list_item_start(list_item, list_type) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/sixfish/patches.rb', line 30

def list_item_start(list_item, list_type)
	case list_type
	when :BULLET, :LALPHA, :NUMBER, :UALPHA then
		"<li>"
	when :LABEL, :NOTE then
		Array(list_item.label).map do |label|
			"<tr><td>#{to_html label}\n"
		end.join << "</td><td>"
	else
		raise RDoc::Error, "Invalid list type: #{list_type.inspect}"
	end
end