فهرست منبع

Make :skip_links option work with true/false

Thibaut 12 سال پیش
والد
کامیت
bf6c900ca7

+ 1 - 1
lib/docs/filters/core/internal_urls.rb

@@ -25,7 +25,7 @@ module Docs
     end
 
     def skip_links?
-      context[:skip_links] && context[:skip_links].call(self)
+      context[:skip_links].is_a?(Proc) ? context[:skip_links].call(self) : context[:skip_links]
     end
 
     def follow_links?

+ 1 - 1
lib/docs/scrapers/backbone.rb

@@ -10,7 +10,7 @@ module Docs
 
     options[:title] = 'Backbone.js'
     options[:container] = '.container'
-    options[:skip_links] = ->(filter) { true }
+    options[:skip_links] = true
 
     options[:attribution] = <<-HTML
       &copy; 2010&ndash;2013 Jeremy Ashkenas, DocumentCloud<br>

+ 1 - 1
lib/docs/scrapers/coffeescript.rb

@@ -9,7 +9,7 @@ module Docs
 
     options[:title] = 'CoffeeScript'
     options[:container] = '.container'
-    options[:skip_links] = ->(filter) { true }
+    options[:skip_links] = true
 
     options[:attribution] = <<-HTML
       &copy; 2009&ndash;2013 Jeremy Ashkenas<br>

+ 1 - 1
lib/docs/scrapers/less.rb

@@ -8,7 +8,7 @@ module Docs
 
     options[:title] = 'LESS'
     options[:container] = 'section'
-    options[:skip_links] = ->(filter) { true }
+    options[:skip_links] = true
 
     options[:attribution] = <<-HTML
       &copy; 2009&ndash;2013 Alexis Sellier &amp; The Core Less Team<br>

+ 1 - 1
lib/docs/scrapers/lodash.rb

@@ -10,7 +10,7 @@ module Docs
 
     options[:title] = 'Lo-Dash'
     options[:container] = 'h1+div+div'
-    options[:skip_links] = ->(filter) { true }
+    options[:skip_links] = true
 
     options[:attribution] = <<-HTML
       &copy; 2012&ndash;2013 The Dojo Foundation<br>

+ 1 - 1
lib/docs/scrapers/underscore.rb

@@ -10,7 +10,7 @@ module Docs
 
     options[:title] = 'Underscore.js'
     options[:container] = '#documentation'
-    options[:skip_links] = ->(filter) { true }
+    options[:skip_links] = true
 
     options[:attribution] = <<-HTML
       &copy; 2009&ndash;2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters &amp; Editors<br>

+ 14 - 0
test/lib/docs/filters/core/internal_urls_test.rb

@@ -285,6 +285,20 @@ class InternalUrlsFilterTest < MiniTest::Spec
       @body = link_to context[:url]
     end
 
+    context "when it is true" do
+      before do
+        context[:skip_links] = true
+      end
+
+      it "doesn't set :internal_urls" do
+        refute internal_urls
+      end
+
+      it "doesn't replace urls" do
+        assert_equal @body, filter_output_string
+      end
+    end
+
     context "when it is a block" do
       it "calls the block with the filter instance" do
         context[:skip_links] = ->(arg) { @arg = arg; nil }