Almirah 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/almirah/doc_fabric.rb +45 -5
- data/lib/almirah/doc_items/code_block.rb +27 -0
- data/lib/almirah/doc_items/doc_footer.rb +17 -0
- data/lib/almirah/doc_items/markdown_list.rb +21 -6
- data/lib/almirah/doc_items/text_line.rb +1 -1
- data/lib/almirah/doc_types/index.rb +17 -0
- data/lib/almirah/doc_types/specification.rb +2 -0
- data/lib/almirah/project.rb +40 -0
- data/lib/almirah/templates/page.html +14 -5
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7a10581e498b38097f10868900c903c9e3bad04bfb3e1d63170bada3222c65b
|
4
|
+
data.tar.gz: 70ac0c4e2893e69ae0aa6c146c4c7a1da2b4ddd7ae0249604bc0b9afcb4980dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d2f2cfe15dd20b56c31cab7748304007497cbb4a03928df501b2628a261861003a8a0d576ff084ebd54128b03a5c521e6e1da94e8125f93e1233bee94a06ddc
|
7
|
+
data.tar.gz: ff4cbc8d03219cb9792a854dfabbe0b968a097b73e57fca89f0a027bcca11916c646dbca4e64539ea3ac3f6a0b6213d18b71e4e9e323e57a05d83240289bf057
|
data/lib/almirah/doc_fabric.rb
CHANGED
@@ -8,12 +8,14 @@ require_relative "doc_items/doc_item"
|
|
8
8
|
require_relative "doc_items/heading"
|
9
9
|
require_relative "doc_items/paragraph"
|
10
10
|
require_relative "doc_items/blockquote"
|
11
|
+
require_relative "doc_items/code_block"
|
11
12
|
require_relative "doc_items/todo_block"
|
12
13
|
require_relative "doc_items/controlled_paragraph"
|
13
14
|
require_relative "doc_items/markdown_table"
|
14
15
|
require_relative "doc_items/controlled_table"
|
15
16
|
require_relative "doc_items/image"
|
16
17
|
require_relative "doc_items/markdown_list"
|
18
|
+
require_relative "doc_items/doc_footer"
|
17
19
|
|
18
20
|
class DocFabric
|
19
21
|
|
@@ -39,6 +41,7 @@ class DocFabric
|
|
39
41
|
|
40
42
|
tempMdTable = nil
|
41
43
|
tempMdList = nil
|
44
|
+
tempCodeBlock = nil
|
42
45
|
|
43
46
|
file = File.open( doc.path )
|
44
47
|
file_lines = file.readlines
|
@@ -186,7 +189,7 @@ class DocFabric
|
|
186
189
|
|
187
190
|
doc.items.append(item)
|
188
191
|
|
189
|
-
elsif res = /^(\*\s
|
192
|
+
elsif res = /^(\*\s+)(.*)/.match(s) #check if unordered list start
|
190
193
|
|
191
194
|
if tempMdTable
|
192
195
|
doc.items.append tempMdTable
|
@@ -272,6 +275,32 @@ class DocFabric
|
|
272
275
|
item = Blockquote.new(res[1])
|
273
276
|
item.parent_doc = doc
|
274
277
|
doc.items.append(item)
|
278
|
+
|
279
|
+
elsif res = /^```(\w*)/.match(s) #check if code block
|
280
|
+
|
281
|
+
if tempMdTable
|
282
|
+
doc.items.append tempMdTable
|
283
|
+
tempMdTable = nil
|
284
|
+
end
|
285
|
+
if tempMdList
|
286
|
+
doc.items.append tempMdList
|
287
|
+
tempMdList = nil
|
288
|
+
end
|
289
|
+
|
290
|
+
suggested_format = ""
|
291
|
+
if res.length == 2
|
292
|
+
suggested_format = res[1]
|
293
|
+
end
|
294
|
+
|
295
|
+
if tempCodeBlock
|
296
|
+
# close already opened block
|
297
|
+
doc.items.append(tempCodeBlock)
|
298
|
+
tempCodeBlock = nil
|
299
|
+
else
|
300
|
+
#start code block
|
301
|
+
tempCodeBlock = CodeBlock.new(suggested_format)
|
302
|
+
tempCodeBlock.parent_doc = doc
|
303
|
+
end
|
275
304
|
|
276
305
|
elsif res = /^TODO\:(.*)/.match(s) #check if TODO block
|
277
306
|
|
@@ -305,10 +334,13 @@ class DocFabric
|
|
305
334
|
tempMdList = nil
|
306
335
|
end
|
307
336
|
end
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
337
|
+
if tempCodeBlock
|
338
|
+
tempCodeBlock.code_lines.append(s)
|
339
|
+
else
|
340
|
+
item = Paragraph.new(s)
|
341
|
+
item.parent_doc = doc
|
342
|
+
doc.items.append(item)
|
343
|
+
end
|
312
344
|
end
|
313
345
|
else
|
314
346
|
if tempMdList # lists are separated by emty line from each other
|
@@ -326,5 +358,13 @@ class DocFabric
|
|
326
358
|
doc.items.append tempMdList
|
327
359
|
tempMdList = nil
|
328
360
|
end
|
361
|
+
if tempCodeBlock
|
362
|
+
doc.items.append tempCodeBlock
|
363
|
+
tempCodeBlock = nil
|
364
|
+
end
|
365
|
+
# Add footer to close opened tables if any
|
366
|
+
item = DocFooter.new
|
367
|
+
item.parent_doc = doc
|
368
|
+
doc.items.append(item)
|
329
369
|
end
|
330
370
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative "doc_item"
|
2
|
+
|
3
|
+
class CodeBlock < DocItem
|
4
|
+
|
5
|
+
attr_accessor :suggested_format
|
6
|
+
attr_accessor :code_lines
|
7
|
+
|
8
|
+
def initialize(suggested_format)
|
9
|
+
@suggested_format = suggested_format
|
10
|
+
@code_lines = Array.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_html
|
14
|
+
s = ''
|
15
|
+
|
16
|
+
if @@htmlTableRenderInProgress
|
17
|
+
s += "</table>\n"
|
18
|
+
@@htmlTableRenderInProgress = false
|
19
|
+
end
|
20
|
+
s += "<code>"
|
21
|
+
@code_lines.each do |l|
|
22
|
+
s += l + " </br>"
|
23
|
+
end
|
24
|
+
s += "</code>\n"
|
25
|
+
return s
|
26
|
+
end
|
27
|
+
end
|
@@ -47,7 +47,9 @@ class MarkdownList < DocItem
|
|
47
47
|
|
48
48
|
elsif pos < @@lists_stack[-1].indent_position
|
49
49
|
|
50
|
-
@@lists_stack.
|
50
|
+
while pos < @@lists_stack[-1].indent_position
|
51
|
+
@@lists_stack.pop
|
52
|
+
end
|
51
53
|
@@lists_stack[-1].rows.append(row)
|
52
54
|
|
53
55
|
else
|
@@ -70,14 +72,27 @@ class MarkdownList < DocItem
|
|
70
72
|
def calculate_text_position(s)
|
71
73
|
s.downcase
|
72
74
|
pos = 0
|
73
|
-
|
75
|
+
state = 'looking_for_list_item_marker'
|
74
76
|
s.each_char do |c|
|
75
|
-
if
|
76
|
-
if c
|
77
|
+
if state == 'looking_for_list_item_marker'
|
78
|
+
if c == '*'
|
79
|
+
state = 'looking_for_space'
|
80
|
+
elsif numeric?(c)
|
81
|
+
state = 'looking_for_dot'
|
82
|
+
end
|
83
|
+
elsif state == 'looking_for_dot'
|
84
|
+
if c == '.'
|
85
|
+
state = 'looking_for_space'
|
86
|
+
end
|
87
|
+
elsif state == 'looking_for_space'
|
88
|
+
if c == ' ' || c == '\t'
|
89
|
+
state = 'looking_for_non_space'
|
90
|
+
end
|
91
|
+
elsif state == 'looking_for_non_space'
|
92
|
+
if c != ' ' || c != '\t'
|
93
|
+
state = 'list_item_text_pos_found'
|
77
94
|
break
|
78
95
|
end
|
79
|
-
elsif c == ' ' || c == '\t'
|
80
|
-
space_detected = true
|
81
96
|
end
|
82
97
|
pos += 1
|
83
98
|
end
|
@@ -155,7 +155,7 @@ class TextLine
|
|
155
155
|
def link(link_text, link_url)
|
156
156
|
|
157
157
|
# define default result first
|
158
|
-
result = "<a href=\"#{link_url}\" class=\"external\">#{link_text}</a>"
|
158
|
+
result = "<a target=\"_blank\" rel=\"noopener\" href=\"#{link_url}\" class=\"external\">#{link_text}</a>"
|
159
159
|
|
160
160
|
lazy_doc_id, anchor = nil, nil
|
161
161
|
|
@@ -34,6 +34,7 @@ class Index < BaseDocument
|
|
34
34
|
s += "\t\t<th>Items<br>w/ Downlinks</th>\n"
|
35
35
|
s += "\t\t<th>Covered<br>by Tests</th>\n"
|
36
36
|
s += "\t\t<th>Duplicated<br>ids</th>\n"
|
37
|
+
s += "\t\t<th>Wrong<br>links</th>\n"
|
37
38
|
s += "\t\t<th>TODOs</th>\n"
|
38
39
|
s += "\t\t<th>Last Used<br>id</th>\n"
|
39
40
|
s += "</thead>\n"
|
@@ -63,6 +64,22 @@ class Index < BaseDocument
|
|
63
64
|
else
|
64
65
|
s += "\t\t<td class=\"item_id\" style='width: 7%;'>#{doc.duplicated_ids_number.to_s}</td>\n"
|
65
66
|
end
|
67
|
+
|
68
|
+
if doc.wrong_links_hash.length >0
|
69
|
+
s += "\t\t<td class=\"item_id\" style='width: 7%; background-color: #fcc;'>"
|
70
|
+
s += "<div id=\"DL_#{doc.id}wl\" style=\"display: block;\">"
|
71
|
+
s += "<a href=\"#\" onclick=\"downlink_OnClick(this.parentElement); return false;\" class=\"external\">#{doc.wrong_links_hash.length.to_s}</a>"
|
72
|
+
s += "</div>"
|
73
|
+
s += "<div id=\"DLS_#{doc.id}wl\" style=\"display: none;\">"
|
74
|
+
doc.wrong_links_hash.each do |wrong_lnk, item|
|
75
|
+
s += "\t\t\t<a href=\"./specifications/#{doc.id}/#{doc.id}.html##{item.id}\" class=\"external\">#{wrong_lnk}</a>\n<br>"
|
76
|
+
end
|
77
|
+
s += "</div>"
|
78
|
+
s += "</td>\n"
|
79
|
+
else
|
80
|
+
s += "\t\t<td class=\"item_id\" style='width: 7%;'>#{doc.wrong_links_hash.length.to_s}</td>\n"
|
81
|
+
end
|
82
|
+
|
66
83
|
if doc.todo_blocks.length >0
|
67
84
|
color = "background-color: #fcc;"
|
68
85
|
else
|
@@ -6,6 +6,7 @@ class Specification < BaseDocument
|
|
6
6
|
attr_accessor :dictionary
|
7
7
|
attr_accessor :controlled_items
|
8
8
|
attr_accessor :todo_blocks
|
9
|
+
attr_accessor :wrong_links_hash
|
9
10
|
|
10
11
|
attr_accessor :items_with_uplinks_number
|
11
12
|
attr_accessor :items_with_downlinks_number
|
@@ -25,6 +26,7 @@ class Specification < BaseDocument
|
|
25
26
|
@dictionary = Hash.new
|
26
27
|
@duplicates_list = Array.new
|
27
28
|
@todo_blocks = Array.new
|
29
|
+
@wrong_links_hash = Hash.new
|
28
30
|
|
29
31
|
@items_with_uplinks_number = 0
|
30
32
|
@items_with_downlinks_number = 0
|
data/lib/almirah/project.rb
CHANGED
@@ -35,6 +35,7 @@ class Project
|
|
35
35
|
parse_all_protocols
|
36
36
|
link_all_specifications
|
37
37
|
link_all_protocols
|
38
|
+
check_wrong_specification_referenced
|
38
39
|
create_index
|
39
40
|
render_all_specifications(@specifications)
|
40
41
|
render_all_specifications(@traceability_matrices)
|
@@ -49,6 +50,7 @@ class Project
|
|
49
50
|
parse_test_run test_run
|
50
51
|
link_all_specifications
|
51
52
|
link_all_protocols
|
53
|
+
check_wrong_specification_referenced
|
52
54
|
create_index
|
53
55
|
render_all_specifications(@specifications)
|
54
56
|
render_all_specifications(@traceability_matrices)
|
@@ -123,6 +125,37 @@ class Project
|
|
123
125
|
end
|
124
126
|
end
|
125
127
|
|
128
|
+
def check_wrong_specification_referenced
|
129
|
+
|
130
|
+
available_specification_ids = Hash.new
|
131
|
+
|
132
|
+
@specifications.each do |s|
|
133
|
+
available_specification_ids[ s.id.to_s.downcase ] = s
|
134
|
+
end
|
135
|
+
|
136
|
+
@specifications.each do |s|
|
137
|
+
s.up_link_doc_id.each do |key, value|
|
138
|
+
unless available_specification_ids.has_key?(key)
|
139
|
+
# now key points to the doc_id that does not exist
|
140
|
+
wrong_doc_id = key
|
141
|
+
# find the item that reference to it
|
142
|
+
s.controlled_items.each do |item|
|
143
|
+
unless item.up_link_ids.nil?
|
144
|
+
item.up_link_ids.each do |up_link_id|
|
145
|
+
if tmp = /^([a-zA-Z]+)[-]\d+/.match(up_link_id) # SRS
|
146
|
+
if tmp[1].downcase == wrong_doc_id
|
147
|
+
# we got it finally!
|
148
|
+
s.wrong_links_hash[ up_link_id.to_s ] = item
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
126
159
|
def link_two_specifications(doc_A, doc_B)
|
127
160
|
|
128
161
|
if doc_B.up_link_doc_id.has_key?(doc_A.id.to_s)
|
@@ -149,6 +182,13 @@ class Project
|
|
149
182
|
top_document.items_with_downlinks_number += 1 # for statistics
|
150
183
|
end
|
151
184
|
topItem.down_links.append(item)
|
185
|
+
else
|
186
|
+
# check if there is a non existing link with the right doc_id
|
187
|
+
if tmp = /^([a-zA-Z]+)[-]\d+/.match(up_lnk) # SRS
|
188
|
+
if tmp[1].downcase == top_document.id.downcase
|
189
|
+
bottom_document.wrong_links_hash[ up_lnk ] = item
|
190
|
+
end
|
191
|
+
end
|
152
192
|
end
|
153
193
|
end
|
154
194
|
end
|
@@ -145,6 +145,15 @@
|
|
145
145
|
margin-top: 4px;
|
146
146
|
margin-bottom: 4px;
|
147
147
|
}
|
148
|
+
code {
|
149
|
+
display: block;
|
150
|
+
background:#ffffee;
|
151
|
+
border-left: 3px double #bbb;
|
152
|
+
font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace;
|
153
|
+
padding: 4px 1em 4px 4px;
|
154
|
+
margin-top: 4px;
|
155
|
+
margin-bottom: 4px;
|
156
|
+
}
|
148
157
|
div.todoblock {
|
149
158
|
display: block;
|
150
159
|
background:#fcc;
|
@@ -341,16 +350,16 @@ function modal_close_OnClick(clicked){
|
|
341
350
|
</div>
|
342
351
|
<div id="content" href="javascript:void(0)" onclick="closeNav()">
|
343
352
|
{{CONTENT}}
|
344
|
-
</div
|
345
|
-
</div
|
353
|
+
</div><!-- content -->
|
354
|
+
</div><!-- main -->
|
355
|
+
<div id="footer">
|
356
|
+
Powered by <a target="_blank" rel="noopener" href="https://www.almirah.site/">Almirah Framework</a>
|
357
|
+
</div><!-- footer -->
|
346
358
|
<!-- The modal window for image zoom -->
|
347
359
|
<div id="image_modal_div" class="modal">
|
348
360
|
<span class="modal_close_btn" href="javascript:void(0)" onclick="modal_close_OnClick(this)">×</span>
|
349
361
|
<img class="modal_image" id="modal_image_id">
|
350
362
|
<div id="modal_image_caption"></div>
|
351
363
|
</div>
|
352
|
-
<div id="footer">
|
353
|
-
Powered by <a target="_blank" rel="noopener" href="https://www.almirah.site/">Almirah Framework</a>
|
354
|
-
</div>
|
355
364
|
</body>
|
356
365
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Almirah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleksandr Ivanov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The software part of the Almirah framework
|
14
14
|
email: oleksandr.ivanov.development@gmail.com
|
@@ -21,9 +21,11 @@ files:
|
|
21
21
|
- lib/almirah.rb
|
22
22
|
- lib/almirah/doc_fabric.rb
|
23
23
|
- lib/almirah/doc_items/blockquote.rb
|
24
|
+
- lib/almirah/doc_items/code_block.rb
|
24
25
|
- lib/almirah/doc_items/controlled_paragraph.rb
|
25
26
|
- lib/almirah/doc_items/controlled_table.rb
|
26
27
|
- lib/almirah/doc_items/controlled_table_row.rb
|
28
|
+
- lib/almirah/doc_items/doc_footer.rb
|
27
29
|
- lib/almirah/doc_items/doc_item.rb
|
28
30
|
- lib/almirah/doc_items/heading.rb
|
29
31
|
- lib/almirah/doc_items/image.rb
|
@@ -60,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
62
|
- !ruby/object:Gem::Version
|
61
63
|
version: '0'
|
62
64
|
requirements: []
|
63
|
-
rubygems_version: 3.5.
|
65
|
+
rubygems_version: 3.5.9
|
64
66
|
signing_key:
|
65
67
|
specification_version: 4
|
66
68
|
summary: Almirah
|