Class: Muwu::RenderHtmlPartialBuilder::TopicBuilder
- Inherits:
-
Object
- Object
- Muwu::RenderHtmlPartialBuilder::TopicBuilder
show all
- Includes:
- Muwu
- Defined in:
- lib/muwu/render_html_partial_builder/render_topic_builder.rb
Constant Summary
Constants included
from Muwu
GEM_HOME_LIB, GEM_HOME_LIB_MUWU, VERSION
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Muwu
debug, read
Constructor Details
Returns a new instance of TopicBuilder.
18
19
20
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 18
def initialize
@renderer = RenderHtmlPartial::Topic.new
end
|
Instance Attribute Details
#renderer ⇒ Object
Returns the value of attribute renderer.
8
9
10
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 8
def renderer
@renderer
end
|
Class Method Details
.build {|builder| ... } ⇒ Object
11
12
13
14
15
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 11
def self.build
builder = new
yield(builder)
builder.renderer
end
|
Instance Method Details
#build_from_manifest_topic(manifest_topic) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 23
def build_from_manifest_topic(manifest_topic)
@manifest_topic = manifest_topic
@project = manifest_topic.project
phase_1_set_id
phase_1_set_commonmarker_options
phase_1_set_destination
phase_1_set_generate_inner_identifiers
phase_1_set_heading
phase_1_set_heading_origin
phase_1_set_numbering
phase_1_set_depth
phase_1_set_numbering_as_text
phase_1_set_does_have_source_text
phase_1_set_is_parent_heading
phase_1_set_text_root_name
phase_2_set_source_filename_absolute
phase_2_set_source_filename_relative
phase_3_set_subtopics
phase_3_set_source_relative_segments
phase_4_set_end_links
phase_4_set_will_render_section_number
phase_4_set_subtopics_are_distinct
phase_5_set_html_id
end
|
#phase_1_set_commonmarker_options ⇒ Object
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 49
def phase_1_set_commonmarker_options
@renderer.commonmarker_options = { extension: {}, render: {} }
@renderer.commonmarker_options[:extension].merge!({ description_lists: true })
if @project.options.render_punctuation_smart
@renderer.commonmarker_options[:render].merge!({ smart: true })
end
if @project.options.markdown_allows_raw_html
@renderer.commonmarker_options[:render].merge!({ unsafe: true })
end
end
|
#phase_1_set_depth ⇒ Object
105
106
107
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 105
def phase_1_set_depth
@renderer.depth = @manifest_topic.topic_depth
end
|
#phase_1_set_destination ⇒ Object
61
62
63
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 61
def phase_1_set_destination
@renderer.destination = @manifest_topic.destination
end
|
#phase_1_set_does_have_source_text ⇒ Object
66
67
68
69
70
71
72
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 66
def phase_1_set_does_have_source_text
if @manifest_topic.source_file_does_exist
@renderer.does_have_source_text = true
elsif @manifest_topic.source_file_does_not_exist
@renderer.does_have_source_text = false
end
end
|
#phase_1_set_generate_inner_identifiers ⇒ Object
75
76
77
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 75
def phase_1_set_generate_inner_identifiers
@renderer.generate_inner_identifiers = @project.options.generate_topic_inner_identifiers
end
|
#phase_1_set_heading ⇒ Object
80
81
82
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 80
def phase_1_set_heading
@renderer.heading = @manifest_topic.heading
end
|
#phase_1_set_heading_origin ⇒ Object
85
86
87
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 85
def phase_1_set_heading_origin
@renderer.heading_origin = @manifest_topic.heading_origin
end
|
#phase_1_set_id ⇒ Object
90
91
92
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 90
def phase_1_set_id
@renderer.id = @manifest_topic.id
end
|
#phase_1_set_is_parent_heading ⇒ Object
95
96
97
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 95
def phase_1_set_is_parent_heading
@renderer.is_parent_heading = @manifest_topic.is_parent_heading
end
|
#phase_1_set_numbering ⇒ Object
100
101
102
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 100
def phase_1_set_numbering
@renderer.numbering = @manifest_topic.numbering
end
|
#phase_1_set_numbering_as_text ⇒ Object
110
111
112
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 110
def phase_1_set_numbering_as_text
@renderer.numbering_as_text = @manifest_topic.numbering.join('.')
end
|
#phase_1_set_text_root_name ⇒ Object
115
116
117
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 115
def phase_1_set_text_root_name
@renderer.text_root_name = @manifest_topic.text_root_name
end
|
#phase_2_set_source_filename_absolute ⇒ Object
120
121
122
123
124
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 120
def phase_2_set_source_filename_absolute
if @manifest_topic.source_file_does_exist
@renderer.source_filename_absolute = @manifest_topic.source_filename_absolute
end
end
|
#phase_2_set_source_filename_relative ⇒ Object
127
128
129
130
131
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 127
def phase_2_set_source_filename_relative
if @manifest_topic.source_file_does_exist
@renderer.source_filename_relative = @manifest_topic.source_filename_relative
end
end
|
#phase_3_set_source_relative_segments ⇒ Object
141
142
143
144
145
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 141
def phase_3_set_source_relative_segments
segments = @manifest_topic.source_filename_relative.split('/')
segments.last.gsub!(/\.[\w\.]*\z/,'')
@renderer.source_relative_segments = segments
end
|
#phase_3_set_subtopics ⇒ Object
134
135
136
137
138
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 134
def phase_3_set_subtopics
if @manifest_topic.does_have_subtopics
@renderer.subtopics = determine_subtopics
end
end
|
#phase_4_set_end_links ⇒ Object
148
149
150
151
152
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 148
def phase_4_set_end_links
if topic_should_have_end_links
@renderer.end_links = determine_end_links
end
end
|
#phase_4_set_subtopics_are_distinct ⇒ Object
160
161
162
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 160
def phase_4_set_subtopics_are_distinct
@renderer.subtopics_are_distinct = determine_whether_subtopics_are_distinct
end
|
#phase_4_set_will_render_section_number ⇒ Object
155
156
157
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 155
def phase_4_set_will_render_section_number
@renderer.will_render_section_number = determine_whether_topic_will_render_section_number
end
|
#phase_5_set_html_id ⇒ Object
165
166
167
|
# File 'lib/muwu/render_html_partial_builder/render_topic_builder.rb', line 165
def phase_5_set_html_id
@renderer.html_id = Helper::HrefHelper.(@manifest_topic)
end
|