middleman-targets 1.0.3 → 1.0.4

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -0
  3. data/.yardopts +9 -0
  4. data/CHANGELOG.md +7 -0
  5. data/README.md +21 -4
  6. data/Rakefile +12 -6
  7. data/documentation_project/Gemfile +1 -1
  8. data/documentation_project/config.rb +7 -7
  9. data/documentation_project/source/helpers-resources.html.md.erb +14 -66
  10. data/documentation_project/source/partials/config.erb +326 -0
  11. data/documentation_project/source/partials/helpers.erb +354 -0
  12. data/documentation_project/source/partials/resources.erb +100 -0
  13. data/documentation_project/source/stylesheets/_middlemac_minimal.scss +283 -1
  14. data/documentation_project/source/target-feature-config.html.md.erb +6 -36
  15. data/features/build_target_option.feature +42 -0
  16. data/features/helpers_and_resources.feature +44 -0
  17. data/features/server_target_option.feature +42 -0
  18. data/features/support/env.rb +20 -0
  19. data/fixtures/middleman_targets_app/config.rb +33 -0
  20. data/fixtures/middleman_targets_app/source/all-root-logo.png +0 -0
  21. data/fixtures/middleman_targets_app/source/all-root.png +0 -0
  22. data/fixtures/middleman_targets_app/source/free-root.png +0 -0
  23. data/fixtures/middleman_targets_app/source/images/all-image.png +0 -0
  24. data/fixtures/middleman_targets_app/source/images/all-logo.png +0 -0
  25. data/fixtures/middleman_targets_app/source/images/free-image.png +0 -0
  26. data/fixtures/middleman_targets_app/source/images/pro-image.png +0 -0
  27. data/fixtures/middleman_targets_app/source/index.html.md.erb +35 -0
  28. data/fixtures/middleman_targets_app/source/pro-root.png +0 -0
  29. data/lib/middleman-targets/extension.rb +182 -54
  30. data/lib/middleman-targets/middleman-cli/build_all.rb +5 -6
  31. data/lib/middleman-targets/version.rb +1 -1
  32. data/middleman-targets.gemspec +9 -2
  33. data/yard/readme.md +6 -0
  34. data/yard/templates/default/fulldoc/html/css/common.css +1 -0
  35. data/yard/templates/default/fulldoc/html/css/full_list.css +57 -0
  36. data/yard/templates/default/fulldoc/html/css/style.css +343 -0
  37. data/yard/templates/default/onefile/html/files.erb +5 -0
  38. data/yard/templates/default/onefile/html/headers.erb +6 -0
  39. data/yard/templates/default/onefile/html/layout.erb +17 -0
  40. data/yard/templates/default/onefile/html/readme.erb +3 -0
  41. data/yard/templates/default/onefile/html/setup.rb +61 -0
  42. data/yard/yard_extensions.rb +73 -0
  43. metadata +83 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 538cbe8f9ebafb3d881145f28ba6a0d8f80e362c
4
- data.tar.gz: 971d1152ee7fd0fd2f875ebfaebc2727fc09ac51
3
+ metadata.gz: 7a0c601e30b8d5beb37283c652cf41790157c314
4
+ data.tar.gz: 5a24bebde45c5a00ea98d9152ae57fc60337ff59
5
5
  SHA512:
6
- metadata.gz: 843728b544dec1b827acf71cc75746f2d215a4ab37dc77328060a7a7e259964a18c0185a4e56f4030e9622fb45bf8de50a072e2b29d59c83c4d0c58fe3e77c34
7
- data.tar.gz: 0a475c0233be66cdc15b41ef43df05793205fb8635a872bd9259c854d3badb17dc24fb4fa194cfe8b8f2ac3d994adfa5770237884b104607dac4765f40b789d2
6
+ metadata.gz: 1f351b50ebaeb1f243ccc6c7a2c2c56681e0c175cc055b6642c18d602dc5de8266f904b33ae0bd13754bbfbbee6471f01065ebc28659694b451fdb5541e16c59
7
+ data.tar.gz: b327da177ded0c89ce0ba06355506d0f2cee7b3bba59da8de80744726bad0d0afadcc6c4b372a35f6344ddee3edb0c6d7c06b354c6bfd90f162008b03d0fde7b
data/.gitignore CHANGED
@@ -15,3 +15,10 @@ Gemfile.lock
15
15
 
