History

Bring back Yii 1.1 documentation

Closes #157.

Thibaut committed 11 years ago

Commit 4a930ee1 parent 9f676055 files · +73 −1Browse files

Unified · Split

5 files
  1. assets/javascripts/news.json +1 −1
  2. assets/stylesheets/global/_icons.scss +1 −0
  3. lib/docs/filters/yii1/clean_html.rb +33 −0
  4. lib/docs/filters/yii1/entries.rb +21 −0
  5. lib/docs/scrapers/yii1.rb +17 −0
assets/javascripts/news.json+1−1
@@ -1,6 +1,6 @@
11 [
22 [ "2015-02-15",
3− "New <a href=\"/iojs/\">io.js</a> documentation"
3+ "New <a href=\"/iojs/\">io.js</a> and <a href=\"/yii1/\">Yii 1.1</a> documentations"
44 ], [
55 "2015-02-08",
66 "New dark theme\nClick the icon in the bottom left corner to activate.\n<a href=\"https://github.com/Thibaut/devdocs/issues\" target=\"_blank\">Feedback</a> welcome :)"
assets/stylesheets/global/_icons.scss+1−0
@@ -52,6 +52,7 @@ · 51 unmodified lines
5252 ._icon-c:before { background-position: -2rem -7rem; }
5353 %icon-path { background-position: -3rem -7rem; }
5454 ._icon-yii:before { background-position: -4rem -7rem; }
55+._icon-yii1:before { background-position: -4rem -7rem; }
5556 ._icon-cpp:before { background-position: 0 -8rem; }
5657 ._icon-go:before { background-position: -1rem -8rem; }
5758 ._icon-express:before { background-position: -2rem -8rem; }
lib/docs/filters/yii1/clean_html.rb+33−0
@@ -0,0 +1,33 @@
1+module Docs
2+ class Yii1
3+ class CleanHtmlFilter < Filter
4+ def call
5+ at_css('h1').content = 'Yii PHP Framework' if root_page?
6+
7+ css('.api-suggest', '.google-ad', '.g-plusone', '#nav', '#comments').remove
8+
9+ css('.summary > p > .toggle').each do |node|
10+ node.parent.remove
11+ end
12+
13+ css('.signature', '.signature2').each do |node|
14+ node.name = 'pre'
15+ node.inner_html = node.inner_html.strip
16+ end
17+
18+ css('div.detailHeader').each do |node|
19+ node.name = 'h3'
20+ end
21+
22+ css('.sourceCode > .code > code').each do |node|
23+ parent = node.parent
24+ parent.name = 'pre'
25+ node.remove
26+ parent.inner_html = node.first_element_child.inner_html.strip
27+ end
28+
29+ doc
30+ end
31+ end
32+ end
33+end
lib/docs/filters/yii1/entries.rb+21−0
@@ -0,0 +1,21 @@
1+module Docs
2+ class Yii1
3+ class EntriesFilter < Docs::EntriesFilter
4+ def get_name
5+ at_css('h1').content.strip
6+ end
7+
8+ def get_type
9+ css('.summaryTable td').first.content
10+ end
11+
12+ def additional_entries
13+ css('.detailHeader').inject [] do |entries, node|
14+ name = node.child.content.strip
15+ name.prepend self.name + (node.next_element.content.include?('public static') ? '::' : '->')
16+ entries << [name, node['id']]
17+ end
18+ end
19+ end
20+ end
21+end
lib/docs/scrapers/yii1.rb+17−0
@@ -0,0 +1,17 @@
1+module Docs
2+ class Yii1 < UrlScraper
3+ self.name = 'Yii 1'
4+ self.slug = 'yii1'
5+ self.type = 'yii'
6+ self.version = '1.1.16'
7+ self.base_url = 'http://www.yiiframework.com/doc/api/1.1/'
8+
9+ html_filters.push 'yii1/clean_html', 'yii1/entries'
10+
11+ options[:container] = '.grid_9'
12+ options[:attribution] = <<-HTML
13+ &copy; 2008&ndash;2015 by Yii Software LLC<br>
14+ Licensed under the three clause BSD license.
15+ HTML
16+ end
17+end