History

Make :skip_links option apply to pages instead of individual links

Thibaut committed 12 years ago

Commit 47eb7ee1 parent 6c8eea17 files · +59 −43Browse files

Showing the changes to lib/docs (6 of 7 files). Show all

Unified · Split

6 files
  1. lib/docs/filters/core/internal_urls.rb +5 −5
  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
lib/docs/filters/core/internal_urls.rb+5−5
@@ -3,10 +3,10 @@ require 'set' · 2 unmodified lines
33 module Docs
44 class InternalUrlsFilter < Filter
55 def call
6+ return doc if skip_links?
67 internal_urls = Set.new if follow_links?
78
89 css('a').each do |link|
9− next if skip_link?(link)
1010 next unless url = parse_href(link['href'])
1111 next unless subpath = subpath_to(url)
1212
@@ -24,12 +24,12 @@ module Docs · 11 unmodified lines
2424 doc
2525 end
2626
27− def follow_links?
28− !(context[:follow_links] && context[:follow_links].call(self) == false)
27+ def skip_links?
28+ context[:skip_links] && context[:skip_links].call(self)
2929 end
3030
31− def skip_link?(link)
32− context[:skip_links] && context[:skip_links].call(link)
31+ def follow_links?
32+ !(context[:follow_links] && context[:follow_links].call(self) == false)
3333 end
3434
3535 def parse_href(str)
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] = -> (_) { true }
13+ options[:skip_links] = ->(filter) { 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] = -> (_) { true }
12+ options[:skip_links] = ->(filter) { 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] = -> (_) { true }
11+ options[:skip_links] = ->(filter) { 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] = -> (_) { true }
13+ options[:skip_links] = ->(filter) { 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] = -> (_) { true }
13+ options[:skip_links] = ->(filter) { true }
1414
1515 options[:attribution] = <<-HTML
1616 &copy; 2009&ndash;2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters &amp; Editors<br>