aspec_rb 0.0.11 → 0.0.12

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: ff6a5bc897689e791b6d5745261606cad1c72a515c1675cbc50685aaffd7b4cb
4
- data.tar.gz: 5798e3a071a58d51f2d1b4248613cbc49f4813c837324075ea1699cbeea2048b
3
+ metadata.gz: 6243468a5b596117cdcada689105e7e49657f9dc2bdb25e75d7b25464e46b20e
4
+ data.tar.gz: f6f33c72752b20bd12b1f5beaeced038d32fa818320d48c2d30df8278758e63e
5
5
  SHA512:
6
- metadata.gz: 6fbbb24a7a25c565c070e4f2d485b672341defc776866664f6a5d8878f6821ecd13e2b1207fa132e6f669bb39e00a7432e3b5d5246896833f2e7e6b17499ecff
7
- data.tar.gz: 049355809fdaa91fbe891df9d1b3811bceee0657686739feb9868db9f245bc005c069052c3ddc7774ee1c044016b6db25c986aff63d6ff03c6fbc0a36da38ef8
6
+ metadata.gz: 6ba50b1e54f9e2a3df06abf095422c9e3d0c9636dcd173f5308736a629dd2280ab5087529c0eb6f4deeb57c40e9af5264604b271dd34601884f73441951609ce
7
+ data.tar.gz: 01b04622209bd03ce0ac6ab7a35c2f9939be5ea19fb9fc08600b10f0143650732795283da15182db821c157429881934b9847169e5745a2a2ad3fdc69a88f45f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aspec_rb (0.0.11)
4
+ aspec_rb (0.0.12)
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.11'
10
+ VERSION = '0.0.12'
11
11
  end
@@ -89,7 +89,7 @@ reqs.each do |req, f, title, chapter, doctitle|
89
89
  breadcrumb = "<a href=\"#{f}\">#{chapter} / #{doctitle}</a>"
90
90
  # anchor = "<a class=\"link\" href=\"#Req-#{rid}\">#{rid}</a>"
91
91
  row = %(<tr id="Req-#{rid}"> <th scope="row">#{i}</th> <td style="white-space:pre;">#{rid}</td>
92
- <td>#{version}</td> <td>#{ref}</td> <td>#{f}</td> </tr>)
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)
95
95
  end
@@ -99,7 +99,7 @@ Asciidoctor::Extensions.register do
99
99
  process do |parent, _target, _attrs|
100
100
  content = %(<h2 id="requirements"><a class="anchor" href="#requirements"></a>
101
101
  <a class="link" href="#requirements">Requirements</a></h2>
102
- <div class="panel panel-default"> <div class="panel-heading"><h4>Requirements</h4></div>
102
+ <div class="panel panel-default reqlist"> <div class="panel-heading"><h4>Requirements</h4></div>
103
103
  <table class="table"> <thead> <tr>
104
104
  <th>#</th> <th>ID</th><th>Version</th> <th>Title</th> <th>Source Document</th>
105
105
  </tr> </thead>
@@ -24,7 +24,7 @@ module Context
24
24
  if pattern == 'unknown'
25
25
  "<div style=\"float:right;padding-left:0.1em;\"><span class=\"label label-#{label}\" data-toggle=\"tooltip\" title=\"Missing config\">#{target}</span></div>"
26
26
  else
27
- "<div style=\"float:right;padding-left:0.1em;\"><a href=\"#{url}\"><span class=\"label label-#{label}\">#{target}</span></a></div>"
27
+ "<div style=\"float:right;padding-left:0.1em;\"><a href=\"#{url}\"><span class=\"label label-#{label} task\">#{target}</span></a></div>"
28
28
  end
29
29
  else
30
30
  if pattern == 'unknown'
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Search
4
+ def self.add_to_index(file, slug, title, content)
5
+ section = %(
6
+ "#{slug}": {
7
+ "id": "#{slug}",
8
+ "title": "#{title}",
9
+ "url": "#{file}",
10
+ "content": "#{content}"
11
+ },\n)
12
+ end
13
+ end
@@ -4,3 +4,4 @@ require_relative 'block'
4
4
  require_relative 'index'
5
5
  require_relative 'labels'
6
6
  require_relative 'scanner'
7
+ require_relative 'search'
@@ -3,38 +3,57 @@
3
3
  require 'nokogiri'
4
4
  require 'fileutils'
5
5
  require 'open-uri'
6
+ require_relative '../extensions/utils/utils'
6
7
 
7
- json = ''
8
+ @json = ''
8
9
  gendir = 'generated-docs' # TODO: - do not hardcode
9
- replacements = /"|\n|«|»
|\s\s/
10
+ replacements = /"|\n|«|»
|\s+|\{|\}|…/
10
11
 
11
12
  html_files = Dir.glob("#{gendir}/**/*.html")
12
13
 
13
14
  html_files.each do |file|
14
- # Skip the search results and index pages
15
15
  next if file == "#{gendir}/search.html" || file[%r{^#{gendir}\/index}]
16
16
 
17
17
  page = Nokogiri::HTML(open(file))
18
- file.sub!(%r{^#{gendir}\/}, '')
18
+ url = file.sub!(%r{^#{gendir}\/}, '')
19
19
  slug = file.sub(/\.html$/, '')
20
+ title = page.css('h2').text
20
21
 
21
- h2 = page.css('h2').text
22
- text = page.css('p').text.gsub(replacements, ' ')
23
-
24
- content = %(
25
- "#{slug}": {
26
- "id": "#{slug}",
27
- "title": "#{h2}",
28
- "url": "#{file}",
29
- "content": "#{text}"
30
- },\n)
31
- json += content
22
+ page.xpath("//div[@class='sect1']").each do |section|
23
+ if section.at_css('div.sect2')
24
+
25
+ section.xpath("//div[@class='sect2']").each do |subsection|
26
+ 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
+
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)
39
+ end
40
+ end
41
+
42
+ else
43
+ text = section.xpath("//div[@class='sect1']").css('p').text.gsub(replacements, ' ')
44
+ @json += Search.add_to_index(url, slug, title, text)
45
+ end
46
+ end
32
47
  end
33
48
 
49
+ @json.gsub!(/\</, '&lt;')
50
+ @json.gsub!(/\>/, '&gt;')
51
+
52
+ puts @json
34
53
  jsonindex = %(<script>
35
54
  window.data = {
36
55
 
37
- #{json}
56
+ #{@json}
38
57
 
39
58
  };
40
59
  </script>)
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.11
4
+ version: 0.0.12
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-26 00:00:00.000000000 Z
11
+ date: 2018-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,7 @@ files:
108
108
  - lib/extensions/utils/index.rb
109
109
  - lib/extensions/utils/labels.rb
110
110
  - lib/extensions/utils/scanner.rb
111
+ - lib/extensions/utils/search.rb
111
112
  - lib/extensions/utils/utils.rb
112
113
  - lib/html_chunker.rb
113
114
  - lib/postprocessors/fulltext_search.rb