Almirah 0.2.4 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/bin/almirah +4 -4
  3. data/lib/almirah/doc_fabric.rb +65 -65
  4. data/lib/almirah/doc_items/blockquote.rb +21 -21
  5. data/lib/almirah/doc_items/code_block.rb +26 -26
  6. data/lib/almirah/doc_items/controlled_paragraph.rb +112 -112
  7. data/lib/almirah/doc_items/controlled_table.rb +224 -224
  8. data/lib/almirah/doc_items/controlled_table_row.rb +22 -22
  9. data/lib/almirah/doc_items/doc_footer.rb +16 -16
  10. data/lib/almirah/doc_items/doc_item.rb +22 -20
  11. data/lib/almirah/doc_items/frontmatter.rb +9 -0
  12. data/lib/almirah/doc_items/heading.rb +93 -93
  13. data/lib/almirah/doc_items/image.rb +27 -27
  14. data/lib/almirah/doc_items/markdown_list.rb +156 -158
  15. data/lib/almirah/doc_items/markdown_table.rb +61 -63
  16. data/lib/almirah/doc_items/paragraph.rb +25 -27
  17. data/lib/almirah/doc_items/text_line.rb +296 -296
  18. data/lib/almirah/doc_items/todo_block.rb +21 -21
  19. data/lib/almirah/doc_parser.rb +378 -330
  20. data/lib/almirah/doc_types/base_document.rb +64 -70
  21. data/lib/almirah/doc_types/coverage.rb +95 -81
  22. data/lib/almirah/doc_types/index.rb +173 -169
  23. data/lib/almirah/doc_types/persistent_document.rb +17 -20
  24. data/lib/almirah/doc_types/protocol.rb +24 -24
  25. data/lib/almirah/doc_types/specification.rb +67 -67
  26. data/lib/almirah/doc_types/traceability.rb +142 -142
  27. data/lib/almirah/dom/doc_section.rb +25 -25
  28. data/lib/almirah/dom/document.rb +78 -72
  29. data/lib/almirah/navigation_pane.rb +16 -16
  30. data/lib/almirah/project.rb +287 -306
  31. data/lib/almirah/project_configuration.rb +41 -41
  32. data/lib/almirah/project_template.rb +298 -0
  33. data/lib/almirah/project_utility.rb +52 -0
  34. data/lib/almirah/search/specifications_db.rb +79 -83
  35. data/lib/almirah/templates/css/main.css +300 -300
  36. data/lib/almirah/templates/css/search.css +40 -40
  37. data/lib/almirah/templates/page.html +42 -42
  38. data/lib/almirah/templates/scripts/main.js +111 -111
  39. data/lib/almirah/templates/scripts/orama_search.js +138 -138
  40. data/lib/almirah.rb +93 -49
  41. metadata +28 -5
