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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74bc1e1a248d3671df75c73837618c84f6af4343
4
- data.tar.gz: 6c0e8b24415954e6b8d1fba0d3790649b7f2b67b
3
+ metadata.gz: 0afc1da878314d89be5c796fa7267d6c6b398db2
4
+ data.tar.gz: 719b5c319e30eb964ed3ccba41ea12d66a29fa56
5
5
  SHA512:
6
- metadata.gz: 34690448559fd2b64a3e8cc7038345673b6a0b51c8b02a0332f49adceaa8557f5d980b1064c2f13060c39098f19ea5ff11553f1c4f976c2e3f50d08b2630a80e
7
- data.tar.gz: 7d004d0a4c9ba6042657f111c75944171855aca0486fb8b449b6a08b9035dba5514698d95eb06761077be19bec879b5f63eb688666542029baa4cc4101c5be30
6
+ metadata.gz: bf4f4e382abf729f92a5ec609e03edb1ecdff09205e495b1e758b829241004c085407ff3c5ca89c5dedd8223bee66de66a79a355116f21d55dcb22dbc40f0478
7
+ data.tar.gz: dc00fb2199e5c32a2dd10feda3421d741a8bd7d57ca81699f3b7dcc77c396cd7104ab8604c7d63f718a44e2ca0d622afeee8047819b1588314543a977047d49c
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll_aspec (1.0.6)
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.0)
12
- rake (12.1.0)
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.pre.3
26
+ 1.16.0
@@ -7,59 +7,67 @@ include ::Asciidoctor
7
7
  adoc_files = Dir.glob('**/*.adoc')
8
8
  invoc = Dir.pwd
9
9
 
10
- # Make some arrays available
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!(/_docs\//, '')
20
- s.gsub!(/(\.adoc|\.md|\.html)/, '')
14
+ s = s.gsub(/^_docs\//, '')
15
+ s = s.gsub(/(\.adoc|\.md|\.html)/, '')
21
16
  end
22
17
 
23
18
  def targetify(t)
24
- # make all chars lowercase and substitute spaces with hyphens
25
- t.downcase.gsub(/\s/, '-')
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>> exluding Requirements
42
+ # Match all <<xrefs>> (Excluding Requirements! - handled separately)
35
43
  if li[/\<\<(?!Req)(.+?)\>\>/]
36
44
 
37
- text = ''
38
- target = ''
39
- path = trim(file_name)
40
- xref = li.chop.match(/\<\<(?!Req)(\S.+?)\>\>/i).captures[0].to_s
41
-
42
- if xref[/,/]
43
- target = xref.downcase.gsub(/,.+/, '').gsub(/\s/, '-')
44
- text = xref.gsub(/.+,/, '').lstrip!
45
- xref = xref.sub(/,.+/, '')
46
- path = file_name
47
- else
48
- target = xref.downcase.gsub(/\s/, '-')
49
- text = xref
50
- end
51
-
52
- item = [xref, path, file_name, text, target]
53
- xrefs.push item
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
- # Match .Titles and = Section Titles
63
+ # Match Block .Titles and = Section Titles
56
64
  elsif li[/(^(\.\S\w+)|^(\=+\s+?\S+.+))/]
57
65
 
58
- # Add check if none found (captures nil)
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
- path = trim(file_name)
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, _tdisp|
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 the paths are not the same (xref and title not the same document) do the following
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
- # puts "Title \"#{ttext}\" in #{tfile} - mismatched xref \"#{xref}\" to different doc - #{xpath}"
96
-
97
- xtform = targetify(xtarget)
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
- i = 0
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
- mismatches.each do |xref, xtarget, xtext, _xpath, _xfile, _ttext, _tpath, _tfile, _relpath|
133
- # check if the line contains the original xref
134
-
135
- next unless li[/\<\<#{xref}(,.+)?\>\>/]
136
- fixes.each do |x|
137
- if x[/#{xtarget}/]
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
- replacement = li.sub(/\<\<#{xref}(,.+)?\>\>/, "icon:expand[] <<#{x}#{t}>> ")
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
@@ -33,7 +33,7 @@ Extensions.register do
33
33
  end
34
34
 
35
35
  if pattern.nil?
36
- warn "asciidoctor: WARNING: Task pattern not defined for #{target}"
36
+ warn "asciidoctor: WARNING: Task pattern not defined for #{target.delete(':')}"
37
37
  pattern = 'unknown'
38
38
  end
39
39
 
@@ -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
@@ -2,5 +2,5 @@
2
2
  module JekyllAspec
3
3
  # After updating the version, publishing can be done by running
4
4
  # rake release in the project root
5
- VERSION = '1.0.6'.freeze
5
+ VERSION = '1.0.7'.freeze
6
6
  end
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.6
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-10-26 00:00:00.000000000 Z
11
+ date: 2017-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler