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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fa95a589e6285719010318ec666da5cf309ef511cd69cb2ffc6629464d64ae0
|
4
|
+
data.tar.gz: f2c8fd5747f9c5e53417744eac9caa15e2c313987d94c36b8d446434089f14fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0071aa202dac9bd73495fb389db3008f83ff5dff9bd61d8d4f957abb935a1727362e51a3e2c6418a7a388ea28d6baef344500ec9ec46256b803982dbd5275cd
|
7
|
+
data.tar.gz: bcfbdf1cbca81f17d3e305723c111a38327ca16f3a8e8c28795e3135041e8a97d64e0baddd1780ae826bec85ddb0cbcf5533908506debde61d1d27e31caf02bf
|
data/lib/almirah/doc_fabric.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require_relative 'doc_types/base_document'
|
2
2
|
require_relative 'doc_types/specification'
|
3
3
|
require_relative 'doc_types/protocol'
|
4
|
+
require_relative 'doc_types/coverage'
|
4
5
|
require_relative 'doc_parser'
|
5
6
|
require_relative 'dom/document'
|
7
|
+
require_relative 'doc_items/heading'
|
6
8
|
|
7
9
|
class DocFabric
|
8
10
|
@@color_index = 0
|
@@ -31,6 +33,24 @@ class DocFabric
|
|
31
33
|
doc
|
32
34
|
end
|
33
35
|
|
36
|
+
def self.create_coverage_matrix(specification)
|
37
|
+
doc = Coverage.new specification
|
38
|
+
Heading.reset_global_section_number
|
39
|
+
doc.headings << Heading.new(doc, doc.title, 0)
|
40
|
+
# Build dom
|
41
|
+
doc.dom = Document.new(doc.headings)
|
42
|
+
doc
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.create_traceability_document(top_document, bottom_document)
|
46
|
+
doc = Traceability.new top_document, bottom_document
|
47
|
+
Heading.reset_global_section_number
|
48
|
+
doc.headings << Heading.new(doc, doc.title, 0)
|
49
|
+
# Build dom
|
50
|
+
doc.dom = Document.new(doc.headings)
|
51
|
+
doc
|
52
|
+
end
|
53
|
+
|
34
54
|
def self.parse_document(doc)
|
35
55
|
|
36
56
|
file = File.open(doc.path)
|
@@ -40,7 +60,6 @@ class DocFabric
|
|
40
60
|
DocParser.parse(doc, file_lines)
|
41
61
|
|
42
62
|
# Build dom
|
43
|
-
doc.dom = Document.new(doc.headings) if doc.is_a?(Specification)
|
44
|
-
|
63
|
+
doc.dom = Document.new(doc.headings) if doc.is_a?(Specification) || doc.is_a?(Protocol)
|
45
64
|
end
|
46
65
|
end
|
@@ -11,9 +11,9 @@ class Blockquote < DocItem
|
|
11
11
|
def to_html
|
12
12
|
s = ''
|
13
13
|
f_text = format_string(@text)
|
14
|
-
if @@
|
14
|
+
if @@html_table_render_in_progress
|
15
15
|
s += "</table>\n"
|
16
|
-
@@
|
16
|
+
@@html_table_render_in_progress = false
|
17
17
|
end
|
18
18
|
|
19
19
|
s += "<div class=\"blockquote\"><p>#{f_text}</div>\n"
|
@@ -13,9 +13,9 @@ class CodeBlock < DocItem
|
|
13
13
|
def to_html
|
14
14
|
s = ''
|
15
15
|
|
16
|
-
if @@
|
16
|
+
if @@html_table_render_in_progress
|
17
17
|
s += "</table>\n"
|
18
|
-
@@
|
18
|
+
@@html_table_render_in_progress = false
|
19
19
|
end
|
20
20
|
s += "<code>"
|
21
21
|
@code_lines.each do |l|
|
@@ -1,91 +1,112 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative 'paragraph'
|
2
2
|
|
3
3
|
class ControlledParagraph < Paragraph
|
4
|
+
attr_accessor :id, :up_link_ids, :down_links, :coverage_links
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def initialize(doc, text, id)
|
7
|
+
super(doc, text)
|
8
|
+
@parent_heading = doc.headings[-1]
|
9
|
+
@id = id
|
10
|
+
@up_link_ids = nil
|
11
|
+
@down_links = nil
|
12
|
+
@coverage_links = nil
|
13
|
+
end
|
9
14
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
@coverage_links = nil
|
15
|
+
def to_html
|
16
|
+
s = ''
|
17
|
+
unless @@html_table_render_in_progress
|
18
|
+
s += "<table class=\"controlled\">\n"
|
19
|
+
s += "\t<thead> <th>#</th> <th></th> <th title=\"Up-links\">UL</th> <th title=\"Down-links\">DL</th> \
|
20
|
+
<th title=\"Test Coverage\">COV</th> </thead>\n"
|
21
|
+
@@html_table_render_in_progress = true # rubocop:disable Style/ClassVars
|
18
22
|
end
|
23
|
+
f_text = format_string(@text)
|
24
|
+
s += "\t<tr>\n"
|
25
|
+
s += "\t\t<td class=\"item_id\"> \
|
26
|
+
<a name=\"#{@id}\" id=\"#{@id}\" href=\"##{@id}\" title=\"Paragraph ID\">#{@id}</a></td>\n"
|
27
|
+
s += "\t\t<td class=\"item_text\">#{f_text}</td>\n"
|
19
28
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
s += "\t<thead> <th>#</th> <th></th> <th>UL</th> <th>DL</th> <th>COV</th> </thead>\n"
|
25
|
-
@@htmlTableRenderInProgress = true
|
29
|
+
if @up_link_ids
|
30
|
+
if @up_link_ids.length == 1
|
31
|
+
if tmp = /^([a-zA-Z]+)-\d+/.match(@up_link_ids[0])
|
32
|
+
up_link_doc_name = tmp[1].downcase
|
26
33
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
s += "<div id=\"DLS_#{@id}\" style=\"display: none;\">"
|
44
|
-
@up_link_ids.each do |lnk|
|
45
|
-
if tmp = /^([a-zA-Z]+)[-]\d+/.match(lnk)
|
46
|
-
up_link_doc_name = tmp[1].downcase
|
47
|
-
end
|
48
|
-
s += "\t\t\t<a href=\"./../#{up_link_doc_name}/#{up_link_doc_name}.html##{lnk}\" class=\"external\">#{lnk}</a>\n<br>"
|
49
|
-
end
|
50
|
-
s += "</div>"
|
51
|
-
s += "</td>\n"
|
52
|
-
end
|
53
|
-
else
|
54
|
-
s += "\t\t<td class=\"item_id\"></td>\n"
|
34
|
+
s += "\t\t<td class=\"item_id\">\
|
35
|
+
<a href=\"./../#{up_link_doc_name}/#{up_link_doc_name}.html##{@up_link_ids[0]}\" \
|
36
|
+
class=\"external\" title=\"Linked to\">#{@up_link_ids[0]}</a></td>\n"
|
37
|
+
else
|
38
|
+
s += "\t\t<td class=\"item_id\">"
|
39
|
+
s += "<div id=\"UL_#{@id}\" style=\"display: block;\">"
|
40
|
+
s += "<a href=\"#\" onclick=\"upLink_OnClick(this.parentElement); return false;\" \
|
41
|
+
class=\"external\" title=\"Number of up-links\">#{@up_link_ids.length}</a>"
|
42
|
+
s += '</div>'
|
43
|
+
s += "<div id=\"ULS_#{@id}\" style=\"display: none;\">"
|
44
|
+
@up_link_ids.each do |lnk|
|
45
|
+
if tmp = /^([a-zA-Z]+)-\d+/.match(lnk)
|
46
|
+
up_link_doc_name = tmp[1].downcase
|
47
|
+
end
|
48
|
+
s += "\t\t\t<a href=\"./../#{up_link_doc_name}/#{up_link_doc_name}.html##{lnk}\" \
|
49
|
+
class=\"external\" title=\"Linked to\">#{lnk}</a>\n<br>"
|
55
50
|
end
|
51
|
+
s += '</div>'
|
52
|
+
s += "</td>\n"
|
53
|
+
end
|
54
|
+
else
|
55
|
+
s += "\t\t<td class=\"item_id\"></td>\n"
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
else
|
76
|
-
s += "\t\t<td class=\"item_id\"></td>\n"
|
58
|
+
if @down_links
|
59
|
+
if tmp = /^([a-zA-Z]+)-\d+/.match(@down_links[0].id) # guessing that all the links refer to one document
|
60
|
+
down_link_doc_name = tmp[1].downcase
|
61
|
+
end
|
62
|
+
if @down_links.length == 1
|
63
|
+
s += "\t\t<td class=\"item_id\">\
|
64
|
+
<a href=\"./../#{down_link_doc_name}/#{down_link_doc_name}.html##{@down_links[0].id}\" \
|
65
|
+
class=\"external\" title=\"Referenced in\">#{@down_links[0].id}</a></td>\n"
|
66
|
+
else
|
67
|
+
s += "\t\t<td class=\"item_id\">"
|
68
|
+
s += "<div id=\"DL_#{@id}\" style=\"display: block;\">"
|
69
|
+
s += "<a href=\"#\" onclick=\"downlink_OnClick(this.parentElement); return false;\" \
|
70
|
+
class=\"external\" title=\"Number of references\">#{@down_links.length}</a>"
|
71
|
+
s += '</div>'
|
72
|
+
s += "<div id=\"DLS_#{@id}\" style=\"display: none;\">"
|
73
|
+
@down_links.each do |lnk|
|
74
|
+
s += "\t\t\t<a href=\"./../#{lnk.parent_doc.id}/#{lnk.parent_doc.id}.html##{lnk.id}\" \
|
75
|
+
class=\"external\" title=\"Referenced in\">#{lnk.id}</a>\n<br>"
|
77
76
|
end
|
77
|
+
s += '</div>'
|
78
|
+
s += "</td>\n"
|
79
|
+
end
|
80
|
+
else
|
81
|
+
s += "\t\t<td class=\"item_id\"></td>\n"
|
82
|
+
end
|
78
83
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
84
|
+
if @coverage_links
|
85
|
+
if tmp = /^(.+)[.]\d+/.match(@coverage_links[0].id) # guessing that all the links refer to one document
|
86
|
+
cov_link_doc_name = tmp[1].downcase
|
87
|
+
end
|
88
|
+
if @coverage_links.length == 1
|
89
|
+
s += "\t\t<td class=\"item_id\">\
|
90
|
+
<a href=\"./../../tests/protocols/#{cov_link_doc_name}/#{cov_link_doc_name}.html\" \
|
91
|
+
class=\"external\" title=\"Number of verification steps\">#{@coverage_links[0].id}</a></td>\n"
|
92
|
+
else
|
93
|
+
s += "\t\t<td class=\"item_id\">"
|
94
|
+
s += "<div id=\"COV_#{@id}\" style=\"display: block;\">"
|
95
|
+
s += "<a href=\"#\" onclick=\"coverageLink_OnClick(this.parentElement); return false;\" \
|
96
|
+
class=\"external\" title=\"Number of verification steps\">#{@coverage_links.length}</a>"
|
97
|
+
s += '</div>'
|
98
|
+
s += "<div id=\"COVS_#{@id}\" style=\"display: none;\">"
|
99
|
+
@coverage_links.each do |lnk|
|
100
|
+
s += "\t\t\t<a href=\"./../../tests/protocols/#{lnk.parent_doc.id}/#{lnk.parent_doc.id}.html##{lnk.id}\" \
|
101
|
+
class=\"external\" title=\"Covered in\">#{lnk.id}</a>\n<br>"
|
86
102
|
end
|
87
|
-
s +=
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
103
|
+
s += '</div>'
|
104
|
+
s += "</td>\n"
|
105
|
+
end
|
106
|
+
else
|
107
|
+
s += "\t\t<td class=\"item_id\"></td>\n"
|
108
|
+
end
|
109
|
+
s += "\t</tr>\n"
|
110
|
+
s
|
111
|
+
end
|
112
|
+
end
|
@@ -1,177 +1,224 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
1
|
+
require_relative 'controlled_table_row'
|
2
|
+
require_relative 'text_line'
|
3
3
|
|
4
|
-
class ControlledTableColumn < TextLine
|
4
|
+
class ControlledTableColumn < TextLine # rubocop:disable Style/Documentation
|
5
|
+
attr_accessor :text
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@text = text.strip
|
10
|
-
end
|
7
|
+
def initialize(text) # rubocop:disable Lint/MissingSuper
|
8
|
+
@text = text.strip
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
def to_html
|
12
|
+
f_text = format_string(@text)
|
13
|
+
"\t\t<td>#{f_text}</td>\n\r"
|
14
|
+
end
|
16
15
|
end
|
17
16
|
|
18
|
-
|
19
17
|
class RegualrColumn < ControlledTableColumn
|
20
|
-
|
21
18
|
end
|
22
19
|
|
20
|
+
class TestStepNumberColumn < ControlledTableColumn # rubocop:disable Style/Documentation
|
21
|
+
attr_accessor :step_number, :row_id
|
23
22
|
|
24
|
-
|
23
|
+
def initialize(text)
|
24
|
+
super
|
25
|
+
@step_number = text.to_i
|
26
|
+
@row_id = ''
|
27
|
+
end
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
@step_number = text.to_i
|
32
|
-
@text = text
|
33
|
-
@row_id = ""
|
34
|
-
end
|
29
|
+
def to_html
|
30
|
+
"\t\t<td style=\"text-align: center;\"><a name=\"#{@row_id}\" id=\"#{@row_id}\" \
|
31
|
+
href=\"##{@row_id}\">#{@text}</a></td>\n\r"
|
32
|
+
end
|
33
|
+
end
|
35
34
|
|
36
|
-
|
37
|
-
|
35
|
+
class TestStepResultColumn < ControlledTableColumn # rubocop:disable Style/Documentation
|
36
|
+
def to_html
|
37
|
+
f_text = format_string(@text)
|
38
|
+
case @text.downcase
|
39
|
+
when 'pass'
|
40
|
+
"\t\t<td style=\"background-color: #cfc;\">#{f_text}</td>\n\r"
|
41
|
+
when 'fail'
|
42
|
+
"\t\t<td style=\"background-color: #fcc;\">#{f_text}</td>\n\r"
|
43
|
+
else
|
44
|
+
"\t\t<td>#{f_text}</td>\n\r"
|
38
45
|
end
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
class TestStepResultColumn < ControlledTableColumn
|
46
|
+
end
|
47
|
+
end
|
43
48
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
class TestStepReferenceColumn < ControlledTableColumn # rubocop:disable Style/Documentation
|
50
|
+
attr_accessor :up_link_ids, :up_link_doc_ids, :parent_row
|
51
|
+
|
52
|
+
def initialize(parent_row, text)
|
53
|
+
super(text)
|
54
|
+
@up_link_ids = nil
|
55
|
+
@up_link_doc_ids = {}
|
56
|
+
@parent_row = parent_row
|
57
|
+
|
58
|
+
up_links = nil
|
59
|
+
|
60
|
+
# check if it contains the uplink (one or many)
|
61
|
+
first_pos = text.length # for trailing commas
|
62
|
+
tmp = text.scan(/(>\[(?>[^\[\]]|\g<0>)*\])/) # >[SRS-001], >[SYS-002]
|
63
|
+
unless tmp.empty?
|
64
|
+
up_links = []
|
65
|
+
tmp.each do |ul|
|
66
|
+
lnk = ul[0]
|
67
|
+
# do not add links for the self document
|
68
|
+
doc_id = /([a-zA-Z]+)-\d+/.match(lnk) # SRS
|
69
|
+
up_links << lnk.upcase if doc_id # (doc_id) and (doc_id[1].downcase != doc.id.downcase)
|
70
|
+
# try to find the real end of text
|
71
|
+
pos = text.index(lnk)
|
72
|
+
first_pos = pos if pos < first_pos
|
73
|
+
# remove uplink from text
|
74
|
+
text = text.split(lnk, 1).join('')
|
75
|
+
end
|
76
|
+
# remove trailing commas and spaces
|
77
|
+
if text.length > first_pos
|
78
|
+
first_pos -= 1
|
79
|
+
text = text[0..first_pos].strip
|
80
|
+
end
|
53
81
|
end
|
54
|
-
end
|
55
82
|
|
83
|
+
if up_links # rubocop:disable Style/GuardClause
|
84
|
+
up_links.uniq! # remove duplicates
|
85
|
+
# doc.items_with_uplinks_number += 1 # for statistics
|
86
|
+
up_links.each do |ul|
|
87
|
+
next unless tmp = />\[(\S*)\]$/.match(ul) # >[SRS-001]
|
56
88
|
|
57
|
-
|
89
|
+
up_link_id = tmp[1]
|
58
90
|
|
59
|
-
|
60
|
-
attr_accessor :up_link_doc_id
|
91
|
+
@up_link_ids ||= []
|
61
92
|
|
62
|
-
|
63
|
-
|
64
|
-
@up_link = nil
|
65
|
-
@up_link_doc_id = nil
|
93
|
+
@up_link_ids.append(up_link_id)
|
66
94
|
|
67
|
-
if tmp =
|
68
|
-
|
69
|
-
if tmp = /^([a-zA-Z]+)[-]\d+/.match(@up_link) # SRS
|
70
|
-
@up_link_doc_id = tmp[1].downcase
|
71
|
-
end
|
95
|
+
if tmp = /^([a-zA-Z]+)-\d+/.match(up_link_id) # SRS
|
96
|
+
@up_link_doc_ids[tmp[1].downcase.to_s] = tmp[1].downcase # multiple documents could be up-linked
|
72
97
|
end
|
98
|
+
end
|
73
99
|
end
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
100
|
+
end
|
101
|
+
|
102
|
+
def to_html # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
103
|
+
s = ''
|
104
|
+
if @up_link_ids
|
105
|
+
if @up_link_ids.length == 1
|
106
|
+
if tmp = /^([a-zA-Z]+)-\d+/.match(@up_link_ids[0])
|
107
|
+
up_link_doc_name = tmp[1].downcase
|
80
108
|
end
|
109
|
+
s += "\t\t<td class=\"item_id\" style=\"text-align: center;\">\
|
110
|
+
<a href=\"./../../../specifications/#{up_link_doc_name}/#{up_link_doc_name}.html##{@up_link_ids[0]}\" \
|
111
|
+
class=\"external\" title=\"Linked to\">#{@up_link_ids[0]}</a></td>\n"
|
112
|
+
else
|
113
|
+
s += "\t\t<td class=\"item_id\" style=\"text-align: center;\">"
|
114
|
+
s += "<div id=\"COV_#{@parent_row.id}\" style=\"display: block;\">"
|
115
|
+
s += "<a href=\"#\" onclick=\"coverageLink_OnClick(this.parentElement); return false;\" \
|
116
|
+
class=\"external\" title=\"Number of verified items\">#{@up_link_ids.length}</a>"
|
117
|
+
s += '</div>'
|
118
|
+
s += "<div id=\"COVS_#{@parent_row.id}\" style=\"display: none;\">"
|
119
|
+
@up_link_ids.each do |lnk|
|
120
|
+
if tmp = /^([a-zA-Z]+)-\d+/.match(lnk)
|
121
|
+
up_link_doc_name = tmp[1].downcase
|
122
|
+
end
|
123
|
+
s += "\t\t\t<a href=\"./../../../specifications/#{up_link_doc_name}/#{up_link_doc_name}.html##{lnk}\" \
|
124
|
+
class=\"external\" title=\"Verifies\">#{lnk}</a>\n<br>"
|
125
|
+
end
|
126
|
+
s += '</div>'
|
127
|
+
s += "</td>\n"
|
128
|
+
end
|
129
|
+
else
|
130
|
+
"\t\t<td style=\"text-align: center;\"></td>\n\r"
|
81
131
|
end
|
82
|
-
|
132
|
+
end
|
83
133
|
end
|
84
134
|
|
135
|
+
class ControlledTable < DocItem # rubocop:disable Style/Documentation
|
136
|
+
attr_accessor :column_names, :rows, :is_separator_detected
|
85
137
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
attr_accessor :rows
|
138
|
+
def initialize(doc, markdown_table) # rubocop:disable Lint/MissingSuper
|
139
|
+
@parent_doc = doc
|
140
|
+
@parent_heading = doc.headings[-1]
|
90
141
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
@rows = Array.new
|
142
|
+
@column_names = markdown_table.column_names
|
143
|
+
@is_separator_detected = markdown_table.is_separator_detected
|
144
|
+
# copy and re-format existing rows
|
145
|
+
@rows = []
|
96
146
|
|
97
|
-
|
98
|
-
|
99
|
-
end
|
147
|
+
markdown_table.rows.each do |r|
|
148
|
+
@rows.append(format_columns(r))
|
100
149
|
end
|
150
|
+
end
|
101
151
|
|
102
|
-
|
152
|
+
def add_row(row)
|
153
|
+
columns = row.split('|')
|
103
154
|
|
104
|
-
|
155
|
+
@rows.append(format_columns(columns))
|
105
156
|
|
106
|
-
|
157
|
+
true
|
158
|
+
end
|
107
159
|
|
108
|
-
|
109
|
-
|
160
|
+
def format_columns(columns) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
161
|
+
new_row = ControlledTableRow.new
|
162
|
+
new_row.parent_doc = @parent_doc
|
110
163
|
|
111
|
-
|
112
|
-
|
113
|
-
new_row = ControlledTableRow.new
|
114
|
-
new_row.parent_doc = @parent_doc
|
115
|
-
|
116
|
-
columns.each_with_index do | element, index |
|
117
|
-
|
118
|
-
if index == 0 # it is expected that test step id is placed in the first columl
|
119
|
-
|
120
|
-
col = TestStepNumberColumn.new element
|
121
|
-
new_row.columns.append col
|
122
|
-
new_row.id = @parent_doc.id + '.' + col.text
|
123
|
-
col.row_id = new_row.id
|
124
|
-
|
125
|
-
elsif index + 1 == columns.length # it is expected that a link is placed to the last column only
|
126
|
-
|
127
|
-
col = TestStepReferenceColumn.new element
|
128
|
-
new_row.columns.append col
|
129
|
-
# save uplink key but do not rewrite
|
130
|
-
if col.up_link_doc_id != nil
|
131
|
-
|
132
|
-
@parent_doc.up_link_docs[ col.up_link_doc_id.to_s ] = col.up_link_doc_id
|
133
|
-
|
134
|
-
# save reference to the test step
|
135
|
-
new_row.up_link = col.up_link
|
136
|
-
@parent_doc.controlled_items.append new_row
|
137
|
-
end
|
138
|
-
|
139
|
-
elsif index + 2 == columns.length # it is expected that test step result is placed to the pre-last column only
|
140
|
-
|
141
|
-
col = TestStepResultColumn.new element
|
142
|
-
new_row.columns.append col
|
143
|
-
|
144
|
-
else
|
145
|
-
col = RegualrColumn.new element
|
146
|
-
new_row.columns.append col
|
147
|
-
end
|
148
|
-
end
|
149
|
-
return new_row
|
150
|
-
end
|
164
|
+
columns.each_with_index do |element, index|
|
165
|
+
if index.zero? # it is expected that test step id is placed in the first columl
|
151
166
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
@@htmlTableRenderInProgress = false
|
157
|
-
end
|
158
|
-
|
159
|
-
s += "<table class=\"markdown_table\">\n"
|
160
|
-
s += "\t<thead>"
|
167
|
+
col = TestStepNumberColumn.new element
|
168
|
+
new_row.columns.append col
|
169
|
+
new_row.id = "#{@parent_doc.id}.#{col.text}"
|
170
|
+
col.row_id = new_row.id
|
161
171
|
|
162
|
-
|
163
|
-
s += " <th>#{h}</th>"
|
164
|
-
end
|
172
|
+
elsif index + 1 == columns.length # it is expected that a link is placed to the last column only
|
165
173
|
|
166
|
-
|
174
|
+
col = TestStepReferenceColumn.new(new_row, element)
|
175
|
+
new_row.columns << col
|
176
|
+
# save uplink key but do not rewrite
|
177
|
+
unless col.up_link_doc_ids.empty?
|
178
|
+
col.up_link_doc_ids.each do |key, value|
|
179
|
+
@parent_doc.up_link_docs[key] = value
|
167
180
|
|
168
|
-
|
169
|
-
|
181
|
+
# save reference to the test step
|
182
|
+
new_row.up_link_ids = col.up_link_ids
|
183
|
+
@parent_doc.controlled_items.append new_row
|
184
|
+
end
|
170
185
|
end
|
171
186
|
|
172
|
-
|
187
|
+
elsif index + 2 == columns.length # it is expected that test step result is placed to the pre-last column only
|
188
|
+
|
189
|
+
col = TestStepResultColumn.new element
|
190
|
+
new_row.columns.append col
|
191
|
+
|
192
|
+
else
|
193
|
+
col = RegualrColumn.new element
|
194
|
+
new_row.columns.append col
|
195
|
+
end
|
196
|
+
end
|
197
|
+
new_row
|
198
|
+
end
|
199
|
+
|
200
|
+
def to_html # rubocop:disable Metrics/MethodLength
|
201
|
+
s = ''
|
202
|
+
if @@html_table_render_in_progress
|
203
|
+
s += "</table>\n"
|
204
|
+
@@html_table_render_in_progress = false # rubocop:disable Style/ClassVars
|
205
|
+
end
|
206
|
+
|
207
|
+
s += "<table class=\"markdown_table\">\n"
|
208
|
+
s += "\t<thead>"
|
173
209
|
|
174
|
-
|
210
|
+
@column_names.each do |h|
|
211
|
+
s += " <th>#{h}</th>"
|
175
212
|
end
|
176
213
|
|
177
|
-
|
214
|
+
s += " </thead>\n"
|
215
|
+
|
216
|
+
@rows.each do |row|
|
217
|
+
s += row.to_html
|
218
|
+
end
|
219
|
+
|
220
|
+
s += "</table>\n"
|
221
|
+
|
222
|
+
s
|
223
|
+
end
|
224
|
+
end
|
@@ -3,13 +3,13 @@ require_relative "doc_item"
|
|
3
3
|
class ControlledTableRow < DocItem
|
4
4
|
|
5
5
|
attr_accessor :id
|
6
|
-
attr_accessor :
|
6
|
+
attr_accessor :up_link_ids
|
7
7
|
attr_accessor :columns
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
@id = ""
|
11
|
-
@
|
12
|
-
@columns =
|
11
|
+
@up_link_ids = nil
|
12
|
+
@columns = []
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_html
|