Showing the changes to lib (3 of 14 files). Show all
Unified · Split
| @@ -0,0 +1,21 @@ | |||
| 1 | module Docs | ||
| 2 | class Bower | ||
| 3 | class CleanHtmlFilter < Filter | ||
| 4 | def call | ||
| 5 | title = at_css('.page-title') | ||
| 6 | @doc = at_css('.main') | ||
| 7 | doc.child.before(title) | ||
| 8 | |||
| 9 | css('.site-footer').remove | ||
| 10 | |||
| 11 | css('.highlight').each do |node| | ||
| 12 | node.name = 'pre' | ||
| 13 | node['data-lang'] = node.at_css('[data-lang]')['data-lang'] | ||
| 14 | node.content = node.content | ||
| 15 | end | ||
| 16 | |||
| 17 | doc | ||
| 18 | end | ||
| 19 | end | ||
| 20 | end | ||
| 21 | end | ||
| @@ -0,0 +1,26 @@ | |||
| 1 | module Docs | ||
| 2 | class Bower | ||
| 3 | class EntriesFilter < Docs::EntriesFilter | ||
| 4 | ENTRIES_TYPE_BY_SLUG = { | ||
| 5 | 'api' => 'Commands', | ||
| 6 | 'config' => '.bowerrc' | ||
| 7 | } | ||
| 8 | |||
| 9 | def get_name | ||
| 10 | at_css('h1').content | ||
| 11 | end | ||
| 12 | |||
| 13 | def get_type | ||
| 14 | 'Guides' | ||
| 15 | end | ||
| 16 | |||
| 17 | def additional_entries | ||
| 18 | return [] unless type = ENTRIES_TYPE_BY_SLUG[slug] | ||
| 19 | |||
| 20 | css('#bowerrc-specification + ul a', '#commands + p + ul a').map do |node| | ||
| 21 | [node.content, node['href'].remove('#'), type] | ||
| 22 | end | ||
| 23 | end | ||
| 24 | end | ||
| 25 | end | ||
| 26 | end | ||
| @@ -0,0 +1,19 @@ | |||
| 1 | module Docs | ||
| 2 | class Bower < UrlScraper | ||
| 3 | self.name = 'Bower' | ||
| 4 | self.type = 'bower' | ||
| 5 | self.version = '1.3.12' | ||
| 6 | self.base_url = 'http://bower.io/docs/' | ||
| 7 | self.root_path = 'api' | ||
| 8 | |||
| 9 | html_filters.push 'bower/clean_html', 'bower/entries' | ||
| 10 | |||
| 11 | options[:trailing_slash] = false | ||
| 12 | options[:skip] = %w(tools about) | ||
| 13 | |||
| 14 | options[:attribution] = <<-HTML | ||
| 15 | © 2014 Bower contributors<br> | ||
| 16 | Licensed under the Creative Commons Attribution License. | ||
| 17 | HTML | ||
| 18 | end | ||
| 19 | end | ||