16
16
  # Ignore build folders
17
17
  build/*
18
+
19
+ # Yard cruft
20
+ /doc/
21
+ /.yardoc
22
+
23
+ # Aruba
24
+ /tmp/
data/.yardopts ADDED
@@ -0,0 +1,9 @@
1
+ --no-private
2
+ --markup=markdown
3
+ --load yard/yard_extensions.rb
4
+ --exclude middleman-targets/version.rb
5
+ --exclude middleman-targets/commands.rb
6
+ --exclude middleman-targets/middleman-cli/build_all.rb
7
+ --one-file
8
+ --readme yard/readme.md
9
+ --title middleman-targets
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  middleman-targets change log
2
2
  ============================
3
3
 
4
+ - Version 1.0.4 / 2016-April-14
5
+
6
+ - Added Cucumber tests.
7
+ - Added *much* documentation to the extension source in order to
8
+ generate YARD documentation.
9
+ - Improved the documentation sample project to use YARD's output.
10
+
4
11
  - Version 1.0.3 / 2016-April-08
5
12
 
6
13
  - A bit of internal refactoring in order for related gems to be able
data/README.md CHANGED
@@ -71,6 +71,7 @@ Or:
71
71
  bundle exec middleman serve --target mytarget
72
72
  ~~~
73
73
 
74
+
74
75
  Added Features
75
76
  --------------
76
77
 
@@ -89,10 +90,26 @@ available, including
89
90
  - …and more.
90
91
 
91
92
 
93
+ Rake Tasks
94
+ ----------
95
+
96
+ Run tests:
97
+
98
+ ~~~ bash
99
+ rake test
100
+ ~~~
101
+
102
+ Generate YARD documentation:
103
+
104
+ ~~~ bash
105
+ rake yard
106
+ ~~~
107
+
108
+
92
109
  Middlemac
93
110
  ---------
94
111
 
95
- This Middleman extension is a critical part of
112
+ This Middleman extension is a critical part of
96
113
  [Middlemac](https://github.com/middlemac), the Mac OS X help building system
97
114
  for Mac OS X applications. However this gem is not Mac OS X specific and can be
98
115
  useful in any application for which you want to generate multiple targets.
@@ -101,11 +118,11 @@ useful in any application for which you want to generate multiple targets.
101
118
  License
102
119
  -------
103
120
 
104
- MIT. See `LICENSE.md`.
121
+ MIT. See [`LICENSE.md`](LICENSE.md).
105
122
 
106
123
 
107
124
  Changelog
108
125
  ---------
109
126
 
110
- See `CHANGELOG.md` for point changes, or simply have a look at the commit
111
- history for non-version changes (such as readme updates).
127
+ See [`CHANGELOG.md`](CHANGELOG.md) for point changes, or simply have a look at
128
+ the commit history for non-version changes (such as readme updates).
data/Rakefile CHANGED
@@ -1,10 +1,16 @@
1
1
  require 'bundler/gem_tasks'
2
- require 'rake/testtask'
2
+ require 'cucumber/rake/task'
3
+ require 'yard'
3
4
 
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << 'test'
6
- t.libs << 'lib'
7
- t.test_files = FileList['test/**/*_test.rb']
5
+ ENV['GEM_NAME'] = 'middleman-targets'
6
+
7
+ task :default => :test
8
+
9
+ Cucumber::Rake::Task.new(:test, 'Features that must pass') do |task|
10
+ task.cucumber_opts = '--require features --color --tags ~@wip --strict --format QuietFormatter'
8
11
  end
