Almirah 0.2.5 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/almirah +4 -4
- data/lib/almirah/doc_fabric.rb +65 -65
- data/lib/almirah/doc_items/blockquote.rb +21 -21
- data/lib/almirah/doc_items/code_block.rb +26 -26
- data/lib/almirah/doc_items/controlled_paragraph.rb +112 -112
- data/lib/almirah/doc_items/controlled_table.rb +224 -224
- data/lib/almirah/doc_items/controlled_table_row.rb +22 -22
- data/lib/almirah/doc_items/doc_footer.rb +16 -16
- data/lib/almirah/doc_items/doc_item.rb +22 -22
- data/lib/almirah/doc_items/frontmatter.rb +9 -9
- data/lib/almirah/doc_items/heading.rb +93 -93
- data/lib/almirah/doc_items/image.rb +27 -27
- data/lib/almirah/doc_items/markdown_list.rb +156 -156
- data/lib/almirah/doc_items/markdown_table.rb +97 -61
- data/lib/almirah/doc_items/paragraph.rb +25 -25
- data/lib/almirah/doc_items/text_line.rb +296 -296
- data/lib/almirah/doc_items/todo_block.rb +21 -21
- data/lib/almirah/doc_parser.rb +379 -378
- data/lib/almirah/doc_types/base_document.rb +64 -64
- data/lib/almirah/doc_types/coverage.rb +95 -80
- data/lib/almirah/doc_types/index.rb +173 -173
- data/lib/almirah/doc_types/persistent_document.rb +17 -17
- data/lib/almirah/doc_types/protocol.rb +24 -24
- data/lib/almirah/doc_types/specification.rb +67 -67
- data/lib/almirah/doc_types/traceability.rb +142 -142
- data/lib/almirah/dom/doc_section.rb +25 -25
- data/lib/almirah/dom/document.rb +78 -78
- data/lib/almirah/navigation_pane.rb +16 -16
- data/lib/almirah/project.rb +287 -287
- data/lib/almirah/project_configuration.rb +41 -41
- data/lib/almirah/project_template.rb +298 -298
- data/lib/almirah/project_utility.rb +52 -0
- data/lib/almirah/search/specifications_db.rb +79 -79
- data/lib/almirah/templates/css/main.css +300 -300
- data/lib/almirah/templates/css/search.css +40 -40
- data/lib/almirah/templates/page.html +42 -42
- data/lib/almirah/templates/scripts/main.js +111 -111
- data/lib/almirah/templates/scripts/orama_search.js +138 -138
- data/lib/almirah.rb +93 -58
- metadata +4 -3
@@ -1,79 +1,79 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
# Prepare JSON database file for further indexing by other tools
|
6
|
-
class SpecificationsDb
|
7
|
-
attr_accessor :specifications, :data
|
8
|
-
|
9
|
-
def initialize(spec_list)
|
10
|
-
@specifications = spec_list
|
11
|
-
@data = []
|
12
|
-
create_data
|
13
|
-
end
|
14
|
-
|
15
|
-
def create_data # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
16
|
-
@specifications.each do |sp|
|
17
|
-
sp.items.each do |i|
|
18
|
-
if (i.instance_of? Paragraph) or (i.instance_of? ControlledParagraph)
|
19
|
-
e = { 'document' => i.parent_doc.title, \
|
20
|
-
'doc_color' => i.parent_doc.color, \
|
21
|
-
'text' => i.text, \
|
22
|
-
'heading_url' => i.parent_heading.get_url, \
|
23
|
-
'heading_text' => i.parent_heading.get_section_info }
|
24
|
-
@data.append e
|
25
|
-
elsif i.instance_of? MarkdownList
|
26
|
-
add_markdown_list_item_to_db(@data, i, i)
|
27
|
-
elsif i.instance_of? MarkdownTable
|
28
|
-
add_markdown_table_item_to_db(@data, i, i)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def add_markdown_list_item_to_db(data, item_for_reference, item_to_process) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
35
|
-
e = nil
|
36
|
-
item_to_process.rows.each do |r|
|
37
|
-
if r.is_a?(MarkdownList)
|
38
|
-
f_text = r.text
|
39
|
-
e = { 'document' => item_for_reference.parent_doc.title, \
|
40
|
-
'doc_color' => item_for_reference.parent_doc.color, \
|
41
|
-
'text' => f_text, \
|
42
|
-
'heading_url' => item_for_reference.parent_heading.get_url, \
|
43
|
-
'heading_text' => item_for_reference.parent_heading.get_section_info }
|
44
|
-
data << e
|
45
|
-
add_markdown_list_item_to_db(data, item_for_reference, r)
|
46
|
-
else
|
47
|
-
f_text = r
|
48
|
-
e = { 'document' => item_for_reference.parent_doc.title, \
|
49
|
-
'doc_color' => item_for_reference.parent_doc.color, \
|
50
|
-
'text' => f_text, \
|
51
|
-
'heading_url' => item_for_reference.parent_heading.get_url, \
|
52
|
-
'heading_text' => item_for_reference.parent_heading.get_section_info }
|
53
|
-
data << e
|
54
|
-
end
|
55
|
-
end
|
56
|
-
e
|
57
|
-
end
|
58
|
-
|
59
|
-
def add_markdown_table_item_to_db(data, item_for_reference, item_to_process)
|
60
|
-
table_text = ''
|
61
|
-
item_to_process.rows.each do |row|
|
62
|
-
table_text += "| #{row.join(' | ')} |"
|
63
|
-
end
|
64
|
-
e = { 'document' => item_for_reference.parent_doc.title, \
|
65
|
-
'doc_color' => item_for_reference.parent_doc.color, \
|
66
|
-
'text' => table_text, \
|
67
|
-
'heading_url' => item_for_reference.parent_heading.get_url, \
|
68
|
-
'heading_text' => item_for_reference.parent_heading.get_section_info }
|
69
|
-
data << e
|
70
|
-
end
|
71
|
-
|
72
|
-
def save(path)
|
73
|
-
json = JSON.generate(@data)
|
74
|
-
|
75
|
-
file = File.open("#{path}/specifications_db.json", 'w')
|
76
|
-
file.puts json
|
77
|
-
file.close
|
78
|
-
end
|
79
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
# Prepare JSON database file for further indexing by other tools
|
6
|
+
class SpecificationsDb
|
7
|
+
attr_accessor :specifications, :data
|
8
|
+
|
9
|
+
def initialize(spec_list)
|
10
|
+
@specifications = spec_list
|
11
|
+
@data = []
|
12
|
+
create_data
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_data # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
16
|
+
@specifications.each do |sp|
|
17
|
+
sp.items.each do |i|
|
18
|
+
if (i.instance_of? Paragraph) or (i.instance_of? ControlledParagraph)
|
19
|
+
e = { 'document' => i.parent_doc.title, \
|
20
|
+
'doc_color' => i.parent_doc.color, \
|
21
|
+
'text' => i.text, \
|
22
|
+
'heading_url' => i.parent_heading.get_url, \
|
23
|
+
'heading_text' => i.parent_heading.get_section_info }
|
24
|
+
@data.append e
|
25
|
+
elsif i.instance_of? MarkdownList
|
26
|
+
add_markdown_list_item_to_db(@data, i, i)
|
27
|
+
elsif i.instance_of? MarkdownTable
|
28
|
+
add_markdown_table_item_to_db(@data, i, i)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_markdown_list_item_to_db(data, item_for_reference, item_to_process) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
35
|
+
e = nil
|
36
|
+
item_to_process.rows.each do |r|
|
37
|
+
if r.is_a?(MarkdownList)
|
38
|
+
f_text = r.text
|
39
|
+
e = { 'document' => item_for_reference.parent_doc.title, \
|
40
|
+
'doc_color' => item_for_reference.parent_doc.color, \
|
41
|
+
'text' => f_text, \
|
42
|
+
'heading_url' => item_for_reference.parent_heading.get_url, \
|
43
|
+
'heading_text' => item_for_reference.parent_heading.get_section_info }
|
44
|
+
data << e
|
45
|
+
add_markdown_list_item_to_db(data, item_for_reference, r)
|
46
|
+
else
|
47
|
+
f_text = r
|
48
|
+
e = { 'document' => item_for_reference.parent_doc.title, \
|
49
|
+
'doc_color' => item_for_reference.parent_doc.color, \
|
50
|
+
'text' => f_text, \
|
51
|
+
'heading_url' => item_for_reference.parent_heading.get_url, \
|
52
|
+
'heading_text' => item_for_reference.parent_heading.get_section_info }
|
53
|
+
data << e
|
54
|
+
end
|
55
|
+
end
|
56
|
+
e
|
57
|
+
end
|
58
|
+
|
59
|
+
def add_markdown_table_item_to_db(data, item_for_reference, item_to_process)
|
60
|
+
table_text = ''
|
61
|
+
item_to_process.rows.each do |row|
|
62
|
+
table_text += "| #{row.join(' | ')} |"
|
63
|
+
end
|
64
|
+
e = { 'document' => item_for_reference.parent_doc.title, \
|
65
|
+
'doc_color' => item_for_reference.parent_doc.color, \
|
66
|
+
'text' => table_text, \
|
67
|
+
'heading_url' => item_for_reference.parent_heading.get_url, \
|
68
|
+
'heading_text' => item_for_reference.parent_heading.get_section_info }
|
69
|
+
data << e
|
70
|
+
end
|
71
|
+
|
72
|
+
def save(path)
|
73
|
+
json = JSON.generate(@data)
|
74
|
+
|
75
|
+
file = File.open("#{path}/specifications_db.json", 'w')
|
76
|
+
file.puts json
|
77
|
+
file.close
|
78
|
+
end
|
79
|
+
end
|