aspec_rb 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/aspec_rb/version.rb +1 -1
- data/lib/extensions/requirement_appendix.rb +16 -7
- data/lib/extensions/utils/search.rb +12 -1
- data/lib/postprocessors/fulltext_search.rb +18 -18
- data/lib/postprocessors/generate_toc.rb +4 -2
- 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: d2a1b3abea25b1809963996414935a74ba305e1a39b6ceabf4d9d1d766221501
|
4
|
+
data.tar.gz: b6cf95dd90879fc7c6c634c7f2af4a44239d9f682d3958770644324dfb92871c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25a21dc3e280b85c37b50aa2dea3d5da6d97f6ac5b5a25ebb545a739455f7c53e83e50c9b9af0740039f567c3915bdf225067bb7182393afb97629409af670c0
|
7
|
+
data.tar.gz: 952538cec2c9062ad300b65b3a1536ceb81b0254f53336a3d5840cdbb6212e9330434ffeec79c72c7b946a66437ba6abeb350272aaef0408abdb310a9f46bc89
|
data/Gemfile.lock
CHANGED
data/lib/aspec_rb/version.rb
CHANGED
@@ -87,8 +87,8 @@ reqs.each do |req, f, title, chapter, doctitle|
|
|
87
87
|
icon = '<i class="fa fa-external-link-square" aria-hidden="true"></i>'
|
88
88
|
ref = "<a class=\"link\" href=\"#{link}\"><emphasis role=\"strong\">#{icon} #{title}</emphasis> </a>"
|
89
89
|
breadcrumb = "<a href=\"#{f}\">#{chapter} / #{doctitle}</a>"
|
90
|
-
|
91
|
-
row = %(<tr id="Req-#{rid}"> <th scope="row">#{i}</th> <td style="white-space:pre;">#{
|
90
|
+
anchor = "<a class=\"link\" href=\"#Req-#{rid}\">#{rid}</a>"
|
91
|
+
row = %(<tr id="Req-#{rid}"> <th scope="row">#{i}</th> <td style="white-space:pre;">#{anchor}</td>
|
92
92
|
<td><span class="badge badge-primary badge-pill">#{version}</span></td> <td>#{ref}</td> <td>#{f}</td> </tr>)
|
93
93
|
|
94
94
|
rows.push(row)
|
@@ -97,16 +97,25 @@ end
|
|
97
97
|
Asciidoctor::Extensions.register do
|
98
98
|
block_macro :requirements do
|
99
99
|
process do |parent, _target, _attrs|
|
100
|
-
content = %(<
|
101
|
-
|
102
|
-
<
|
103
|
-
<table class="table"> <thead> <tr>
|
100
|
+
content = %(<div class="panel panel-default reqlist"> <div class="panel-heading"><h4>Requirements</h4></div>
|
101
|
+
<input class="form-control" id="tableFilter" type="text" placeholder="Filter..">
|
102
|
+
<table class="table" id="reqTable"> <thead> <tr>
|
104
103
|
<th>#</th> <th>ID</th><th>Version</th> <th>Title</th> <th>Source Document</th>
|
105
104
|
</tr> </thead>
|
106
105
|
<tbody>
|
107
106
|
#{rows.join}
|
108
107
|
</tbody>
|
109
|
-
</table> </div>
|
108
|
+
</table> </div>
|
109
|
+
<script>
|
110
|
+
$(document).ready(function(){
|
111
|
+
$("#tableFilter").on("keyup", function() {
|
112
|
+
var value = $(this).val().toLowerCase();
|
113
|
+
$("#reqTable tr").filter(function() {
|
114
|
+
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
|
115
|
+
});
|
116
|
+
});
|
117
|
+
});
|
118
|
+
</script>)
|
110
119
|
|
111
120
|
create_pass_block parent, content, {}
|
112
121
|
end
|
@@ -1,13 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Search
|
4
|
+
# Some special handling for sanitizing the search json
|
5
|
+
def self.sanitize_json(str)
|
6
|
+
special_chars = /"|\n|«|»
|\{|\}|…/
|
7
|
+
str.gsub!(special_chars, ' ')
|
8
|
+
str.gsub!(/\s+/, ' ')
|
9
|
+
str.gsub!(/Unresolved directive.+\[\]/, '')
|
10
|
+
str.gsub!(/\</, '<') if str[/\</]
|
11
|
+
str.gsub!(/\>/, '>') if str[/\>/]
|
12
|
+
str
|
13
|
+
end
|
14
|
+
|
4
15
|
def self.add_to_index(file, slug, title, content)
|
5
16
|
section = %(
|
6
17
|
"#{slug}": {
|
7
18
|
"id": "#{slug}",
|
8
19
|
"title": "#{title}",
|
9
20
|
"url": "#{file}",
|
10
|
-
"content": "#{content}"
|
21
|
+
"content": "#{sanitize_json(content)}"
|
11
22
|
},\n)
|
12
23
|
end
|
13
24
|
end
|
@@ -7,10 +7,15 @@ require_relative '../extensions/utils/utils'
|
|
7
7
|
|
8
8
|
@json = ''
|
9
9
|
gendir = 'generated-docs' # TODO: - do not hardcode
|
10
|
-
replacements = /"|\n|«|»
|\s+|\{|\}|…/
|
11
10
|
|
12
11
|
html_files = Dir.glob("#{gendir}/**/*.html")
|
13
12
|
|
13
|
+
def add_heading(subsection, url, level)
|
14
|
+
id = subsection.at(level).attr('id')
|
15
|
+
sub_url = url + '#' + id
|
16
|
+
@json += Search.add_to_index(sub_url, id, subsection.at(level).text, subsection.text)
|
17
|
+
end
|
18
|
+
|
14
19
|
html_files.each do |file|
|
15
20
|
next if file == "#{gendir}/search.html" || file[%r{^#{gendir}\/index}]
|
16
21
|
|
@@ -22,34 +27,29 @@ html_files.each do |file|
|
|
22
27
|
page.xpath("//div[@class='sect1']").each do |section|
|
23
28
|
if section.at_css('div.sect2')
|
24
29
|
|
25
|
-
section.xpath("//div[@class='sect2']").each do |subsection|
|
30
|
+
section.xpath("//div[@class='sect2' or @class='sect2 language-n4js']").each do |subsection|
|
26
31
|
if subsection.at_css('div.sect3')
|
27
|
-
title = subsection.at('h4').text
|
28
|
-
id = "\##{subsection.at('h4').attr('id')}"
|
29
|
-
sub_url = url + id
|
30
|
-
text = subsection.text.gsub(replacements, ' ')
|
31
|
-
@json += Search.add_to_index(sub_url, id, title, text)
|
32
|
-
else
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
section.xpath("//div[@class='sect3']").each do |subsection|
|
34
|
+
if subsection.at_css('div.sect4')
|
35
|
+
add_heading(subsection, url, 'h5')
|
36
|
+
else
|
37
|
+
add_heading(subsection, url, 'h4')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
else
|
42
|
+
add_heading(subsection, url, 'h3')
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
42
46
|
else
|
43
|
-
text = section.xpath("//div[@class='sect1']").css('p').text
|
47
|
+
text = section.xpath("//div[@class='sect1' or @class='sect1 language-n4js']").css('p').text
|
44
48
|
@json += Search.add_to_index(url, slug, title, text)
|
45
49
|
end
|
46
50
|
end
|
47
51
|
end
|
48
52
|
|
49
|
-
@json.gsub!(/\</, '<')
|
50
|
-
@json.gsub!(/\>/, '>')
|
51
|
-
|
52
|
-
puts @json
|
53
53
|
jsonindex = %(<script>
|
54
54
|
window.data = {
|
55
55
|
|
@@ -25,6 +25,9 @@ appendices = []
|
|
25
25
|
|
26
26
|
html_files.each do |file|
|
27
27
|
next if file == "#{gendir}/search.html" || file[%r{^#{gendir}\/index}]
|
28
|
+
if file == "#{gendir}/revision_history.html"
|
29
|
+
toc += %(<li><a href="revision_history.html">Revision History</a></li>)
|
30
|
+
end
|
28
31
|
page = Nokogiri::HTML(open(file))
|
29
32
|
filename = file.sub(%r{^#{gendir}\/}, '')
|
30
33
|
|
@@ -75,8 +78,7 @@ anchors.each do |file, id, text, level|
|
|
75
78
|
if level > prev_level
|
76
79
|
if i != 0
|
77
80
|
toc = toc.chomp("</li>\n")
|
78
|
-
toc += " <a href=\"#\" data-toggle=\"collapse\" data-target=\"#tocnav_#{id}\"><i class=\"fa fa-plus-square\" aria-hidden=\"true\"></i></a>
|
79
|
-
<ul>
|
81
|
+
toc += " <a href=\"#\" data-toggle=\"collapse\" data-target=\"#tocnav_#{id}\"><i class=\"fa fa-plus-square\" aria-hidden=\"true\"></i></a><ul>
|
80
82
|
<div id=\"tocnav_#{id}\" class=\"collapse\">
|
81
83
|
<li><a href=\"#{file}##{id}\">#{text}</a></li>\n"
|
82
84
|
li = ''
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aspec_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tcob
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|