9
12
 
10
- task :default => :spec
13
+
14
+ YARD::Rake::YardocTask.new(:yard) do |task|
15
+ task.stats_options = ['--list-undoc']
16
+ end
@@ -9,6 +9,6 @@ gem 'wdm', '~> 0.1.0', platforms: [:mswin, :mingw]
9
9
  gem 'tzinfo-data', platforms: [:mswin, :mingw, :jruby]
10
10
 
11
11
  # Middleman Gems
12
- gem 'middleman-targets', '~>1.0.3'
12
+ gem 'middleman-targets', '~>1.0.4'
13
13
  gem 'middleman', '~> 4.1.6'
14
14
  gem 'middleman-syntax'
@@ -23,7 +23,7 @@ activate :MiddlemanTargets
23
23
  # Set the default target. This is the target that is used automatically
24
24
  # when you `middleman build` or `middleman server` without using the
25
25
  # `targets` CLI option.
26
- set :target, :pro
26
+ config[:target] = :pro
27
27
 
28
28
  # Setup your targets and their features. You can use any target names and
29
29
  # feature names that you like, but keep in mind that the key :features is
@@ -37,7 +37,7 @@ set :target, :pro
37
37
  # You can add your own keys to each target for your own uses; the
38
38
  # `sample_key` below is an example of such. The generic `target_value()`
39
39
  # helper can retrieve these values, or you can write your own helpers.
