Almirah 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/almirah/doc_fabric.rb +21 -2
- data/lib/almirah/doc_items/blockquote.rb +2 -2
- data/lib/almirah/doc_items/code_block.rb +2 -2
- data/lib/almirah/doc_items/controlled_paragraph.rb +100 -79
- data/lib/almirah/doc_items/controlled_table.rb +181 -134
- data/lib/almirah/doc_items/controlled_table_row.rb +3 -3
- data/lib/almirah/doc_items/doc_footer.rb +2 -2
- data/lib/almirah/doc_items/doc_item.rb +1 -1
- data/lib/almirah/doc_items/heading.rb +80 -85
- data/lib/almirah/doc_items/image.rb +2 -2
- data/lib/almirah/doc_items/markdown_list.rb +134 -143
- data/lib/almirah/doc_items/markdown_table.rb +52 -48
- data/lib/almirah/doc_items/paragraph.rb +6 -4
- data/lib/almirah/doc_items/text_line.rb +247 -264
- data/lib/almirah/doc_items/todo_block.rb +2 -2
- data/lib/almirah/doc_parser.rb +56 -60
- data/lib/almirah/doc_types/base_document.rb +1 -0
- data/lib/almirah/doc_types/coverage.rb +4 -1
- data/lib/almirah/doc_types/index.rb +26 -18
- data/lib/almirah/doc_types/specification.rb +56 -93
- data/lib/almirah/doc_types/traceability.rb +6 -2
- data/lib/almirah/dom/doc_section.rb +21 -24
- data/lib/almirah/dom/document.rb +66 -57
- data/lib/almirah/project.rb +257 -275
- data/lib/almirah/search/specifications_db.rb +18 -1
- data/lib/almirah/templates/css/main.css +5 -2
- data/lib/almirah/templates/page.html +4 -2
- data/lib/almirah/templates/scripts/main.js +54 -3
- metadata +2 -2
data/lib/almirah/dom/document.rb
CHANGED
@@ -1,63 +1,72 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative 'doc_section'
|
2
2
|
|
3
3
|
class Document
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
s = DocSection.new(h)
|
29
|
-
@@sections_stack[-2].sections.append(s)
|
30
|
-
@@sections_stack[-1] = s
|
31
|
-
|
32
|
-
elsif h.level > @@sections_stack[-1].heading.level
|
33
|
-
|
34
|
-
s = DocSection.new(h)
|
35
|
-
@@sections_stack[-1].sections.append(s)
|
36
|
-
@@sections_stack.push s
|
37
|
-
|
38
|
-
else
|
39
|
-
while h.level < @@sections_stack[-1].heading.level
|
40
|
-
@@sections_stack.pop
|
41
|
-
end
|
42
|
-
|
43
|
-
s = DocSection.new(h)
|
44
|
-
@@sections_stack[-2].sections.append(s)
|
45
|
-
@@sections_stack[-1] = s
|
46
|
-
end
|
4
|
+
attr_accessor :root_section
|
5
|
+
|
6
|
+
def initialize(headings_list)
|
7
|
+
@root_section = nil
|
8
|
+
|
9
|
+
build_sections_tree(headings_list)
|
10
|
+
end
|
11
|
+
|
12
|
+
def build_sections_tree(headings_list)
|
13
|
+
sections_stack = []
|
14
|
+
headings_list.each do |h|
|
15
|
+
if @root_section.nil?
|
16
|
+
|
17
|
+
s = DocSection.new(h)
|
18
|
+
s.parent_section = nil
|
19
|
+
@root_section = s
|
20
|
+
sections_stack.push s
|
21
|
+
# one more artificial section copy if root is not a Document Title (level 0)
|
22
|
+
if h.level.positive?
|
23
|
+
a = DocSection.new(h)
|
24
|
+
a.parent_section = @root_section
|
25
|
+
@root_section.sections.append(a)
|
26
|
+
sections_stack.push a
|
47
27
|
end
|
48
|
-
end
|
49
28
|
|
50
|
-
|
51
|
-
|
52
|
-
s
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
29
|
+
elsif sections_stack[-1].heading.level == h.level
|
30
|
+
|
31
|
+
s = DocSection.new(h)
|
32
|
+
s.parent_section = sections_stack[-1].parent_section
|
33
|
+
sections_stack[-1].parent_section.sections.append(s)
|
34
|
+
sections_stack[-1] = s
|
35
|
+
|
36
|
+
elsif h.level > sections_stack[-1].heading.level
|
37
|
+
|
38
|
+
s = DocSection.new(h)
|
39
|
+
s.parent_section = sections_stack[-1]
|
40
|
+
sections_stack[-1].sections.append(s)
|
41
|
+
sections_stack.push s
|
42
|
+
|
43
|
+
else
|
44
|
+
sections_stack.pop while h.level < sections_stack[-1].heading.level
|
45
|
+
sections_stack.push @root_section if sections_stack.empty?
|
46
|
+
s = DocSection.new(h)
|
47
|
+
if h.level == sections_stack[-1].heading.level
|
48
|
+
s.parent_section = sections_stack[-1].parent_section
|
49
|
+
sections_stack[-1].parent_section.sections.append(s)
|
50
|
+
else
|
51
|
+
s.parent_section = sections_stack[-1]
|
52
|
+
sections_stack[-1].sections.append(s)
|
59
53
|
end
|
60
|
-
|
61
|
-
|
54
|
+
sections_stack[-1] = s
|
55
|
+
end
|
62
56
|
end
|
63
|
-
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def section_tree_to_html
|
60
|
+
s = ''
|
61
|
+
s += "<a href=\"##{@root_section.heading.anchor_id}\">#{@root_section.heading.get_section_info}</a>\n"
|
62
|
+
unless @root_section.sections.empty?
|
63
|
+
s += "\t<ul class=\"fa-ul\" style=\"margin-top: 2px;\">\n"
|
64
|
+
@root_section.sections.each do |sub_section|
|
65
|
+
s += sub_section.to_html
|
66
|
+
end
|
67
|
+
s += "\t</ul>\n"
|
68
|
+
end
|
69
|
+
|
70
|
+
s
|
71
|
+
end
|
72
|
+
end
|