jekyll_aspec 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.travis.yml +1 -1
- data/Gemfile +2 -2
- data/Gemfile.lock +1 -1
- data/README.md +10 -10
- data/Rakefile +8 -1
- data/bin/console +3 -3
- data/jekyll_aspec.gemspec +18 -18
- data/lib/extensions/autoxrefs.rb +103 -5
- data/lib/extensions/html_postprocessor.rb +1 -2
- data/lib/extensions/inline_callout_macro.rb +1 -1
- data/lib/extensions/inline_cwiki_macro.rb +8 -5
- data/lib/extensions/inline_repo_macro.rb +29 -23
- data/lib/extensions/inline_task_macro.rb +2 -2
- data/lib/extensions/replace_regex.rb +0 -3
- data/lib/extensions/req_refs.rb +32 -47
- data/lib/extensions/requirement_appendix.rb +116 -0
- data/lib/extensions/requirement_block.rb +45 -50
- data/lib/extensions/todo_block.rb +10 -16
- data/lib/extensions/utils/block.rb +21 -11
- data/lib/extensions/utils/labels.rb +9 -9
- data/lib/jekyll_aspec.rb +11 -20
- data/lib/jekyll_aspec/version.rb +2 -2
- metadata +9 -14
- data/docs/inline-task.adoc +0 -34
- data/docs/requirement-block.adoc +0 -56
- data/docs/todo-block.adoc +0 -48
- data/lib/extensions/req_preprocessor.rb +0 -23
- data/lib/extensions/requirement_block_macro.rb +0 -28
- data/lib/extensions/utils/req_macro_walker.rb +0 -110
- data/lib/extensions/utils/xref_helper.rb +0 -122
@@ -1,122 +0,0 @@
|
|
1
|
-
# Helper methods for common xref processing.
|
2
|
-
#
|
3
|
-
module Xrefs
|
4
|
-
# Trims a path of a given source document to exclude the docs directory
|
5
|
-
# and file extension. This is used to calculate the target directory
|
6
|
-
# of generated HTML files given default permalink settings.
|
7
|
-
#
|
8
|
-
# @param path [String] the path of the source document relative to the project root
|
9
|
-
# @return [String] the formatted path
|
10
|
-
def self.trim(path)
|
11
|
-
trimmed = path.gsub(/_docs\//, '')
|
12
|
-
trimmed.gsub(/(\.adoc|\.md|\.html)/, '')
|
13
|
-
end
|
14
|
-
|
15
|
-
# Formats a string to be permalink-friendly. This simply
|
16
|
-
# downcases the string an substitutes spaces with hyphens. This is
|
17
|
-
# typically used for section titles and document titles to generate
|
18
|
-
# a cross-reference to an anchor.
|
19
|
-
#
|
20
|
-
# @param path [String] the path of the source document relative to the project root
|
21
|
-
# @return [String] the formatted path
|
22
|
-
def self.targetify(path)
|
23
|
-
path.downcase.gsub(/\s/, '-')
|
24
|
-
end
|
25
|
-
|
26
|
-
# Recursively globs all files with the .adoc extension and matches cross-references,
|
27
|
-
# section titles and anchors. Cross-references to Requirements are excluded and handled
|
28
|
-
# in their own processor as they are a special case (i.e., there is no built-in support).
|
29
|
-
#
|
30
|
-
# @return [String] the formatted path
|
31
|
-
def self.list_xrefs
|
32
|
-
|
33
|
-
# @todo Maybe don't do this. Find a better way to process
|
34
|
-
# all .adoc files before extensions are loaded.
|
35
|
-
adoc_files = Dir.glob('**/*.adoc')
|
36
|
-
|
37
|
-
# Make some arrays available
|
38
|
-
titles = []
|
39
|
-
anchors = []
|
40
|
-
xrefs = []
|
41
|
-
mismatches = []
|
42
|
-
|
43
|
-
replacement = ''
|
44
|
-
|
45
|
-
adoc_files.each do |file_name|
|
46
|
-
lc = 0
|
47
|
-
|
48
|
-
File.read(file_name).each_line do |li|
|
49
|
-
lc += 1
|
50
|
-
|
51
|
-
# @note Matches all <<xrefs>> except Requirements
|
52
|
-
if li[/\<\<(?!Req)(.+?)\>\>/]
|
53
|
-
|
54
|
-
text = ''
|
55
|
-
target = ''
|
56
|
-
path = trim(file_name)
|
57
|
-
xref = li.chop.match(/\<\<(?!Req)(\S.+?)\>\>/i).captures[0].to_s
|
58
|
-
|
59
|
-
# @note Checks if the xref has display text, i.e. '<<title-1,Lovely Display Text>>'
|
60
|
-
if xref[/,/]
|
61
|
-
# @todo Use helper methods.
|
62
|
-
target = xref.downcase.gsub(/,.+/, '').gsub(/\s/, '-')
|
63
|
-
text = xref.gsub(/.+,/, '').lstrip!
|
64
|
-
xref = xref.sub(/,.+/, '')
|
65
|
-
path = file_name
|
66
|
-
else
|
67
|
-
# @todo Use helper methods.
|
68
|
-
target = xref.downcase.gsub(/\s/, '-')
|
69
|
-
text = xref
|
70
|
-
end
|
71
|
-
|
72
|
-
item = [xref, path, file_name, text, target]
|
73
|
-
xrefs.push item
|
74
|
-
|
75
|
-
# Match .Titles and = Section Titles
|
76
|
-
elsif li[/(^(\.\S\w+)|^(\=+\s+?\S+.+))/]
|
77
|
-
|
78
|
-
# Add check if none found (captures nil)
|
79
|
-
title = li.chop.match(/(?!=+\s)(\S+.+?)$/i).captures[0]
|
80
|
-
title.sub(/\.(?=\w+?)/, '') if title[/\.(?=\w+?)/]
|
81
|
-
path = trim(file_name)
|
82
|
-
item = [title, path, file_name]
|
83
|
-
titles.push item
|
84
|
-
|
85
|
-
# Match [[anchors]]
|
86
|
-
elsif li[/\[\[.+?\]\]/]
|
87
|
-
|
88
|
-
# Add check if none found (captures nil)
|
89
|
-
anchor = li.chop.match(/(?<=\[\[).+?(?=\]\])/).to_s
|
90
|
-
|
91
|
-
if anchor[/,/]
|
92
|
-
anchor = anchor.match(/(?<=\[\[)(?:|[\w+?_:][\w+?:.-]*)(?=,.+?\]\])/).to_s
|
93
|
-
text = anchor.sub(/.+?,/, '')
|
94
|
-
text = text.sub(/\]\]$/, '')
|
95
|
-
end
|
96
|
-
|
97
|
-
path = trim(file_name)
|
98
|
-
item = [anchor, path, file_name, text]
|
99
|
-
# for the moment, just handle anchors similar to titles
|
100
|
-
titles.push item
|
101
|
-
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# Run through each xref and check for matching titles
|
107
|
-
xrefs.each do |xref, xpath, xfile, xtext, xtarget|
|
108
|
-
# check xrefs against titles
|
109
|
-
titles.each do |ttext, tpath, tfile, _tdisp|
|
110
|
-
|
111
|
-
next unless ttext == xref
|
112
|
-
tpath = 'index' if tpath.to_s.empty?
|
113
|
-
# If the paths are not the same (xref and title not the same document) do the following
|
114
|
-
next unless tpath != xpath
|
115
|
-
|
116
|
-
xtform = targetify(xtarget)
|
117
|
-
detail = [xref, xtarget, xtext, xpath, xfile, ttext, tpath, tfile, xtform]
|
118
|
-
mismatches.push detail
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|