40
- set :targets, {
40
+ config[:targets] = {
41
41
  :free =>
42
42
  {
43
43
  :sample_key => 'People who use free versions don\'t drive profits.',
@@ -71,21 +71,21 @@ set :targets, {
71
71
  # Important: when this is enabled, images from *other* targets will *not* be
72
72
  # included in the build! In the example above, *any* image prefixed with "free-"
73
73
  # would not be included in the output directory.
74
- set :target_magic_images, true
75
- set :target_magic_word, 'all'
74
+ config[:target_magic_images] = true
75
+ config[:target_magic_word] = 'all'
76
76
 
77
77
  # Note that output will now use this directory as a *prefix*; if the target
78
78
  # is :pro, then the actual build directory will be `build (pro)/`. If the
79
79
  # build_dir key is present for any of the :targets, they will override this
80
80
  # setting.
81
- set :build_dir, 'build'
81
+ config[:build_dir] = 'build'
82
82
 
83
83
 
84
84
  #==========================================================================
85
85
  # Regular Middleman Setup
86
86
  #==========================================================================
87
87
 
88
- set :relative_links, true
88
+ config[:relative_links] = true
89
89
  activate :syntax
90
90
 
91
91
 
@@ -103,7 +103,7 @@ helpers do
103
103
  end
104
104
 
105
105
  def product_version
106
- '1.0.3'
106
+ '1.0.4'
107
107
  end
108
108
 
109
109
  def product_uri
@@ -9,82 +9,30 @@ layout: template-logo-medium
9
9
  working with multiple targets easier.
10
10
 
11
11
 
12
- ## Resources
13
-
14
- Middleman’s resource list is available to all of your templates and pages, and
15
- also available for your own helpers, and `middleman-targets` provides a couple
16
- of resource map additions than can prove useful when developing your own
17
- helpers.
18
-
19
- `valid_features`
20
-
21
- : `valid_features` returns an array of features that are enabled and applicable
22
- to the current build target. Although available for output in your pages,
23
- this is probably most useful for developing your own helpers.
24
-
25
- By way of example, the raw output of `<%%= current_page.valid_features %>`
26
- on this page is `<%= current_page.valid_features %>`. The output will be
27
- different if you switch targets.
28
-
29
- `targeted?`
30
-
31
- : Determines if the resource is eligible for inclusion in the current page
32
- based on the front matter `target` and `exclude` data fields
33
-
34
- - if `frontmatter:target` is used, the target or feature appears in the
35
- front matter, and
36
- - if `frontmatter:exclude` is used, the target or enabled feature does NOT
37
- appear in the frontmatter.
38
-
39
- In general you won't use this resource method on pages because resources will
40
- already be excluded before you have a chance to check them, and so any
41
- leftover resources will always return true for this method. This method could
42
- be valuable in writing your own helpers, however.
43
-
44
-
45
12
  ## Helpers
46
13
 
47
- `target_name`
14
+ This extension provides several useful helpers to manage multiple targets and
15
+ features. Most of them are demonstrated at [Simple features demonstration](simple-demo.html).
48
16
 
49
- : Return the current build target.
17
+ <%= partial 'partials/helpers' %>
50
18
 
51
- `target_name?(proposal)`
52
19
 
53
- : Is the current target `proposal`?
54
-
55
- `target_feature?(feature)`
20
+ ## Resources
56
21
 
57
- : Does the target have the feature `feature`?
22
+ Middleman’s resource list is available to all of your templates and pages, and
23
+ also available for your own helpers, and `middleman-targets` provides a couple
24
+ of resource map additions than can prove useful when developing your own
25
+ helpers.
58
26
 
59
- `target_value(key)`
27
+ <%= partial 'partials/resources' %>
60
28
 
61
- : Attempts to return the value for they key `key` for the current target.
62
-
63
- `image_tag`
29
+ * * *
64
30
 
65
- : Extends Middleman’s built-in `image_tag` helper in order to support:
66
-
67
- - automatic target-specific images. Note that this only works on local files.
68
- - target and feature dependent images.
69
- - absolute paths
70
-
71
- Automatic target-specific images are described in
72
- [Simple features demonstration](simple-demo.html), and allow you to specify
73
- an image with a magic prefix in your source code which will be substituted
74
- with a target-specific image for output.
75
-
76
- Target- and feature-dependent images add the `:target` and `:feature`
77
- options to the `image_tag` parameter array, indicating that the image should
78
- only be used in the condition specified. For example,
79
- `image_tag 'my_image.png', :feature => 'insults_user'` will only include the
80
- image if the current target has the feature `insults_user` enabled.
81
-
82
- As a freebie that’s not specifically related to multiple targets, our
83
- `image_tag` helper also works with absolute image paths, where ”absolute”
84
- means relative to your project directory. Specifying `/assets/images/photo.png`
85
- will correctly reference that image as if your project directory were the
86
- root filesystem.
31
+ ### Example
87
32
 
33
+ The raw output of `<%%= current_page.valid_features %>` on this page is
34
+ `<%= current_page.valid_features %>`. The output will be different if you switch
35
+ targets.
88
36
 
89
37
 
90
38
  <% content_for :seeAlso do %>
@@ -0,0 +1,326 @@
1
+ <div class="attr_details">
2
+
3
+ <div class="method_details first">
4
+ <h3 class="signature first" id="config[:build_dir]=-instance_method">
5
+
6
+ - (<tt>String</tt>) <strong>config[:build_dir]=</strong>(value)
7
+
8
+
9
+
10
+
11
+
12
+ </h3><div class="docstring">
13
+ <div class="discussion">
14
+
15
+ <p>Indicates where <strong>Middleman</strong> will put build output. This standard config
16
+ value will be treated as a <em>prefix</em>; for example if the current target is <code>:pro</code> and this
17
+ value is set to its default <code>build</code>, then the actual build directory will
18
+ be <code>build (pro)/</code>.</p>
19
+
20
+ <p>If the <code>build_dir</code> key is present for any of the <code>config[:targets]</code>, they
21
+ will override this setting.</p>
22
+
23
+
24
+ </div>
25
+ </div>
26
+ <div class="tags">
27
+ <p class="tag_title">Parameters:</p>
28
+ <ul class="param">
29
+
30
+ <li>
31
+
32
+ <span class='name'>value</span>
33
+
34
+
35
+ <span class='type'>(<tt>String</tt>)</span>
36
+
37
+
38
+
39
+ &mdash;
40
+ <div class='inline'><p>Indicate the build directory prefix that should be
41
+ used for build output.</p>
42
+ </div>
43
+
44
+ </li>
45
+
46
+ </ul>
47
+
48
+ <p class="tag_title">Returns:</p>
49
+ <ul class="return">
50
+
51
+ <li>
52
+
53
+
54
+ <span class='type'>(<tt>String</tt>)</span>
55
+
56
+
57
+
58
+ &mdash;
59
+ <div class='inline'><p>Returns the current value of this configuration setting.</p>
60
+ </div>
61
+
62
+ </li>
63
+
64
+ </ul>
65
+
66
+ </div>
67
+ </div>
68
+
69
+
70
+ <div class="method_details">
71
+ <h3 class="signature">
72
+
73
+ - (<tt>Symbol</tt>) <strong>config[:target]=</strong>(value)
74
+
75
+
76
+
77
+
78
+
79
+ </h3><div class="docstring">
80
+ <div class="discussion">
81
+
82
+ <p>Indicates the current target that is being built or served. When
83
+ set in <code>config.rb</code> it indicates the default target if one is not
84
+ specified on the command line.</p>
85
+
86
+
87
+ </div>
88
+ </div>
89
+ <div class="tags">
90
+ <p class="tag_title">Parameters:</p>
91
+ <ul class="param">
92
+
93
+ <li>
94
+
95
+ <span class='name'>value</span>
96
+
97
+
98
+ <span class='type'>(<tt>Symbol</tt>)</span>
99
+
100
+
101
+
102
+ &mdash;
103
+ <div class='inline'><p>The target from <code>config[:targets]</code> that should
104
+ be used as the default.</p>
105
+ </div>
106
+
107
+ </li>
108
+
109
+ </ul>
110
+
111
+ <p class="tag_title">Returns:</p>
112
+ <ul class="return">
113
+
114
+ <li>
115
+
116
+
117
+ <span class='type'>(<tt>Symbol</tt>)</span>
118
+
119
+
120
+
121
+ &mdash;
122
+ <div class='inline'><p>Returns the current target.</p>
123
+ </div>
124
+
125
+ </li>
126
+
127
+ </ul>
128
+
129
+ </div>
130
+ </div>
131
+
132
+
133
+ <div class="method_details ">
134
+ <h3 class="signature ">
135
+
136
+ - (<tt>Boolean</tt>) <strong>config[:target_magic_images]=</strong>(value)
137
+
138
+
139
+
140
+
141
+
142
+ </h3><div class="docstring">
143
+ <div class="discussion">
144
+
145
+ <p>This option is used to enable or disable the target magic images feature.
146
+ If it’s <code>true</code> then the <code>image_tag</code> helper will attempt to substitute
147
+ target-specific images instead of the specified image, if the specified
148
+ image begins with <code>:target_magic_word</code>.</p>
149
+
150
+
151
+ </div>
152
+ </div>
153
+ <div class="tags">
154
+ <p class="tag_title">Parameters:</p>
155
+ <ul class="param">
156
+
157
+ <li>
158
+
159
+ <span class='name'>value</span>
160
+
161
+
162
+ <span class='type'>(<tt>Boolean</tt>)</span>
163
+
164
+
165
+
166
+ &mdash;
167
+ <div class='inline'><p>Specify whether or not automatic target-specific
168
+ image substitution should be enabled.</p>
169
+ </div>
170
+
171
+ </li>
172
+
173
+ </ul>
174
+
175
+ <p class="tag_title">Returns:</p>
176
+ <ul class="return">
177
+
178
+ <li>
179
+
180
+
181
+ <span class='type'>(<tt>Boolean</tt>)</span>
182
+
183
+
184
+
185
+ &mdash;
186
+ <div class='inline'><p>Returns the current state of this option.</p>
187
+ </div>
188
+
189
+ </li>
190
+
191
+ </ul>
192
+
193
+ </div>
194
+ </div>
195
+
196
+
197
+ <div class="method_details ">
198
+ <h3 class="signature ">
199
+
200
+ - (<tt>String</tt>) <strong>config[:target_magic_word]=</strong>(value)
201
+
202
+
203
+
204
+
205
+
206
+ </h3><div class="docstring">
207
+ <div class="discussion">
208
+
209
+ <p>Indicates the magic image prefix for image substitution with the
210
+ <code>image_tag</code> helper when <code>:target_magic_images</code> is enabled. For example
211
+ if you specify <code>all-image.png</code> and <code>pro-image.png</code> exists, then the
212
+ latter will be used by the helper instead of the former.</p>
213
+
214
+
215
+ </div>
216
+ </div>
217
+ <div class="tags">
218
+ <p class="tag_title">Parameters:</p>
219
+ <ul class="param">
220
+
221
+ <li>
222
+
223
+ <span class='name'>value</span>
224
+
225
+
226
+ <span class='type'>(<tt>String</tt>)</span>
227
+
228
+
229
+
230
+ &mdash;
231
+ <div class='inline'><p>Indicate the prefix that should indicate and image
232
+ the should be substituted, such as <code>all</code>.</p>
233
+ </div>
234
+
235
+ </li>
236
+
237
+ </ul>
238
+
239
+ <p class="tag_title">Returns:</p>
240
+ <ul class="return">
241
+
242
+ <li>
243
+
244
+
245
+ <span class='type'>(<tt>String</tt>)</span>
246
+
247
+
248
+
249
+ &mdash;
250
+ <div class='inline'><p>Returns the current magic prefix.</p>
251
+ </div>
252
+
253
+ </li>
254
+
255
+ </ul>
256
+
257
+ </div>
258
+ </div>
259
+
260
+
261
+ <div class="method_details ">
262
+ <h3 class="signature ">
263
+
264
+ - (<tt>Hash</tt>) <strong>config[:targets]=</strong>(value)
265
+
266
+
267
+
268
+
269
+
270
+ </h3><div class="docstring">
271
+ <div class="discussion">
272
+
273
+ <p>A hash that defines all of the characteristics of your individual targets.
274
+ The <code>build_dir</code> and <code>features</code> keys in a target have special meanings;
275
+ other keys can be added arbitrarily and helpers can fetch these for you.
276
+ A best practice is to assign the same features to <em>all</em> of your targets and
277
+ toggle them <code>on</code> or <code>off</code> on a target-specific basis.</p>
278
+
279
+
280
+ </div>
281
+ </div>
282
+ <div class="tags">
283
+
284
+ <p class="tag_title">Parameters:</p>
285
+ <ul class="param">
286
+
287
+ <li>
288
+
289
+ <span class='name'>value</span>
290
+
291
+
292
+ <span class='type'>(<tt>Hash</tt>)</span>
293
+
294
+
295
+
296
+ &mdash;
297
+ <div class='inline'><p>The complete definition of your targets, their
298
+ features, and other keys-value pairs that you wish to include.</p>
299
+ </div>
300
+
301
+ </li>
302
+
303
+ </ul>
304
+
305
+ <p class="tag_title">Returns:</p>
306
+ <ul class="return">
307
+
308
+ <li>
309
+
310
+
311
+ <span class='type'>(<tt>Hash</tt>)</span>
312
+
313
+
314
+
315
+ &mdash;
316
+ <div class='inline'><p>Returns the attributes of your targets.</p>
317
+ </div>
318
+
319
+ </li>
320
+
321
+ </ul>
322
+
323
+ </div>
324
+ </div>
325
+
326
+ </div>