You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
devdocs/lib/docs/scrapers/angular.rb

41 lines
1.1 KiB

11 years ago
module Docs
class Angular < UrlScraper
include StubRootPage
11 years ago
self.name = 'Angular.js'
self.slug = 'angular'
self.type = 'angular'
self.release = '1.5.0'
self.base_url = "https://code.angularjs.org/#{release}/docs/partials/api/"
html_filters.push 'angular/clean_html', 'angular/entries', 'title'
text_filters.push 'angular/clean_urls'
options[:title] = false
options[:root_title] = 'Angular.js'
options[:fix_urls] = ->(url) do
url.sub! '/partials/api/api/', '/partials/api/'
url.sub! %r{/api/(.+?)/api/}, '/api/'
url.sub! %r{/partials/api/(.+?)(?<!\.html)(?:\z|(#.*))}, '/partials/api/\1.html\2'
url
end
options[:skip] = %w(ng.html)
options[:attribution] = <<-HTML
&copy; 2010&ndash;2016 Google, Inc.<br>
Licensed under the Creative Commons Attribution License 4.0.
HTML
private
def root_page_body
require 'capybara'
Capybara.current_driver = :selenium
Capybara.visit("https://code.angularjs.org/#{self.class.release}/docs/api")
Capybara.find('.side-navigation')['innerHTML']
end
11 years ago
end
end