History

Adding Yii files

Kirk Hansen committed 12 years ago

Commit 45fa50e1 parent 306acfa5 files · +88 −-2Browse files

Unified · Split

5 files
  1. lib/docs/filters/yii/clean_html.rb +48 −0
  2. lib/docs/filters/yii/entries.rb +30 −0
  3. lib/docs/scrapers/yii.rb +12 −0
  4. public/icons/docs/yii/16.png +0 −0
  5. public/icons/docs/yii/16@2x.png +0 −0
lib/docs/filters/yii/clean_html.rb+48−0
@@ -0,0 +1,48 @@
1+module Docs
2+ class Yii
3+ class CleanHtmlFilter < Filter
4+ def call
5+
6+ #remove irrelevant content
7+ css('div').each do |node|
8+ if node['class'] == "layout-main-header"
9+ node.remove
10+ elsif node['class'] == "layout-main-submenu"
11+ node.remove
12+ elsif node['class'] == "layout-main-shortcuts"
13+ node.remove
14+ elsif node['class'] == "layout-main-footer"
15+ node.remove
16+ elsif node['class'] == "grid_3 alpha"
17+ node.remove
18+ elsif node['class'] == "comments"
19+ node.remove
20+ elsif node['class'] == "api-suggest clearfix"
21+ node.remove
22+ elsif node['id'] == "comments"
23+ node.remove
24+ elsif node['id'] == "nav"
25+ node.remove
26+ else
27+ end
28+ end
29+
30+ # Put code blocks in <pre> tags
31+ css('.code').each do |node|
32+ node.name = 'pre'
33+ end
34+
35+ #remove Hide inherited methods / properties and show links
36+ css('a').each do |node|
37+ if node['class'] == 'toggle'
38+ node.remove
39+ elsif node['class'] == 'show'
40+ node.remove
41+ end
42+ end
43+
44+ doc
45+ end
46+ end
47+ end
48+end
lib/docs/filters/yii/entries.rb+30−0
@@ -0,0 +1,30 @@
1+module Docs
2+ class Yii
3+ class EntriesFilter < Docs::EntriesFilter
4+
5+ def get_name
6+ #class names exist in the <h1> content.
7+ name = at_css('h1').content.strip
8+ end
9+
10+ def get_type
11+ #need to get the table with a class of summaryTable. Then we need the content of the first td in the first tr.
12+ type = css('table.summaryTable td')[0].content
13+ type
14+ end
15+
16+ def additional_entries
17+ css('table.summaryTable tr[id]').inject [] do |entries,node|
18+ #need to ignore inherited methods and properties
19+ if (node['class'] != 'inherited' and node.parent().parent()['class'] == "summary docMethod")
20+ #name should be Class.method() id will take you to the link in the summary block.
21+ name = slug + "." + node['id'] + "()"
22+ entries << [name, node['id']]
23+ end
24+ entries
25+ end
26+ end
27+
28+ end
29+ end
30+end
lib/docs/scrapers/yii.rb+12−0
@@ -0,0 +1,12 @@
1+module Docs
2+ class Yii < UrlScraper
3+ self.name = 'Yii'
4+ self.slug = 'yii'
5+ self.type = 'yii'
6+ self.version = '1.1.14'
7+ self.base_url = 'http://www.yiiframework.com/doc/api/1.1/'
8+
9+ html_filters.push 'yii/clean_html', 'yii/entries'
10+
11+ end
12+end
public/icons/docs/yii/16.png+0−0

Binary file not shown.

public/icons/docs/yii/16@2x.png+0−0

Binary file not shown.