Browse Source

Finish Phaser scraper

Thibaut 10 years ago
parent
commit
6e4f56f6c2

BIN
assets/images/icons.png


BIN
assets/images/icons@2x.png


+ 1 - 1
assets/javascripts/news.json

@@ -1,7 +1,7 @@
 [
   [
     "2015-07-05",
-    "New documentations: <a href=\"/drupal/\">Drupal</a> and <a href=\"/webpack/\">webpack</a>"
+    "New documentations: <a href=\"/drupal/\">Drupal</a>, <a href=\"/phaser/\">Phaser</a> and <a href=\"/webpack/\">webpack</a>"
   ], [
     "2015-05-24",
     "New <a href=\"/rust/\">Rust</a> documentation"

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -275,6 +275,11 @@ credits = [
     'npm, Inc. and Contributors<br>npm is a trademark of npm, Inc.',
     'npm',
     'https://raw.githubusercontent.com/npm/npm/master/LICENSE'
+  ], [
+    'Phaser',
+    '2015 Richard Davey, Photon Storm Ltd.',
+    'MIT',
+    'https://raw.githubusercontent.com/photonstorm/phaser/master/license.txt'
   ], [
     'PHP',
     '1997-2015 The PHP Documentation Group',

+ 1 - 0
assets/javascripts/views/pages/javascript.coffee

@@ -25,6 +25,7 @@ app.views.ModernizrPage =
 app.views.MomentPage =
 app.views.MongoosePage =
 app.views.NodePage =
+app.views.PhaserPage =
 app.views.RethinkdbPage =
 app.views.SinonPage =
 app.views.UnderscorePage =

+ 0 - 6
assets/javascripts/views/pages/phaser.coffee

@@ -1,6 +0,0 @@
-#= require views/pages/base
-
-class app.views.PhaserPage extends app.views.BasePage
-  afterRender: ->
-    @highlightCode @findAll('pre.source'), 'javascript'
-    return

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

@@ -103,3 +103,4 @@
 ._icon-apache_http_server:before { background-position: -9rem -7rem; }
 ._icon-drupal:before        { background-position: 0 -8rem; }
 ._icon-webpack:before       { background-position: -1rem -8rem; @extend %darkIconFix !optional; }
+._icon-phaser:before        { background-position: -2rem -8rem; }

+ 3 - 16
assets/stylesheets/pages/_phaser.scss

@@ -1,23 +1,10 @@
 ._phaser {
-  h2 { @extend %block-heading; }
-  h4 { @extend %block-label, %label-blue; }
+  @extend %simple;
 
-  p > code, li > code, td > code { @extend %label; }
-
-  dt.tag-source {
+  .type-signature, dt.tag-source {
     color: #666;
     font-weight: normal;
   }
 
-  .deprecated-notice {
-    @extend %note;
-  }
-
-  #docs-index > h3 { @extend %block-label, %label-blue; }
-  #docs > h3 { @extend %block-heading; }
-  #docs > h4 { @extend %block-label, %label-blue; }
-
-  #docs header {
-    display: none;
-  }
+  .deprecated-notice { @extend %note; }
 }

+ 31 - 6
lib/docs/filters/phaser/clean_html.rb

@@ -2,22 +2,47 @@ module Docs
   class Phaser
     class CleanHtmlFilter < Filter
       def call
-
         title = at_css('h1')
 
         if root_page?
-          doc.children = at_css('#docs-index')
+          @doc = at_css('#docs-index')
 
           # Remove first paragraph (old doc details)
-          doc.at_css('p').remove()
+          at_css('p').remove
+
+          title.content = 'Phaser'
         else
-          doc.children = at_css('#docs')
+          @doc = at_css('#docs')
+
+          # Remove useless markup
+          css('section > article').each do |node|
+            node.parent.replace(node.children)
+          end
+
+          css('dt > h4').each do |node|
+            dt = node.parent
+            dd = dt.next_element
+            dt.before(node).remove
+            dd.before(dd.children).remove
+          end
+
+          css('> div', '> section').each do |node|
+            node.before(node.children).remove
+          end
+
+          css('h3.subsection-title').each do |node|
+            node.name = 'h2'
+          end
+
+          css('h4.name').each do |node|
+            node.name = 'h3'
+          end
 
           # Remove "Jump to" block
-          doc.at_css('table').remove()
+          at_css('table').remove
         end
 
-        doc.child.before title
+        doc.child.before(title)
 
         # Clean code blocks
         css('pre > code').each do |node|

+ 18 - 3
lib/docs/filters/phaser/entries.rb

@@ -1,7 +1,6 @@
 module Docs
   class Phaser
     class EntriesFilter < Docs::EntriesFilter
-
       REPLACE_TYPES = {
         'gameobjects' => 'Game Objects',
         'geom'        => 'Geometry',
@@ -17,8 +16,8 @@ module Docs
 
       def get_name
         name = at_css('.title-frame h1').content
-        name.sub! /Phaser\./, ''
-        name.sub! /PIXI\./, ''
+        name.remove!('Phaser.')
+        name.remove!('PIXI.')
         name
       end
 
@@ -39,6 +38,22 @@ module Docs
 
         'Global'
       end
+
+      def additional_entries
+        entries = []
+
+        %w(members methods).each do |type|
+          css("##{type} h4.name").each do |node|
+            sig = node.at_css('.type-signature')
+            next if node.parent.parent.at_css('.inherited-from') || (sig && sig.content.include?('internal'))
+            sep = sig && sig.content.include?('static') ? '.' : '#'
+            name = "#{self.name}#{sep}#{node['id']}#{'()' if type == 'methods'}"
+            entries << [name, node['id']]
+          end
+        end
+
+        entries
+      end
     end
   end
 end

+ 0 - 2
lib/docs/scrapers/phaser.rb

@@ -1,7 +1,5 @@
 module Docs
   class Phaser < UrlScraper
-    self.name = 'Phaser'
-    self.slug = 'phaser'
     self.type = 'phaser'
     self.version = '2.3.0'
     self.base_url = "https://phaser.io/docs/#{version}"

BIN
public/icons/docs/phaser/16.png


BIN
public/icons/docs/phaser/16@2x.png