瀏覽代碼

Update Yii documentation (2.0.1)

Thibaut 11 年之前
父節點
當前提交
a72778e9f4

+ 0 - 15
assets/javascripts/views/pages/yii.coffee

@@ -1,15 +0,0 @@
-#= require views/pages/base
-
-class app.views.YiiPage extends app.views.BasePage
-  @events:
-    click: 'onClick'
-
-  onClick: (event) ->
-    return unless event.target.classList.contains 'show'
-    $.stopEvent(event)
-
-    source = $ '.code', event.target.parentNode.parentNode
-    isShown = source.style.display is 'block'
-
-    source.style.display = if isShown then 'none' else 'block'
-    event.target.textContent = if isShown then 'show' else 'hide'

+ 7 - 17
assets/stylesheets/pages/_yii.scss

@@ -1,24 +1,14 @@
 ._yii {
   h2 { @extend %block-heading; }
-  > h3 { @extend %block-label, %label-blue; }
+  h3 { @extend %block-label, %label-blue; }
+  h4 { font-size: 1em; }
 
-  .paramNameCol { font-weight: bold; }
-  .signature2 { margin: .4em 0; }
-  .sourceCode { margin-bottom: 1em; }
-  .sourceCode > .code { display: none; }
+  blockquote { @extend %note; }
 
-  .SeeAlso {
-    > h4 {
-      margin-bottom: 1em;
-      font-size: inherit;
-    }
-
-    > ul { margin-top: 0; }
+  .detail-header-tag, .detailHeaderTag {
+    float: right;
+    color: $textColorLight;
   }
 
-  .summaryTable td:first-child[rowspan] {
-    border-right: 1px solid $boxBorderLight;
-
-    + td { border-left: 0; }
-  }
+  .param-type-col { white-space: nowrap; }
 }

+ 18 - 12
lib/docs/filters/yii/clean_html.rb

@@ -2,28 +2,34 @@ module Docs
   class Yii
     class CleanHtmlFilter < Filter
       def call
-        at_css('h1').content = 'Yii PHP Framework' if root_page?
+        css('#nav', '.tool-link', '.toggle').remove
 
-        css('.api-suggest', '.google-ad', '.g-plusone', '#nav', '#comments').remove
+        css('.hashlink[name]').each do |node|
+          node.parent['id'] = node['name']
+          node.remove
+        end
 
-        css('.summary > p > .toggle').each do |node|
-          node.parent.remove
+        css('.detail-header').each do |node|
+          node.name = 'h3'
+          node.child.remove while node.child.content.blank?
         end
 
-        css('.signature', '.signature2').each do |node|
+        css('pre').each do |node|
+          node.inner_html = node.inner_html.gsub('<br>', "\n").gsub('&nbsp;', ' ')
+          node.content = node.content
+        end
+
+        css('div.signature').each do |node|
           node.name = 'pre'
           node.inner_html = node.inner_html.strip
         end
 
-        css('div.detailHeader').each do |node|
-          node.name = 'h3'
+        css('.detail-table th').each do |node|
+          node.name = 'td'
         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
+        css('.detail-table td.signature').each do |node|
+          node.name = 'th'
         end
 
         doc

+ 16 - 4
lib/docs/filters/yii/entries.rb

@@ -2,17 +2,29 @@ module Docs
   class Yii
     class EntriesFilter < Docs::EntriesFilter
       def get_name
-        at_css('h1').content.strip
+        name = at_css('h1').content.strip
+        name.remove! %r{\A.*?(Class|Trait|Interface)\s*}
+        name.remove!('yii\\')
+        name
       end
 
       def get_type
-        css('.summaryTable td').first.content
+        if slug.include?('guide')
+          'Guides'
+        else
+          components = name.split('\\')
+          type = components.first
+          type << "\\#{components.second}" if (type == 'db' && components.second.in?(%w(cubrid mssql mysql oci pgsql sqlite))) ||
+                                              (type == 'web' && components.second.in?(%w(Request Response)))
+          type = 'yii' if type == 'BaseYii' || type == 'Yii'
+          type
+        end
       end
 
       def additional_entries
-        css('.detailHeader').inject [] do |entries, node|
+        css('.detail-header').each_with_object [] do |node, entries|
           name = node.child.content.strip
-          name.prepend self.name + (node.next_element.content.include?('public static') ? '::' : '->')
+          name.prepend "#{self.name} "
           entries << [name, node['id']]
         end
       end

+ 6 - 3
lib/docs/scrapers/yii.rb

@@ -1,12 +1,15 @@
 module Docs
   class Yii < UrlScraper
     self.type = 'yii'
-    self.version = '1.1.14'
-    self.base_url = 'http://www.yiiframework.com/doc/api/1.1/'
+    self.version = '2.0.1'
+    self.base_url = 'http://www.yiiframework.com/doc-2.0/'
+    self.root_path = 'index.html'
 
     html_filters.push 'yii/clean_html', 'yii/entries'
 
-    options[:container] = '.grid_9'
+    options[:container] = 'div[role=main]'
+    options[:skip_patterns] = [/\Ayii-apidoc/]
+
     options[:attribution] = <<-HTML
       &copy; 2008&ndash;2014 by Yii Software LLC<br>
       Licensed under the three clause BSD license.