diff --git a/assets/javascripts/views/pages/phaser.coffee b/assets/javascripts/views/pages/phaser.coffee new file mode 100644 index 00000000..d9949116 --- /dev/null +++ b/assets/javascripts/views/pages/phaser.coffee @@ -0,0 +1,6 @@ +#= require views/pages/base + +class app.views.PhaserPage extends app.views.BasePage + afterRender: -> + @highlightCode @findAll('pre.source'), 'javascript' + return diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index 1968dceb..827328fd 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -54,6 +54,7 @@ 'pages/nginx', 'pages/node', 'pages/npm', + 'pages/phaser', 'pages/php', 'pages/phpunit', 'pages/postgres', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 4a8f307f..9a27ad70 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -54,6 +54,7 @@ 'pages/nginx', 'pages/node', 'pages/npm', + 'pages/phaser', 'pages/php', 'pages/phpunit', 'pages/postgres', diff --git a/assets/stylesheets/pages/_phaser.scss b/assets/stylesheets/pages/_phaser.scss new file mode 100644 index 00000000..a5314793 --- /dev/null +++ b/assets/stylesheets/pages/_phaser.scss @@ -0,0 +1,23 @@ +._phaser { + h2 { @extend %block-heading; } + h4 { @extend %block-label, %label-blue; } + + p > code, li > code, td > code { @extend %label; } + + 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; + } +} diff --git a/lib/docs/filters/phaser/clean_html.rb b/lib/docs/filters/phaser/clean_html.rb new file mode 100644 index 00000000..6a384cae --- /dev/null +++ b/lib/docs/filters/phaser/clean_html.rb @@ -0,0 +1,31 @@ +module Docs + class Phaser + class CleanHtmlFilter < Filter + def call + + title = at_css('h1') + + if root_page? + doc.children = at_css('#docs-index') + + # Remove first paragraph (old doc details) + doc.at_css('p').remove() + else + doc.children = at_css('#docs') + + # Remove "Jump to" block + doc.at_css('table').remove() + end + + doc.child.before title + + # Clean code blocks + css('pre > code').each do |node| + node.before(node.children).remove + end + + doc + end + end + end +end diff --git a/lib/docs/filters/phaser/entries.rb b/lib/docs/filters/phaser/entries.rb new file mode 100644 index 00000000..f6b720ba --- /dev/null +++ b/lib/docs/filters/phaser/entries.rb @@ -0,0 +1,44 @@ +module Docs + class Phaser + class EntriesFilter < Docs::EntriesFilter + + REPLACE_TYPES = { + 'gameobjects' => 'Game Objects', + 'geom' => 'Geometry', + 'tilemap' => 'Tilemaps', + 'net' => 'Network', + 'tween' => 'Tweens', + 'pixi' => 'PIXI' + } + + TYPE_GROUPS = { + 'Core' => ['loader'] + } + + def get_name + name = at_css('.title-frame h1').content + name.sub! /Phaser\./, '' + name.sub! /PIXI\./, '' + name + end + + def get_type + src = at_css('.container-overview .details > .tag-source > a') + + if src + src = src.content.split('/').first + + TYPE_GROUPS.each_pair do |replacement, types| + types.each do |t| + return replacement if src == t + end + end + + return REPLACE_TYPES[src] || src.capitalize + end + + 'Global' + end + end + end +end diff --git a/lib/docs/scrapers/phaser.rb b/lib/docs/scrapers/phaser.rb new file mode 100644 index 00000000..2da584f0 --- /dev/null +++ b/lib/docs/scrapers/phaser.rb @@ -0,0 +1,30 @@ +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}" + self.links = { + home: 'https://phaser.io/', + code: 'https://github.com/photonstorm/phaser' + } + + html_filters.push 'phaser/entries', 'phaser/clean_html' + + options[:skip] = %w( + /docs_pixi-jsdoc.js.html + /p2.Body.html + /Phaser.html + /PIXI.html + /PIXI.WebGLMaskManager.html + /PIXI.WebGLShaderManager.html + /PIXI.WebGLSpriteBatch.html + /PIXI.WebGLStencilManager.html) + + options[:attribution] = <<-HTML + © 2015 Richard Davey, Photon Storm Ltd.
+ Licensed under the MIT License. + HTML + end +end diff --git a/public/icons/docs/phaser/16.png b/public/icons/docs/phaser/16.png new file mode 100644 index 00000000..250d2388 Binary files /dev/null and b/public/icons/docs/phaser/16.png differ diff --git a/public/icons/docs/phaser/16@2x.png b/public/icons/docs/phaser/16@2x.png new file mode 100644 index 00000000..8af261f3 Binary files /dev/null and b/public/icons/docs/phaser/16@2x.png differ diff --git a/public/icons/docs/phaser/SOURCE b/public/icons/docs/phaser/SOURCE new file mode 100644 index 00000000..94e71758 --- /dev/null +++ b/public/icons/docs/phaser/SOURCE @@ -0,0 +1 @@ +https://phaser.io/