aspec_rb 0.0.14 → 0.0.15
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/Gemfile.lock +3 -3
- data/lib/aspec_rb/version.rb +1 -1
- data/lib/aspec_rb.rb +3 -1
- data/lib/extensions/autoxrefs.rb +23 -24
- data/lib/extensions/definition_block.rb +1 -3
- data/lib/extensions/req_refs.rb +6 -5
- data/lib/extensions/utils/search.rb +0 -2
- data/lib/html_chunker.rb +3 -3
- data/lib/postprocessors/fulltext_search.rb +7 -11
- data/lib/postprocessors/generate_toc.rb +7 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ceaae8abf8a8ed63c0e9d7a58b5065ad8d56a3e13a6d9b4ca43be3367ff4869
|
4
|
+
data.tar.gz: 456c514ec27c3e61b97ec3486415d71be01f38c8809e2c59fb20a3bf44ab823a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a95bbc8b021c3811a318fc2e270e12dc2e61520d77dfdf5870a1d333ff68d5192a11a66c890a4de7f6f52f3ff4e1322d5442cba81eb4896573f57bed4dc087b
|
7
|
+
data.tar.gz: 9053d5e8942fe690eb61df5370fa76ea5191c060d18b1e7c0df390f30dbc0370b41175558cde69655f7e5092697581c89409a5061b61eb1d3105ca73f6bd3f0e
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
aspec_rb (0.0.
|
4
|
+
aspec_rb (0.0.15)
|
5
5
|
asciidoctor
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
asciidoctor (1.5.7.1)
|
11
|
-
docile (1.3.
|
11
|
+
docile (1.3.1)
|
12
12
|
json (2.1.0)
|
13
13
|
power_assert (1.1.1)
|
14
14
|
rake (12.3.1)
|
@@ -31,4 +31,4 @@ DEPENDENCIES
|
|
31
31
|
test-unit
|
32
32
|
|
33
33
|
BUNDLED WITH
|
34
|
-
1.16.
|
34
|
+
1.16.2
|
data/lib/aspec_rb/version.rb
CHANGED
data/lib/aspec_rb.rb
CHANGED
data/lib/extensions/autoxrefs.rb
CHANGED
@@ -12,6 +12,7 @@ AnchorRx = /\[\[(?:|([\w+?_:][\w+?:.-]*)(?:, *(.+))?)\]\]/
|
|
12
12
|
|
13
13
|
ni_includes, includes, doclinks, anchorfixes, intrachapter, interchapter, anchors, xrefs = Array.new(9) { [] }
|
14
14
|
|
15
|
+
# Don't do this!
|
15
16
|
adoc_files = Dir.glob("#{$srcdir}/**/*.adoc")
|
16
17
|
|
17
18
|
indexincludes = Index.includes
|
@@ -41,6 +42,8 @@ adoc_files.each do |filename|
|
|
41
42
|
target = xref.gsub(/,.+/, '')
|
42
43
|
text = xref.gsub(/.+,/, '').lstrip
|
43
44
|
xref = xref.sub(/,.+/, '')
|
45
|
+
elsif xref[/^SC_ROPR/]
|
46
|
+
text = xref
|
44
47
|
else
|
45
48
|
text = Sform.titleify(xref).strip
|
46
49
|
end
|
@@ -78,7 +81,7 @@ adoc_files.each do |filename|
|
|
78
81
|
child = li.match(/(?<=^include::).+?\.adoc(?=\[\])/).to_s
|
79
82
|
child = child.sub(/^\{find\}/, '')
|
80
83
|
childpath = "#{filename.sub(/[^\/]+?\.adoc/, '')}#{child}"
|
81
|
-
includes.push([filename, child, childpath])
|
84
|
+
includes.push([Sform.trim(filename), child, Sform.trim(childpath)])
|
82
85
|
|
83
86
|
end
|
84
87
|
end
|
@@ -92,6 +95,7 @@ adoc_files.each do |filename|
|
|
92
95
|
end
|
93
96
|
end
|
94
97
|
|
98
|
+
|
95
99
|
# For each main include, store a target link
|
96
100
|
anchors.each do |_anchor, full, _filename, link, chapter, main, h1|
|
97
101
|
next unless main && h1
|
@@ -99,8 +103,9 @@ anchors.each do |_anchor, full, _filename, link, chapter, main, h1|
|
|
99
103
|
doclinks.push([doc, link, chapter])
|
100
104
|
end
|
101
105
|
|
102
|
-
# If a section title has an overriding anchor on the previous line, perform the following fix
|
103
106
|
o_anchors = []
|
107
|
+
|
108
|
+
# If a section title has an overriding anchor on the previous line, perform the following fix
|
104
109
|
doclinks.delete_if do |doc, _link, mchapter|
|
105
110
|
topleveldoc = "#{$srcdir}/#{mchapter}/#{doc}.adoc"
|
106
111
|
lines = File.foreach(topleveldoc).first(10).join
|
@@ -113,27 +118,15 @@ end
|
|
113
118
|
doclinks += o_anchors
|
114
119
|
doclinks.uniq!
|
115
120
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
# Loop through all includes, if the anchor is contained in an include,
|
123
|
-
# edit the anchors array to point to its parent instead
|
124
|
-
includes.each do |parent, _child, childpath|
|
125
|
-
anchors.delete_if do |anchor, path, filename, text, chapter, main, _h1|
|
126
|
-
next unless Sform.trim(childpath) == Sform.trim(filename)
|
127
|
-
tempanchors.push([anchor, path, Sform.trim(parent), text, chapter, main])
|
128
|
-
true
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
anchors += tempanchors
|
133
|
-
anchors.uniq!
|
121
|
+
includes.each do |parent, _child, childpath|
|
122
|
+
anchors.map! { |anchor, path, filename, text, chapter, main, _h1|
|
123
|
+
filename = parent if childpath == path
|
124
|
+
[anchor, path, filename, text, chapter, main, _h1]
|
125
|
+
}
|
134
126
|
end
|
135
127
|
|
136
|
-
|
128
|
+
anchors.uniq!
|
129
|
+
tempanchors = []
|
137
130
|
|
138
131
|
anchors.delete_if do |anchor, apath, trim_parent, parent, amain, achapter|
|
139
132
|
doclinks.each do |doc, link, dchapter|
|
@@ -143,6 +136,8 @@ anchors.delete_if do |anchor, apath, trim_parent, parent, amain, achapter|
|
|
143
136
|
end
|
144
137
|
end
|
145
138
|
|
139
|
+
|
140
|
+
tempanchors.uniq!
|
146
141
|
anchors += tempanchors
|
147
142
|
anchors.uniq!
|
148
143
|
|
@@ -155,7 +150,7 @@ xrefs.each do |xref, xpath, _xfilename, _xtext, xtarget, _xchapter|
|
|
155
150
|
afilename = '' if xpath == apath
|
156
151
|
# xtext = xref if xtext.empty?
|
157
152
|
afilename.sub!(/^_/, '') if afilename[/^_/]
|
158
|
-
fix = "#{afilename}##{atext},#{
|
153
|
+
fix = "#{afilename}##{atext},#{_xtext}"
|
159
154
|
anchorfixes.push([anchor, fix, xref])
|
160
155
|
end
|
161
156
|
end
|
@@ -163,7 +158,9 @@ end
|
|
163
158
|
Extensions.register do
|
164
159
|
preprocessor do
|
165
160
|
process do |_document, reader|
|
166
|
-
|
161
|
+
# return reader if reader.eof?
|
162
|
+
|
163
|
+
replacement_lines = reader.read_lines.map do |line|
|
167
164
|
if line[/\<\<(?!Req)(.+?)\>\>/]
|
168
165
|
anchorfixes.each do |original, fix|
|
169
166
|
next unless line[/\<\<#{original}(,.+?)?\>\>/]
|
@@ -177,7 +174,9 @@ Extensions.register do
|
|
177
174
|
2.times { line.sub!(/`/, '') }
|
178
175
|
end
|
179
176
|
line
|
180
|
-
|
177
|
+
end
|
178
|
+
reader.unshift_lines replacement_lines
|
179
|
+
reader
|
181
180
|
end
|
182
181
|
end
|
183
182
|
end
|
data/lib/extensions/req_refs.rb
CHANGED
@@ -56,7 +56,7 @@ adoc_files.each do |filename|
|
|
56
56
|
child = li.match(/(?<=^include::).+?\.adoc(?=\[\])/).to_s
|
57
57
|
child = child.sub(/^\{find\}/, '')
|
58
58
|
childpath = "#{filename.sub(/[^\/]+?\.adoc/, '')}#{child}"
|
59
|
-
includes.push([filename, child, childpath])
|
59
|
+
includes.push([Sform.trim(filename), child, Sform.trim(childpath)])
|
60
60
|
|
61
61
|
end
|
62
62
|
end
|
@@ -105,20 +105,21 @@ end
|
|
105
105
|
|
106
106
|
# TODO: - see if editing the array in-place is better using map!
|
107
107
|
includes += ni_includes
|
108
|
+
tempreqs = []
|
108
109
|
|
109
110
|
# Edit the array of Requirements to point to the parent document *if* it is included.
|
110
111
|
# TODO use a while loop, repeat until no changes made
|
111
112
|
3.times do
|
112
113
|
# initialize an array
|
113
|
-
tempreqs
|
114
|
+
tempreqs.clear
|
114
115
|
|
115
116
|
# Loop through all includes, if the requirement is contained in an include,
|
116
117
|
# edit the $reqs array to point to its parent instead
|
117
118
|
includes.each do |parent, _child, childpath|
|
118
119
|
# Delete the child req if matched
|
119
120
|
$reqs.delete_if do |rid, line, path, _filename, main, chapter|
|
120
|
-
next unless
|
121
|
-
tempreqs.push([rid, line,
|
121
|
+
next unless childpath == path
|
122
|
+
tempreqs.push([rid, line, parent, parent, main, chapter])
|
122
123
|
true
|
123
124
|
end
|
124
125
|
end
|
@@ -180,4 +181,4 @@ Extensions.register do
|
|
180
181
|
(create_anchor parent, final_link, type: :link, target: uri).convert
|
181
182
|
end
|
182
183
|
end
|
183
|
-
end
|
184
|
+
end
|
data/lib/html_chunker.rb
CHANGED
@@ -87,20 +87,20 @@ class MultipageHtml5Converter
|
|
87
87
|
|
88
88
|
def write(output, target)
|
89
89
|
outdir = ::File.dirname target
|
90
|
-
puts '[
|
90
|
+
puts '[ASPEC] Generating chapters'
|
91
91
|
@documents.each do |doc|
|
92
92
|
filename = doc.attr 'docname'
|
93
93
|
filename = filename.sub(/^_/, '')
|
94
94
|
outfile = ::File.join outdir, %(#{filename}.html)
|
95
|
-
puts "[CHAPTER] #{outfile}"
|
96
95
|
::File.open(outfile, 'w') do |f|
|
97
96
|
f.write doc.convert
|
98
97
|
end
|
99
98
|
end
|
100
|
-
puts "[HTML INDEX] Generating index at #{target}"
|
101
99
|
::File.open(target, 'w') do |f|
|
102
100
|
f.write output
|
103
101
|
end
|
102
|
+
puts '[ASPEC] Done'
|
103
|
+
puts "[ASPEC] Index generated at #{target}"
|
104
104
|
load 'postprocessors/generate_toc.rb'
|
105
105
|
load 'postprocessors/fulltext_search.rb'
|
106
106
|
end
|
@@ -1,19 +1,17 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'nokogiri'
|
4
2
|
require 'fileutils'
|
5
|
-
require 'open-uri'
|
6
3
|
require_relative '../extensions/utils/utils'
|
7
4
|
|
8
5
|
@json = ''
|
9
6
|
gendir = 'generated-docs' # TODO: - do not hardcode
|
10
7
|
|
11
8
|
html_files = Dir.glob("#{gendir}/**/*.html")
|
9
|
+
puts "[ASPEC] Creating full-text search index."
|
12
10
|
|
13
11
|
def add_heading(subsection, url, level)
|
14
12
|
id = subsection.at(level).attr('id')
|
15
13
|
sub_url = url + '#' + id
|
16
|
-
@json
|
14
|
+
@json << Search.add_to_index(sub_url, id, subsection.at(level).text, subsection.text)
|
17
15
|
end
|
18
16
|
|
19
17
|
html_files.each do |file|
|
@@ -27,25 +25,21 @@ html_files.each do |file|
|
|
27
25
|
page.xpath("//div[@class='sect1']").each do |section|
|
28
26
|
if section.at_css('div.sect2')
|
29
27
|
|
28
|
+
# consider xpath for multiple cases - be more specific in the query, dont have so many nested ifs
|
30
29
|
section.xpath("//div[@class='sect2' or @class='sect2 language-n4js']").each do |subsection|
|
31
30
|
if subsection.at_css('div.sect3')
|
32
31
|
|
33
32
|
section.xpath("//div[@class='sect3']").each do |subsection|
|
34
|
-
|
35
|
-
add_heading(subsection, url, 'h5')
|
36
|
-
else
|
37
|
-
add_heading(subsection, url, 'h4')
|
38
|
-
end
|
33
|
+
add_heading(subsection, url, 'h4')
|
39
34
|
end
|
40
35
|
|
41
36
|
else
|
42
37
|
add_heading(subsection, url, 'h3')
|
43
38
|
end
|
44
39
|
end
|
45
|
-
|
46
40
|
else
|
47
41
|
text = section.xpath("//div[@class='sect1' or @class='sect1 language-n4js']").css('p').text
|
48
|
-
@json
|
42
|
+
@json << Search.add_to_index(url, slug, title, text)
|
49
43
|
end
|
50
44
|
end
|
51
45
|
end
|
@@ -67,3 +61,5 @@ filtered_data = data.sub(marker, jsonindex)
|
|
67
61
|
File.open(searchpage, 'w') do |f|
|
68
62
|
f.write(filtered_data)
|
69
63
|
end
|
64
|
+
|
65
|
+
puts "[ASPEC] Full-text search index built."
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require 'nokogiri'
|
4
2
|
require 'open-uri'
|
5
3
|
|
@@ -25,9 +23,8 @@ appendices = []
|
|
25
23
|
|
26
24
|
html_files.each do |file|
|
27
25
|
next if file == "#{gendir}/search.html" || file[%r{^#{gendir}\/index}]
|
28
|
-
if file == "#{gendir}/revision_history.html"
|
29
|
-
|
30
|
-
end
|
26
|
+
toc << %(<li><a href="revision_history.html">Revision History</a></li>) if file == "#{gendir}/revision_history.html"
|
27
|
+
|
31
28
|
page = Nokogiri::HTML(open(file))
|
32
29
|
filename = file.sub(%r{^#{gendir}\/}, '')
|
33
30
|
|
@@ -78,7 +75,7 @@ anchors.each do |file, id, text, level|
|
|
78
75
|
if level > prev_level
|
79
76
|
if i != 0
|
80
77
|
toc = toc.chomp("</li>\n")
|
81
|
-
toc
|
78
|
+
toc << " <a href=\"#\" data-toggle=\"collapse\" data-target=\"#tocnav_#{id}\"><i class=\"fa fa-plus-square\" aria-hidden=\"true\"></i></a><ul>
|
82
79
|
<div id=\"tocnav_#{id}\" class=\"collapse\">
|
83
80
|
<li><a href=\"#{file}##{id}\">#{text}</a></li>\n"
|
84
81
|
li = ''
|
@@ -87,16 +84,17 @@ anchors.each do |file, id, text, level|
|
|
87
84
|
# Close nested <ul> elements
|
88
85
|
elsif level < prev_level
|
89
86
|
diff = prev_level - level
|
90
|
-
diff.times { toc
|
87
|
+
diff.times { toc << "</div></ul>\n" }
|
91
88
|
end
|
89
|
+
|
92
90
|
i += 1
|
93
|
-
toc
|
91
|
+
toc << li
|
94
92
|
# assign a variable with current level to compare in next iteration
|
95
93
|
prev_level = level
|
96
94
|
end
|
97
95
|
|
98
96
|
# Close the toc
|
99
|
-
toc
|
97
|
+
toc << '</ul>'
|
100
98
|
|
101
99
|
html_files.each do |fi|
|
102
100
|
file = fi.sub(%r{#{gendir}\/}, '')
|
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.15
|
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-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.7.
|
137
|
+
rubygems_version: 2.7.7
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Asciidoctor extensions for large HTML documents
|