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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6243468a5b596117cdcada689105e7e49657f9dc2bdb25e75d7b25464e46b20e
4
- data.tar.gz: f6f33c72752b20bd12b1f5beaeced038d32fa818320d48c2d30df8278758e63e
3
+ metadata.gz: d2a1b3abea25b1809963996414935a74ba305e1a39b6ceabf4d9d1d766221501
4
+ data.tar.gz: b6cf95dd90879fc7c6c634c7f2af4a44239d9f682d3958770644324dfb92871c
5
5
  SHA512:
6
- metadata.gz: 6ba50b1e54f9e2a3df06abf095422c9e3d0c9636dcd173f5308736a629dd2280ab5087529c0eb6f4deeb57c40e9af5264604b271dd34601884f73441951609ce
7
- data.tar.gz: 01b04622209bd03ce0ac6ab7a35c2f9939be5ea19fb9fc08600b10f0143650732795283da15182db821c157429881934b9847169e5745a2a2ad3fdc69a88f45f
6
+ metadata.gz: 25a21dc3e280b85c37b50aa2dea3d5da6d97f6ac5b5a25ebb545a739455f7c53e83e50c9b9af0740039f567c3915bdf225067bb7182393afb97629409af670c0
7
+ data.tar.gz: 952538cec2c9062ad300b65b3a1536ceb81b0254f53336a3d5840cdbb6212e9330434ffeec79c72c7b946a66437ba6abeb350272aaef0408abdb310a9f46bc89
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aspec_rb (0.0.12)
4
+ aspec_rb (0.0.13)
5
5
  asciidoctor
6
6
 
7
7
  GEM
@@ -7,5 +7,5 @@ module AspecRb
7
7
  # For this deploy config, see https://github.com/tcob/aspec_rb/blob/master/.travis.yml
8
8
  #
9
9
  # Manual release can be performed by running 'bundle install && rake release'
10
- VERSION = '0.0.12'
10
+ VERSION = '0.0.13'
11
11
  end
@@ -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
- # 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;">#{rid}</td>
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 = %(<h2 id="requirements"><a class="anchor" href="#requirements"></a>
101
- <a class="link" href="#requirements">Requirements</a></h2>
102
- <div class="panel panel-default reqlist"> <div class="panel-heading"><h4>Requirements</h4></div>
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!(/\</, '&lt;') if str[/\</]
11
+ str.gsub!(/\>/, '&gt;') 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
- title = subsection.at('h3').text
35
- id = "\##{subsection.at('h3').attr('id')}"
36
- sub_url = url + id
37
- text = subsection.text.gsub(replacements, ' ')
38
- @json += Search.add_to_index(sub_url, id, title, text)
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.gsub(replacements, ' ')
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!(/\</, '&lt;')
50
- @json.gsub!(/\>/, '&gt;')
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.12
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-04-27 00:00:00.000000000 Z
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler