History

Add Bower documentation

Thibaut committed 11 years ago

Commit 9d47e021 parent 0fc2aac14 files · +84 −-3Browse files

Showing the changes to lib/docs (3 of 14 files). Show all

Unified · Split

3 files
  1. lib/docs/filters/bower/clean_html.rb +21 −0
  2. lib/docs/filters/bower/entries.rb +26 −0
  3. lib/docs/scrapers/bower.rb +19 −0
lib/docs/filters/bower/clean_html.rb+21−0
@@ -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
lib/docs/filters/bower/entries.rb+26−0
@@ -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
lib/docs/scrapers/bower.rb+19−0
@@ -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+ &copy; 2014 Bower contributors<br>
16+ Licensed under the Creative Commons Attribution License.
17+ HTML
18+ end
19+end