History

Make :skip_links option work with true/false

Thibaut committed 12 years ago

Commit bf6c9001 parent 47eb7ee7 files · +20 −6Browse files

Unified · Split

7 files
  1. lib/docs/filters/core/internal_urls.rb +1 −1
  2. lib/docs/scrapers/backbone.rb +1 −1
  3. lib/docs/scrapers/coffeescript.rb +1 −1
  4. lib/docs/scrapers/less.rb +1 −1
  5. lib/docs/scrapers/lodash.rb +1 −1
  6. lib/docs/scrapers/underscore.rb +1 −1
  7. test/lib/docs/filters/core/internal_urls_test.rb +14 −0
lib/docs/filters/core/internal_urls.rb+1−1
@@ -25,7 +25,7 @@ module Docs · 24 unmodified lines
2525 end
2626
2727 def skip_links?
28− context[:skip_links] && context[:skip_links].call(self)
28+ context[:skip_links].is_a?(Proc) ? context[:skip_links].call(self) : context[:skip_links]
2929 end
3030
3131 def follow_links?
lib/docs/scrapers/backbone.rb+1−1
@@ -10,7 +10,7 @@ module Docs · 9 unmodified lines
1010
1111 options[:title] = 'Backbone.js'
1212 options[:container] = '.container'
13− options[:skip_links] = ->(filter) { true }
13+ options[:skip_links] = true
1414
1515 options[:attribution] = <<-HTML
1616 &copy; 2010&ndash;2013 Jeremy Ashkenas, DocumentCloud<br>
lib/docs/scrapers/coffeescript.rb+1−1
@@ -9,7 +9,7 @@ module Docs · 8 unmodified lines
99
1010 options[:title] = 'CoffeeScript'
1111 options[:container] = '.container'
12− options[:skip_links] = ->(filter) { true }
12+ options[:skip_links] = true
1313
1414 options[:attribution] = <<-HTML
1515 &copy; 2009&ndash;2013 Jeremy Ashkenas<br>
lib/docs/scrapers/less.rb+1−1
@@ -8,7 +8,7 @@ module Docs · 7 unmodified lines
88
99 options[:title] = 'LESS'
1010 options[:container] = 'section'
11− options[:skip_links] = ->(filter) { true }
11+ options[:skip_links] = true
1212
1313 options[:attribution] = <<-HTML
1414 &copy; 2009&ndash;2013 Alexis Sellier &amp; The Core Less Team<br>
lib/docs/scrapers/lodash.rb+1−1
@@ -10,7 +10,7 @@ module Docs · 9 unmodified lines
1010
1111 options[:title] = 'Lo-Dash'
1212 options[:container] = 'h1+div+div'
13− options[:skip_links] = ->(filter) { true }
13+ options[:skip_links] = true
1414
1515 options[:attribution] = <<-HTML
1616 &copy; 2012&ndash;2013 The Dojo Foundation<br>
lib/docs/scrapers/underscore.rb+1−1
@@ -10,7 +10,7 @@ module Docs · 9 unmodified lines
1010
1111 options[:title] = 'Underscore.js'
1212 options[:container] = '#documentation'
13− options[:skip_links] = ->(filter) { true }
13+ options[:skip_links] = true
1414
1515 options[:attribution] = <<-HTML
1616 &copy; 2009&ndash;2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters &amp; Editors<br>
test/lib/docs/filters/core/internal_urls_test.rb+14−0
@@ -285,6 +285,20 @@ class InternalUrlsFilterTest < MiniTest::Spec · 284 unmodified lines
285285 @body = link_to context[:url]
286286 end
287287
288+ context "when it is true" do
289+ before do
290+ context[:skip_links] = true
291+ end
292+
293+ it "doesn't set :internal_urls" do
294+ refute internal_urls
295+ end
296+
297+ it "doesn't replace urls" do
298+ assert_equal @body, filter_output_string
299+ end
300+ end
301+
288302 context "when it is a block" do
289303 it "calls the block with the filter instance" do
290304 context[:skip_links] = ->(arg) { @arg = arg; nil }