History

Add padrino support

Matthias Guenther committed 10 years ago

Commit e1e4a621 parent 5bb96f83 files · +67 −0Browse files

Unified · Split

3 files
  1. lib/docs/filters/padrino/clean_html.rb +11 −0
  2. lib/docs/filters/padrino/entries.rb +35 −0
  3. lib/docs/scrapers/padrino.rb +21 −0
lib/docs/filters/padrino/clean_html.rb+11−0
@@ -0,0 +1,11 @@
1+module Docs
2+ class Padrino
3+ class CleanHtmlFilter < Filter
4+ def call
5+ css('.summary_toggle').remove
6+ css('.inheritanceTree').remove
7+ at_css('#content')
8+ end
9+ end
10+ end
11+end
lib/docs/filters/padrino/entries.rb+35−0
@@ -0,0 +1,35 @@
1+module Docs
2+ class Padrino
3+ class EntriesFilter < Docs::EntriesFilter
4+ def get_name
5+ name = at_css('h1, h2').content
6+ name.remove! 'Class: '
7+ name.remove! 'Module: '
8+ end
9+
10+ def get_type
11+ type = name.dup
12+ type.remove! %r{#.+\z}
13+ type.split('::')[0..2].join('::')
14+ end
15+
16+ def additional_entries
17+ return [] if root_page?
18+ require 'cgi'
19+
20+ css('.summary_signature').inject [] do |entries, node|
21+
22+ name = node.children[1].attributes['title'].value
23+ name = CGI.unescape(name)
24+
25+ unless name.start_with?('_')
26+ name.prepend self.name
27+ entries << [name, self.name.gsub('::','/').downcase.strip + node.children[1].attributes['href'].value.slice(/\#.*/)] unless entries.any? { |entry| entry[0] == name }
28+ end
29+
30+ entries
31+ end
32+ end
33+ end
34+ end
35+end
lib/docs/scrapers/padrino.rb+21−0
@@ -0,0 +1,21 @@
1+module Docs
2+ class Padrino < UrlScraper
3+ self.name = 'padrino'
4+ self.slug = 'padrino'
5+ self.type = 'ruby'
6+ self.version = 'master'
7+ self.release = '0.13.2'
8+ self.base_url = 'http://www.rubydoc.info/github/padrino/padrino-framework'
9+ self.links = {
10+ home: 'http://padrinorb.com/',
11+ code: 'https://github.com/padrino/padrino-framework'
12+ }
13+
14+ html_filters.push 'padrino/clean_html', 'padrino/entries'
15+
16+ options[:attribution] = <<-HTML
17+ &copy; Padrino contributors<br>
18+ Licensed under the Creative Commons Attribution License.
19+ HTML
20+ end
21+end