浏览代码

Bring back Yii 1.1 documentation

Closes #157.
Thibaut 10 年之前
父节点
当前提交
4a930ee4eb

+ 1 - 1
assets/javascripts/news.json

@@ -1,6 +1,6 @@
 [
   [ "2015-02-15",
-    "New <a href=\"/iojs/\">io.js</a> documentation"
+    "New <a href=\"/iojs/\">io.js</a> and <a href=\"/yii1/\">Yii 1.1</a> documentations"
   ], [
     "2015-02-08",
     "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 :)"

+ 1 - 0
assets/stylesheets/global/_icons.scss

@@ -52,6 +52,7 @@
 ._icon-c:before             { background-position: -2rem -7rem; }
 %icon-path                  { background-position: -3rem -7rem; }
 ._icon-yii:before           { background-position: -4rem -7rem; }
+._icon-yii1:before          { background-position: -4rem -7rem; }
 ._icon-cpp:before           { background-position: 0 -8rem; }
 ._icon-go:before            { background-position: -1rem -8rem; }
 ._icon-express:before       { background-position: -2rem -8rem; }

+ 33 - 0
lib/docs/filters/yii1/clean_html.rb

@@ -0,0 +1,33 @@
+module Docs
+  class Yii1
+    class CleanHtmlFilter < Filter
+      def call
+        at_css('h1').content = 'Yii PHP Framework' if root_page?
+
+        css('.api-suggest', '.google-ad', '.g-plusone', '#nav', '#comments').remove
+
+        css('.summary > p > .toggle').each do |node|
+          node.parent.remove
+        end
+
+        css('.signature', '.signature2').each do |node|
+          node.name = 'pre'
+          node.inner_html = node.inner_html.strip
+        end
+
+        css('div.detailHeader').each do |node|
+          node.name = 'h3'
+        end
+
+        css('.sourceCode > .code > code').each do |node|
+          parent = node.parent
+          parent.name = 'pre'
+          node.remove
+          parent.inner_html = node.first_element_child.inner_html.strip
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 21 - 0
lib/docs/filters/yii1/entries.rb

@@ -0,0 +1,21 @@
+module Docs
+  class Yii1
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        at_css('h1').content.strip
+      end
+
+      def get_type
+        css('.summaryTable td').first.content
+      end
+
+      def additional_entries
+        css('.detailHeader').inject [] do |entries, node|
+          name = node.child.content.strip
+          name.prepend self.name + (node.next_element.content.include?('public static') ? '::' : '->')
+          entries << [name, node['id']]
+        end
+      end
+    end
+  end
+end

+ 17 - 0
lib/docs/scrapers/yii1.rb

@@ -0,0 +1,17 @@
+module Docs
+  class Yii1 < UrlScraper
+    self.name = 'Yii 1'
+    self.slug = 'yii1'
+    self.type = 'yii'
+    self.version = '1.1.16'
+    self.base_url = 'http://www.yiiframework.com/doc/api/1.1/'
+
+    html_filters.push 'yii1/clean_html', 'yii1/entries'
+
+    options[:container] = '.grid_9'
+    options[:attribution] = <<-HTML
+      &copy; 2008&ndash;2015 by Yii Software LLC<br>
+      Licensed under the three clause BSD license.
+    HTML
+  end
+end