@@ -1,224 +1,224 @@
1
- require_relative 'controlled_table_row'
2
- require_relative 'text_line'
3
-
4
- class ControlledTableColumn < TextLine # rubocop:disable Style/Documentation
5
- attr_accessor :text
6
-
7
- def initialize(text) # rubocop:disable Lint/MissingSuper
8
- @text = text.strip
9
- end
10
-
11
- def to_html
12
- f_text = format_string(@text)
13
- "\t\t<td>#{f_text}</td>\n\r"
14
- end
15
- end
16
-
17
- class RegualrColumn < ControlledTableColumn
18
- end
19
-
20
- class TestStepNumberColumn < ControlledTableColumn # rubocop:disable Style/Documentation
21
- attr_accessor :step_number, :row_id
22
-
23
- def initialize(text)
24
- super
25
- @step_number = text.to_i
26
- @row_id = ''
27
- end
28
-
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
34
-
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"
45
- end
46
- end
47
- end
48
-
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
81
- end
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]
88
-
89
- up_link_id = tmp[1]
90
-
91
- @up_link_ids ||= []
92
-
93
- @up_link_ids.append(up_link_id)
94
-
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
97
- end
98
- end
99
- end
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
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"
131
- end
132
- end
133
- end
134
-
135
- class ControlledTable < DocItem # rubocop:disable Style/Documentation
136
- attr_accessor :column_names, :rows, :is_separator_detected
137
-
138
- def initialize(doc, markdown_table) # rubocop:disable Lint/MissingSuper
139
- @parent_doc = doc
140
- @parent_heading = doc.headings[-1]
141
-
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 = []
146
-
147
- markdown_table.rows.each do |r|
148
- @rows.append(format_columns(r))
149
- end
150
- end
151
-
152
- def add_row(row)
153
- columns = row.split('|')
154
-
155
- @rows.append(format_columns(columns))
156
-
157
- true
158
- end
159
-
160
- def format_columns(columns) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
161
- new_row = ControlledTableRow.new
162
- new_row.parent_doc = @parent_doc
163
-
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
166
-
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
171
-
172
- elsif index + 1 == columns.length # it is expected that a link is placed to the last column only
173
-
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
180
-
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
185
- end
186
-
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>"
209
-
210
- @column_names.each do |h|
211
- s += " <th>#{h}</th>"
212
- end
213
-
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
1
+ require_relative 'controlled_table_row'
2
+ require_relative 'text_line'
3
+
4
+ class ControlledTableColumn < TextLine # rubocop:disable Style/Documentation
5
+ attr_accessor :text
6
+
7
+ def initialize(text) # rubocop:disable Lint/MissingSuper
8
+ @text = text.strip
9
+ end
10
+
11
+ def to_html
12
+ f_text = format_string(@text)
13
+ "\t\t<td>#{f_text}</td>\n\r"
14
+ end
15
+ end
16
+
17
+ class RegualrColumn < ControlledTableColumn
18
+ end
19
+
20
+ class TestStepNumberColumn < ControlledTableColumn # rubocop:disable Style/Documentation
21
+ attr_accessor :step_number, :row_id
22
+
23
+ def initialize(text)
24
+ super
25
+ @step_number = text.to_i
26
+ @row_id = ''
27
+ end
28
+
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
34
+
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"
45
+ end
46
+ end
47
+ end
48
+
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
81
+ end
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]
88
+
89
+ up_link_id = tmp[1]
90
+
91
+ @up_link_ids ||= []
92
+
93
+ @up_link_ids.append(up_link_id)
94
+
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
97
+ end
98
+ end
99
+ end
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
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"
131
+ end
132
+ end
133
+ end
134
+
135
+ class ControlledTable < DocItem # rubocop:disable Style/Documentation
136
+ attr_accessor :column_names, :rows, :is_separator_detected
137
+
138
+ def initialize(doc, markdown_table) # rubocop:disable Lint/MissingSuper
139
+ @parent_doc = doc
140
+ @parent_heading = doc.headings[-1]
141
+
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 = []
146
+
147
+ markdown_table.rows.each do |r|
148
+ @rows.append(format_columns(r))
149
+ end
150
+ end
151
+
152
+ def add_row(row)
153
+ columns = row.split('|')
154
+
155
+ @rows.append(format_columns(columns))
156
+
157
+ true
158
+ end
159
+
160
+ def format_columns(columns) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
161
+ new_row = ControlledTableRow.new
162
+ new_row.parent_doc = @parent_doc
163
+
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
166
+
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
171
+
172
+ elsif index + 1 == columns.length # it is expected that a link is placed to the last column only
173
+
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
180
+
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
185
+ end
186
+
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>"
209
+
210
+ @column_names.each do |h|
211
+ s += " <th>#{h}</th>"
212
+ end
213
+
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
@@ -1,23 +1,23 @@
1
- require_relative "doc_item"
2
-
3
- class ControlledTableRow < DocItem
4
-
5
- attr_accessor :id
6
- attr_accessor :up_link_ids
7
- attr_accessor :columns
8
-
9
- def initialize
10
- @id = ""
11
- @up_link_ids = nil
12
- @columns = []
13
- end
14
-
15
- def to_html
16
- s = ""
17
- s += "\t<tr>\n"
18
- @columns.each do |col|
19
- s += col.to_html # "\t\t<td>#{col}</td>\n\r"
20
- end
21
- s += "\t</tr>\n"
22
- end
1
+ require_relative "doc_item"
2
+
3
+ class ControlledTableRow < DocItem
4
+
5
+ attr_accessor :id
6
+ attr_accessor :up_link_ids
7
+ attr_accessor :columns
8
+
9
+ def initialize
10
+ @id = ""
11
+ @up_link_ids = nil
12
+ @columns = []
13
+ end
14
+
15
+ def to_html
16
+ s = ""
17
+ s += "\t<tr>\n"
18
+ @columns.each do |col|
19
+ s += col.to_html # "\t\t<td>#{col}</td>\n\r"
20
+ end
21
+ s += "\t</tr>\n"
22
+ end
23
23
  end
@@ -1,17 +1,17 @@
1
- require_relative "doc_item"
2
-
3
- class DocFooter < DocItem
4
-
5
- def initialize
6
- end
7
-
8
- def to_html
9
- s = ''
10
- if @@html_table_render_in_progress
11
- s += "</table>\n"
12
- @@html_table_render_in_progress = false
13
- end
14
- return s
15
- end
16
-
1
+ require_relative "doc_item"
2
+
3
+ class DocFooter < DocItem
4
+
5
+ def initialize
6
+ end
7
+
8
+ def to_html
9
+ s = ''
10
+ if @@html_table_render_in_progress
11
+ s += "</table>\n"
12
+ @@html_table_render_in_progress = false
13
+ end
14
+ return s
15
+ end
16
+
17
17
  end
@@ -1,20 +1,22 @@
1
- require_relative "text_line"
2
-
3
- class DocItem < TextLine
4
- attr_accessor :parent_doc
5
- attr_accessor :parent_heading
6
-
7
- @parent_doc = nil
8
- @parent_heading = nil
9
-
10
- @@html_table_render_in_progress = false
11
-
12
- def get_url
13
- ''
14
- end
15
- end
16
-
17
-
18
-
19
-
20
-
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'text_line'
4
+
5
+ class DocItem < TextLine # rubocop:disable Style/Documentation
6
+ attr_accessor :parent_doc, :parent_heading
7
+
8
+ @parent_doc = nil
9
+ @parent_heading = nil
10
+
11
+ @@html_table_render_in_progress = false # rubocop:disable Style/ClassVars
12
+
13
+ def initialize(doc)
14
+ super()
15
+ @parent_doc = doc
16
+ @parent_heading = doc.headings[-1]
17
+ end
18
+
19
+ def get_url
20
+ ''
21
+ end
22
+ end
@@ -0,0 +1,9 @@
1
+ require 'yaml'
2
+
3
+ class Frontmatter
4
+ attr_accessor :parameters
5
+
6
+ def initialize(yaml_text_line)
7
+ @parameters = YAML.safe_load(yaml_text_line)
8
+ end
9
+ end