jekyll_aspec 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/lib/extensions/autoxrefs.rb +67 -62
- data/lib/extensions/inline_task_macro.rb +1 -1
- data/lib/extensions/requirement_appendix.rb +1 -1
- data/lib/jekyll_aspec/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0afc1da878314d89be5c796fa7267d6c6b398db2
|
4
|
+
data.tar.gz: 719b5c319e30eb964ed3ccba41ea12d66a29fa56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf4f4e382abf729f92a5ec609e03edb1ecdff09205e495b1e758b829241004c085407ff3c5ca89c5dedd8223bee66de66a79a355116f21d55dcb22dbc40f0478
|
7
|
+
data.tar.gz: dc00fb2199e5c32a2dd10feda3421d741a8bd7d57ca81699f3b7dcc77c396cd7104ab8604c7d63f718a44e2ca0d622afeee8047819b1588314543a977047d49c
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jekyll_aspec (1.0.
|
4
|
+
jekyll_aspec (1.0.7)
|
5
5
|
asciidoctor (>= 1.5.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
asciidoctor (1.5.6.1)
|
11
|
-
power_assert (1.1.
|
12
|
-
rake (12.1
|
11
|
+
power_assert (1.1.1)
|
12
|
+
rake (12.2.1)
|
13
13
|
test-unit (3.2.6)
|
14
14
|
power_assert
|
15
15
|
|
@@ -23,4 +23,4 @@ DEPENDENCIES
|
|
23
23
|
test-unit (>= 3.2.6)
|
24
24
|
|
25
25
|
BUNDLED WITH
|
26
|
-
1.16.0
|
26
|
+
1.16.0
|
data/lib/extensions/autoxrefs.rb
CHANGED
@@ -7,59 +7,67 @@ include ::Asciidoctor
|
|
7
7
|
adoc_files = Dir.glob('**/*.adoc')
|
8
8
|
invoc = Dir.pwd
|
9
9
|
|
10
|
-
|
11
|
-
titles = []
|
12
|
-
anchors = []
|
13
|
-
xrefs = []
|
14
|
-
mismatches = []
|
15
|
-
|
10
|
+
titles, xrefs, mismatches = [], [], []
|
16
11
|
replacement = ''
|
17
12
|
|
18
13
|
def trim(s)
|
19
|
-
s.gsub
|
20
|
-
s.gsub
|
14
|
+
s = s.gsub(/^_docs\//, '')
|
15
|
+
s = s.gsub(/(\.adoc|\.md|\.html)/, '')
|
21
16
|
end
|
22
17
|
|
23
18
|
def targetify(t)
|
24
|
-
|
25
|
-
|
19
|
+
t.downcase.gsub(/(\s|-)/, '_')
|
20
|
+
end
|
21
|
+
|
22
|
+
def underscorify(t)
|
23
|
+
t = t.downcase.gsub(/(\s|-)/, '_')
|
24
|
+
t = t.prepend('_') unless t.match(/^_/)
|
25
|
+
t = t.gsub(/___/, '_').delete('`')
|
26
|
+
end
|
27
|
+
|
28
|
+
def titleify(t)
|
29
|
+
t = t.gsub(/\_/, ' ')
|
30
|
+
t = t.lstrip
|
31
|
+
t = t.split.map(&:capitalize).join(' ')
|
26
32
|
end
|
27
33
|
|
28
34
|
adoc_files.each do |file_name|
|
29
35
|
lc = 0
|
30
36
|
|
31
37
|
File.read(file_name).each_line do |li|
|
38
|
+
h1 = false
|
32
39
|
lc += 1
|
40
|
+
path = trim(file_name)
|
33
41
|
|
34
|
-
# Match all <<xrefs>>
|
42
|
+
# Match all <<xrefs>> (Excluding Requirements! - handled separately)
|
35
43
|
if li[/\<\<(?!Req)(.+?)\>\>/]
|
36
44
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
num_refs = li.scan(/(?=\<\<(?!Req)(.+?)\>\>)/).count
|
46
|
+
|
47
|
+
li.scan(/(?=\<\<(?!Req)(.+?)\>\>)/) {|xref|
|
48
|
+
xref = xref[0].to_s
|
49
|
+
text, target = '', ''
|
50
|
+
#xref = xref.chop.match(/\<\<(?!Req)(\S.+?)\>\>/i).captures[0].to_s
|
51
|
+
if xref[/,/]
|
52
|
+
target = xref.gsub(/,.+/, '').gsub(/\s/, '-')
|
53
|
+
text = xref.gsub(/.+,/, '').lstrip
|
54
|
+
xref = xref.sub(/,.+/, '')
|
55
|
+
else
|
56
|
+
target = xref.gsub(/\s/, '-')
|
57
|
+
text = xref
|
58
|
+
end
|
59
|
+
item = [xref, path, file_name, text, target]
|
60
|
+
xrefs.push item
|
61
|
+
}
|
54
62
|
|
55
|
-
|
63
|
+
# Match Block .Titles and = Section Titles
|
56
64
|
elsif li[/(^(\.\S\w+)|^(\=+\s+?\S+.+))/]
|
57
65
|
|
58
|
-
|
66
|
+
h1 = true if li[/^(\=+\s+?\S+.+)/]
|
59
67
|
title = li.chop.match(/(?!=+\s)(\S+.+?)$/i).captures[0]
|
60
68
|
title.sub!(/\.(?=\w+?)/, '') if title[/\.(?=\w+?)/]
|
61
|
-
|
62
|
-
item = [title, path, file_name]
|
69
|
+
title = title.strip
|
70
|
+
item = [title, path, file_name, underscorify(title).strip, h1]
|
63
71
|
titles.push item
|
64
72
|
|
65
73
|
# Match [[anchors]]
|
@@ -73,7 +81,6 @@ adoc_files.each do |file_name|
|
|
73
81
|
text = anchor.sub(/.+?,/, '')
|
74
82
|
text = text.sub(/\]\]$/, '')
|
75
83
|
end
|
76
|
-
path = trim(file_name)
|
77
84
|
item = [anchor, path, file_name, text]
|
78
85
|
titles.push item
|
79
86
|
|
@@ -84,19 +91,18 @@ end
|
|
84
91
|
# Run through each xref and check for matching titles
|
85
92
|
xrefs.each do |xref, xpath, xfile, xtext, xtarget|
|
86
93
|
# check xrefs against titles
|
87
|
-
titles.each do |ttext, tpath, tfile,
|
88
|
-
# puts "checking #{ttext} against #{xref}"
|
89
|
-
next unless ttext == xref
|
90
|
-
# puts "MATCHED #{ttext} with #{xref}"
|
94
|
+
titles.each do |ttext, tpath, tfile, alt, h1|
|
91
95
|
|
92
|
-
# If
|
96
|
+
# IMPORTANT - If unnecessary matches are made here, there are exponentially large performance knocks
|
97
|
+
# xrefs / alt / title text must be handled properly
|
98
|
+
next unless ttext == xtext || ttext == xref || alt == xref || alt == xtarget
|
93
99
|
next unless tpath != xpath
|
94
100
|
tpath = 'index' if tpath.to_s.empty?
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
detail = [xref, xtarget, xtext, xpath, xfile, ttext, tpath, tfile, xtform]
|
101
|
+
xtform = underscorify(xtarget) if h1
|
102
|
+
xfile = trim(xfile)
|
103
|
+
detail = [xref, xtarget, xtext, xpath, xfile, ttext, tpath, tfile, xtform, alt, h1]
|
99
104
|
mismatches.push detail
|
105
|
+
|
100
106
|
end
|
101
107
|
end
|
102
108
|
|
@@ -104,23 +110,20 @@ Extensions.register do
|
|
104
110
|
preprocessor do
|
105
111
|
process do |document, reader|
|
106
112
|
fixes = []
|
107
|
-
|
108
|
-
|
109
|
-
# Block is loaded once per document!!!
|
110
|
-
# for each malformed xref
|
111
|
-
mismatches.each do |_xref, _xtarget, xtext, _xpath, xfile, _ttext, _tpath, tfile, xtform|
|
112
|
-
# FIXME: This directory is empty in POSTS - breaks conversion
|
113
|
+
|
114
|
+
mismatches.each do |_xref, _xtarget, xtext, _xpath, xfile, _ttext, _tpath, tfile, xtform, alt, h1|
|
113
115
|
docfile = document.attributes['docfile'].sub(/^#{invoc}\//, '')
|
114
116
|
trim(docfile)
|
115
|
-
|
116
117
|
next unless docfile.to_s == xfile
|
117
|
-
|
118
118
|
# calculate the relative path between source and target
|
119
|
+
# TODO - abstract the following
|
119
120
|
first = Pathname.new xfile.to_s
|
120
121
|
second = Pathname.new tfile.to_s
|
121
122
|
relpath = second.relative_path_from first
|
122
|
-
|
123
123
|
relpath = relpath.sub(/^\.\.\//, '') if docfile == 'index'
|
124
|
+
xtform = _xref if xtform.to_s.empty?
|
125
|
+
xtform = underscorify(xtform) if xtform[/\s/] || h1
|
126
|
+
xtext = titleify(xtext) if xtext[/\_/]
|
124
127
|
fix = "#{relpath}/index##{xtform},#{xtext}"
|
125
128
|
fixes.push fix
|
126
129
|
end
|
@@ -128,24 +131,26 @@ Extensions.register do
|
|
128
131
|
Reader.new reader.readlines.map { |li|
|
129
132
|
# If the line contains an xref (not to requirements)
|
130
133
|
if li[/\<\<(?!Req)(.+?)\>\>/]
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
134
|
+
num_refs = li.scan(/(?=\<\<(?!Req)(.+?)\>\>)/).count
|
135
|
+
num_refs.times do
|
136
|
+
mismatches.each do |xref, xtarget, xtext, _xpath, _xfile, _ttext, _tpath, _tfile, _relpath, alt, h1|
|
137
|
+
# check if the line contains the original xref
|
138
|
+
next unless li[/\<\<#{xref}(,.+)?\>\>/]
|
139
|
+
alt = xref if alt.to_s.empty?
|
140
|
+
fixes.each do |x|
|
141
|
+
next unless x[/(#{xtarget}|#{alt})/]
|
138
142
|
t = xref if xtext.to_s.empty?
|
139
|
-
|
143
|
+
x = x.gsub(/_docs\//, '')
|
144
|
+
x = x.gsub(/(\.adoc|\.md|\.html)/, '')
|
145
|
+
#x = x.sub(/(?!=index.html#).+/, '') if h1
|
146
|
+
li = li.sub(/\<\<#{xref}(,.+)?\>\>/, "icon:expand[] <<#{x}#{t}>> ")
|
147
|
+
replacement = li
|
140
148
|
end
|
141
149
|
end
|
142
|
-
i += 1
|
143
150
|
end
|
144
|
-
|
145
151
|
else
|
146
152
|
replacement = ''
|
147
153
|
end
|
148
|
-
|
149
154
|
if replacement.to_s.empty?
|
150
155
|
li
|
151
156
|
else
|
@@ -95,7 +95,7 @@ reqs.each do |req, f, title, chapter, doctitle|
|
|
95
95
|
link = "#{f}/index##{id}"
|
96
96
|
ref = "<a class=\"link\" href=\"#{link}\"><emphasis role=\"strong\">#{title}</emphasis> </a>"
|
97
97
|
breadcrumb = "<a href=\"#{f}\">#{chapter} / #{doctitle}</a>"
|
98
|
-
row = "<tr> <th scope=\"row\">#{i}</th> <td>#{id}</td><td>#{version}</td> <td>#{ref}</td> <td>#{breadcrumb}</td> </tr>"
|
98
|
+
row = "<tr> <th scope=\"row\">#{i}</th> <td style=\"white-space:pre;\">#{id}</td><td>#{version}</td> <td>#{ref}</td> <td>#{breadcrumb}</td> </tr>"
|
99
99
|
|
100
100
|
rows.push(row)
|
101
101
|
end
|
data/lib/jekyll_aspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_aspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bsmith-n4
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|