middleman-targets 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +21 -0
- data/documentation_project/Gemfile +1 -1
- data/documentation_project/config.rb +1 -1
- data/documentation_project/source/helpers-resources.html.md.erb +3 -6
- data/documentation_project/source/partials/config.erb +334 -288
- data/documentation_project/source/partials/helpers.erb +204 -322
- data/documentation_project/source/partials/helpers_extended.erb +139 -0
- data/documentation_project/source/partials/resources.erb +88 -78
- data/lib/middleman-targets/extension.rb +4 -1
- data/lib/middleman-targets/version.rb +1 -1
- data/yard/readme.md +3 -3
- data/yard/template-grouped/default/module/html/method_details_list.erb +11 -0
- data/yard/template-partials/default/method_details/setup.rb +4 -0
- data/yard/template-partials/default/module/html/method_details_list.erb +11 -0
- data/yard/template-partials/default/module/setup.rb +6 -0
- data/yard/template-partials/default/onefile/html/layout.erb +1 -0
- data/yard/template-partials/default/onefile/html/setup.rb +4 -0
- data/yard/yard_extensions.rb +86 -49
- metadata +10 -11
- data/yard/templates/default/fulldoc/html/css/common.css +0 -1
- data/yard/templates/default/fulldoc/html/css/full_list.css +0 -57
- data/yard/templates/default/fulldoc/html/css/style.css +0 -343
- data/yard/templates/default/onefile/html/files.erb +0 -5
- data/yard/templates/default/onefile/html/headers.erb +0 -6
- data/yard/templates/default/onefile/html/layout.erb +0 -17
- data/yard/templates/default/onefile/html/readme.erb +0 -3
- data/yard/templates/default/onefile/html/setup.rb +0 -61
@@ -0,0 +1,139 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
<div class="method_details_list">
|
7
|
+
|
8
|
+
|
9
|
+
<h2>Extended Helpers</h2>
|
10
|
+
|
11
|
+
<div class="method_details first">
|
12
|
+
<h3 class="signature first" id="image_tag-instance_method">
|
13
|
+
|
14
|
+
- (<tt>Void</tt>) <strong>image_tag</strong>(path, params = {})
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
</h3><div class="docstring">
|
21
|
+
<div class="discussion">
|
22
|
+
<p>Override the built-in <code>image-tag</code> helper in order to
|
23
|
+
support additional features.</p>
|
24
|
+
|
25
|
+
<ul>
|
26
|
+
<li>Automatic target-specific images. Note that this
|
27
|
+
only works on local files, and only if enabled
|
28
|
+
with the option <code>:target_magic_images</code>.</li>
|
29
|
+
<li>Target and feature dependent images using the
|
30
|
+
<code>params</code> hash.</li>
|
31
|
+
<li>Absolute paths, which Middleman sometimes bungles.</li>
|
32
|
+
</ul>
|
33
|
+
|
34
|
+
<p>Note that in addition to the options described below,
|
35
|
+
<code>middleman-targets</code> inherits all of the built-in
|
36
|
+
option parameters as well.</p>
|
37
|
+
|
38
|
+
|
39
|
+
</div>
|
40
|
+
</div>
|
41
|
+
<div class="tags">
|
42
|
+
<p class="tag_title">Parameters:</p>
|
43
|
+
<ul class="param">
|
44
|
+
|
45
|
+
<li>
|
46
|
+
|
47
|
+
<span class='name'>path</span>
|
48
|
+
|
49
|
+
|
50
|
+
<span class='type'>(<tt>String</tt>)</span>
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
—
|
55
|
+
<div class='inline'><p>The path to the image file.</p>
|
56
|
+
</div>
|
57
|
+
|
58
|
+
</li>
|
59
|
+
|
60
|
+
<li>
|
61
|
+
|
62
|
+
<span class='name'>params</span>
|
63
|
+
|
64
|
+
|
65
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
66
|
+
|
67
|
+
|
68
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
69
|
+
|
70
|
+
|
71
|
+
—
|
72
|
+
<div class='inline'><p>Optional parameters to pass to
|
73
|
+
the helper.</p>
|
74
|
+
</div>
|
75
|
+
|
76
|
+
</li>
|
77
|
+
|
78
|
+
</ul>
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<p class="tag_title">Options Hash (<tt>params</tt>):</p>
|
86
|
+
<ul class="option">
|
87
|
+
|
88
|
+
<li>
|
89
|
+
<span class="name">:target</span>
|
90
|
+
<span class="type">(<tt>String</tt>, <tt>Symbol</tt>)</span>
|
91
|
+
<span class="default">
|
92
|
+
|
93
|
+
</span>
|
94
|
+
|
95
|
+
— <div class='inline'><p>This image
|
96
|
+
tag will only be applied if the current target is
|
97
|
+
<code>target</code>.</p>
|
98
|
+
</div>
|
99
|
+
|
100
|
+
</li>
|
101
|
+
|
102
|
+
<li>
|
103
|
+
<span class="name">:feature</span>
|
104
|
+
<span class="type">(<tt>String</tt>, <tt>Symbol</tt>)</span>
|
105
|
+
<span class="default">
|
106
|
+
|
107
|
+
</span>
|
108
|
+
|
109
|
+
— <div class='inline'><p>This image
|
110
|
+
tag will only be applied if the current target
|
111
|
+
enables the feature <code>feature</code>.</p>
|
112
|
+
</div>
|
113
|
+
|
114
|
+
</li>
|
115
|
+
|
116
|
+
</ul>
|
117
|
+
|
118
|
+
|
119
|
+
<p class="tag_title">Returns:</p>
|
120
|
+
<ul class="return">
|
121
|
+
|
122
|
+
<li>
|
123
|
+
|
124
|
+
|
125
|
+
<span class='type'>(<tt>Void</tt>)</span>
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
</li>
|
130
|
+
|
131
|
+
</ul>
|
132
|
+
|
133
|
+
</div>
|
134
|
+
</div>
|
135
|
+
|
136
|
+
|
137
|
+
</div>
|
138
|
+
|
139
|
+
|
@@ -1,100 +1,110 @@
|
|
1
|
-
<div id="instance_method_details" class="method_details_list">
|
2
|
-
<div class="method_details first ">
|
3
|
-
<h3 class="signature first" id="resource.targeted?-instance_method">
|
4
1
|
|
5
|
-
- (<tt>Boolean</tt>) <strong>resource.targeted?</strong>
|
6
2
|
|
7
3
|
|
8
4
|
|
9
5
|
|
6
|
+
<div class="method_details_list">
|
7
|
+
|
8
|
+
|
9
|
+
<h2>Resource Extensions</h2>
|
10
|
+
|
11
|
+
<div class="method_details first">
|
12
|
+
<h3 class="signature first" id="resource.targeted?-instance_method">
|
13
|
+
|
14
|
+
- (<tt>Boolean</tt>) <strong>resource.targeted?</strong>
|
15
|
+
|
10
16
|
|
11
|
-
|
12
|
-
<div class="discussion">
|
17
|
+
|
13
18
|
|
14
|
-
|
15
|
-
|
16
|
-
|
19
|
+
|
20
|
+
</h3><div class="docstring">
|
21
|
+
<div class="discussion">
|
22
|
+
<p>Determines if the resource is eligible for inclusion
|
23
|
+
in the current target based on the front matter data
|
24
|
+
<code>target</code> and <code>exclude</code> fields.</p>
|
17
25
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
<ul>
|
27
|
+
<li>If <strong>frontmatter:target</strong> is used, the target or
|
28
|
+
feature appears in the frontmatter, and</li>
|
29
|
+
<li>If <strong>frontmatter:exclude</strong> is used, the target or
|
30
|
+
enabled feature does NOT appear in the
|
31
|
+
frontmatter</li>
|
32
|
+
</ul>
|
25
33
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
34
|
+
<p>In general you won’t use this resource method because
|
35
|
+
resources will already be excluded before you have a
|
36
|
+
chance to check them, and so any leftover resources
|
37
|
+
will always return <code>true</code> for this method.</p>
|
30
38
|
|
31
39
|
|
32
|
-
</div>
|
33
40
|
</div>
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
</div>
|
42
|
+
<div class="tags">
|
43
|
+
|
44
|
+
<p class="tag_title">Returns:</p>
|
45
|
+
<ul class="return">
|
46
|
+
|
47
|
+
<li>
|
48
|
+
|
49
|
+
|
50
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
—
|
55
|
+
<div class='inline'><p>Returns a value indicating whether
|
56
|
+
or not this resource belongs in the current target.</p>
|
57
|
+
</div>
|
58
|
+
|
59
|
+
</li>
|
60
|
+
|
61
|
+
</ul>
|
44
62
|
|
63
|
+
</div>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<div class="method_details ">
|
67
|
+
<h3 class="signature " id="resource.valid_features-instance_method">
|
68
|
+
|
69
|
+
- (<tt>Array</tt>) <strong>resource.valid_features</strong>
|
70
|
+
|
45
71
|
|
46
|
-
|
47
|
-
<div class='inline'><p>Returns a value indicating whether
|
48
|
-
or not this resource belongs in the current target.</p>
|
49
|
-
</div>
|
72
|
+
|
50
73
|
|
51
|
-
|
74
|
+
|
75
|
+
</h3><div class="docstring">
|
76
|
+
<div class="discussion">
|
77
|
+
<p>Returns an array of valid features for a resource
|
78
|
+
based on the current target, i.e., features that
|
79
|
+
are true for the current target.</p>
|
52
80
|
|
53
|
-
</ul>
|
54
81
|
|
55
|
-
</div>
|
56
82
|
</div>
|
83
|
+
</div>
|
84
|
+
<div class="tags">
|
85
|
+
|
86
|
+
<p class="tag_title">Returns:</p>
|
87
|
+
<ul class="return">
|
88
|
+
|
89
|
+
<li>
|
90
|
+
|
91
|
+
|
92
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
—
|
97
|
+
<div class='inline'><p>Returns an array of features.</p>
|
98
|
+
</div>
|
99
|
+
|
100
|
+
</li>
|
101
|
+
|
102
|
+
</ul>
|
57
103
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
</h3><div class="docstring">
|
68
|
-
<div class="discussion">
|
69
|
-
|
70
|
-
<p>Returns an array of valid features for a resource
|
71
|
-
based on the current target, i.e., features that
|
72
|
-
are true for the current target.</p>
|
73
|
-
|
74
|
-
|
75
|
-
</div>
|
104
|
+
</div>
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
76
108
|
</div>
|
77
|
-
<div class="tags">
|
78
|
-
|
79
|
-
<p class="tag_title">Returns:</p>
|
80
|
-
<ul class="return">
|
81
|
-
|
82
|
-
<li>
|
83
|
-
|
84
109
|
|
85
|
-
<span class='type'>(<tt>Array</tt>)</span>
|
86
110
|
|
87
|
-
|
88
|
-
|
89
|
-
—
|
90
|
-
<div class='inline'><p>Returns an array of features.</p>
|
91
|
-
</div>
|
92
|
-
|
93
|
-
</li>
|
94
|
-
|
95
|
-
</ul>
|
96
|
-
|
97
|
-
</div>
|
98
|
-
</div>
|
99
|
-
|
100
|
-
</div>
|
@@ -169,6 +169,7 @@ class MiddlemanTargets < ::Middleman::Extension
|
|
169
169
|
############################################################
|
170
170
|
# Sitemap manipulators.
|
171
171
|
# Add new methods to each resource.
|
172
|
+
# @visibility private
|
172
173
|
############################################################
|
173
174
|
def manipulate_resource_list(resources)
|
174
175
|
|
@@ -326,6 +327,7 @@ class MiddlemanTargets < ::Middleman::Extension
|
|
326
327
|
# tag will only be applied if the current target
|
327
328
|
# enables the feature `feature`.
|
328
329
|
# @return [Void]
|
330
|
+
# @group Extended Helpers
|
329
331
|
#--------------------------------------------------------
|
330
332
|
def image_tag(path, params={})
|
331
333
|
params.symbolize_keys!
|
@@ -355,13 +357,14 @@ class MiddlemanTargets < ::Middleman::Extension
|
|
355
357
|
end
|
356
358
|
|
357
359
|
super(path, params)
|
358
|
-
end
|
360
|
+
end # @endgroup
|
359
361
|
|
360
362
|
end #helpers
|
361
363
|
|
362
364
|
|
363
365
|
############################################################
|
364
366
|
# Instance Methods
|
367
|
+
# @group Instance Methods
|
365
368
|
############################################################
|
366
369
|
|
367
370
|
|
data/yard/readme.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
This gem provides the ability to generate multiple targets by outfitting
|
2
|
-
|
3
|
-
simple to control content that is specific to each target, based on the
|
4
|
-
name or based on feature sets for each target.
|
2
|
+
**Middleman** with additional command line options. The provided helpers make
|
3
|
+
it simple to control content that is specific to each target, based on the
|
4
|
+
target name or based on feature sets for each target.
|
5
5
|
|
6
6
|
It is standalone and can be used in any **Middleman** project.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% scopes(method_listing(false)) do |list, scope| %>
|
2
|
+
<div id="<%= scope %>_method_details" class="method_details_list">
|
3
|
+
<% groups = list.group_by { |g| g.group.nil? ? 'ZZZ' : g.group }.sort.to_h %>
|
4
|
+
<% groups.each_value do |group| %>
|
5
|
+
<h2><%= group[0].group || "#{scope.to_s.capitalize} Method Details" %></h2>
|
6
|
+
<% group.each_with_index do |meth, i| %>
|
7
|
+
<%= yieldall :object => meth, :owner => object, :index => i %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% scopes(method_listing(false)) do |list, scope| %>
|
2
|
+
<div class="method_details_list">
|
3
|
+
<% groups = list.group_by { |g| g.group.nil? ? 'ZZZ' : g.group }.sort.to_h %>
|
4
|
+
<% groups.each_value do |group| %>
|
5
|
+
<h2><%= group[0].group || "#{scope.to_s.capitalize} Method Details" %></h2>
|
6
|
+
<% group.each_with_index do |meth, i| %>
|
7
|
+
<%= yieldall :object => meth, :owner => object, :index => i %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yieldall %>
|
data/yard/yard_extensions.rb
CHANGED
@@ -1,73 +1,110 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
##########################################################################
|
2
|
+
# Our template groups the methods by @group instead of lumping all of
|
3
|
+
# them together as instance methods. This is because most of them simply
|
4
|
+
# *aren't* instance methods but rather helpers or resource methods.
|
5
|
+
# This template will be used by default because .yardopts loads this
|
6
|
+
# file; however `rake partials` will override this template via the
|
7
|
+
# command line in order to use the `template-partials` instead.
|
8
|
+
##########################################################################
|
9
|
+
YARD::Templates::Engine.register_template_path File.join(File.dirname(__FILE__), 'template-grouped')
|
3
10
|
|
11
|
+
|
12
|
+
##########################################################################
|
4
13
|
# Force Yard to parse the helpers block in a Middleman extension.
|
5
|
-
#
|
6
|
-
#
|
14
|
+
#
|
15
|
+
# * Assign a generic "Helpers" group to each item if they don't have
|
16
|
+
# their own @group assignment. Note that @!group doesn't work in this
|
17
|
+
# section.
|
18
|
+
# * Add a @note to each item to distinguish them in a mixed up instance
|
19
|
+
# method detail section.
|
20
|
+
##########################################################################
|
7
21
|
class HelpersHandler < YARD::Handlers::Ruby::Base
|
8
22
|
handles method_call(:helpers)
|
9
23
|
namespace_only
|
10
24
|
|
11
25
|
def process
|
12
|
-
extra = <<HEREDOC
|
13
|
-
@note This is not truly an instance method but a **helper** provided by this class.
|
14
|
-
@group Helpers
|
15
|
-
HEREDOC
|
16
26
|
|
17
27
|
statement.last.last.each do |node|
|
18
|
-
node.docstring.gsub!(/^[\-=]+\n/, '').gsub!(/[\-=]+$/, '') << extra
|
19
|
-
parse_block(node, :owner => self.owner)
|
20
|
-
end
|
21
|
-
end
|
22
28
|
|
23
|
-
|
24
|
-
hash = {}
|
25
|
-
return hash unless node
|
29
|
+
extra = ''
|
26
30
|
|
27
|
-
|
28
|
-
|
31
|
+
# Find out if there's a @group assigned.
|
32
|
+
extra << '@group Helpers' unless node.docstring.match(/^@group (.*?)$/i)
|
33
|
+
|
34
|
+
# Clean up the doc string because we like - and = borders.
|
35
|
+
# Force the note and group on each of these "fake" methods.
|
36
|
+
if node.docstring
|
37
|
+
docstring = node.docstring
|
38
|
+
docstring = docstring.gsub(/^[\-=]+\n/, '')
|
39
|
+
docstring = docstring.gsub(/[\-=]+$/, '')
|
40
|
+
docstring << extra
|
41
|
+
node.docstring = docstring
|
42
|
+
else
|
43
|
+
node.docstring = extra
|
44
|
+
end
|
45
|
+
|
46
|
+
parse_block(node, :owner => self.owner)
|
47
|
+
end # do
|
29
48
|
|
30
|
-
|
31
|
-
.each { |c| c.strip! }
|
32
|
-
hash[components[0]] = components[1]
|
33
|
-
end
|
49
|
+
end # def
|
34
50
|
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
51
|
+
end # class
|
38
52
|
|
39
53
|
|
54
|
+
##########################################################################
|
40
55
|
# Force Yard to parse the resources.each block in a Middleman extension.
|
41
|
-
#
|
42
|
-
#
|
56
|
+
#
|
57
|
+
# * Assign a generic "Resource Extensions" group to each item if they
|
58
|
+
# don't have their own @group assignment. Note that @!group
|
59
|
+
# doesn't work in this section.
|
60
|
+
# * Force each item to have a `@visibility public` because we will
|
61
|
+
# probably have `@visibility private` in the wrapping method.
|
62
|
+
# * Add a @note to each item to distinguish them in a mixed up instance
|
63
|
+
# method detail section.
|
64
|
+
##########################################################################
|
43
65
|
class ResourcesHandler < YARD::Handlers::Ruby::Base
|
44
66
|
handles :def
|
45
67
|
namespace_only
|
46
68
|
|
47
69
|
def process
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
object[:group] = 'Resource Extensions'
|
70
|
+
extra = <<HEREDOC
|
71
|
+
@visibility public
|
72
|
+
HEREDOC
|
73
|
+
|
74
|
+
return unless statement.method_name(true).to_sym == :manipulate_resource_list
|
75
|
+
|
76
|
+
# Block consists of everything in the actual `do` block
|
77
|
+
block = statement.last.first.last.last
|
78
|
+
block.each do | node |
|
79
|
+
if node.type == :defs
|
80
|
+
# Clean up the doc string because we like - and = borders.
|
81
|
+
# Force the note and public on each of these "fake" methods.
|
82
|
+
if node.docstring
|
83
|
+
docstring = node.docstring
|
84
|
+
docstring = docstring.gsub(/^[\-=]+\n/, '')
|
85
|
+
docstring = docstring.gsub(/[\-=]+$/, '')
|
86
|
+
docstring << extra
|
87
|
+
else
|
88
|
+
docstring = extra
|
68
89
|
end
|
90
|
+
|
91
|
+
# Find out if there's a @group assigned.
|
92
|
+
if ( group = docstring.match(/^@group (.*?)$/i) )
|
93
|
+
group = group[1]
|
94
|
+
else
|
95
|
+
group = 'Resource Extensions'
|
96
|
+
end
|
97
|
+
|
98
|
+
def_name = node[2][0]
|
99
|
+
object = YARD::CodeObjects::MethodObject.new(namespace, "resource.#{def_name}")
|
100
|
+
register(object)
|
101
|
+
object.dynamic = true
|
102
|
+
object.source = node.source.clone
|
103
|
+
object[:docstring] = docstring
|
104
|
+
object[:group] = group
|
69
105
|
end
|
106
|
+
end # do
|
107
|
+
|
108
|
+
end # def
|
70
109
|
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
110
|
+
end # class
|