Finish Phalcon scraper

pull/281/head
Thibaut 9 years ago
parent 4cde9d2961
commit ece7a75afd

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 87 KiB

@ -1,5 +1,8 @@
[
[
"2015-09-13",
"New documentation: <a href=\"/phalcon/\">Phalcon</a>"
], [
"2015-08-09",
"New documentation: <a href=\"/react_native/\">React Native</a>"
], [

@ -279,6 +279,11 @@ credits = [
'2010-2015 The OpenTSDB Authors',
'LGPLv2.1',
'https://raw.githubusercontent.com/OpenTSDB/opentsdb.net/gh-pages/COPYING.LESSER'
], [
'Phalcon',
'2011-2015 Phalcon Framework Team',
'CC BY',
'https://docs.phalconphp.com/en/latest/reference/license.html'
], [
'Phaser',
'2015 Richard Davey, Photon Storm Ltd.',

@ -0,0 +1,7 @@
#= require views/pages/base
class app.views.PhalconPage extends app.views.BasePage
afterRender: ->
@highlightCode @findAll('pre[class*="php"]'), 'php'
@highlightCode @findAll('pre.highlight-html'), 'markup'
return

@ -55,6 +55,7 @@
'pages/node',
'pages/npm',
'pages/opentsdb',
'pages/phalcon',
'pages/phaser',
'pages/php',
'pages/phpunit',

@ -55,6 +55,7 @@
'pages/node',
'pages/npm',
'pages/opentsdb',
'pages/phalcon',
'pages/phaser',
'pages/php',
'pages/phpunit',

@ -112,3 +112,4 @@
%icon-expand-white { background-position: -8rem -8rem; }
%icon-contract-white { background-position: -9rem -8rem; }
._icon-react_native:before { background-position: 0 -9rem; }
._icon-phalcon:before { background-position: -1rem -9rem; }

@ -0,0 +1,8 @@
._phalcon {
@extend %simple;
h3 > small {
float: right;
color: $textColorLight;
}
}

@ -4,12 +4,38 @@ module Docs
def call
@doc = at_css('.body')
# Remove unnecessary things
css('.headerlink', '#what-is-phalcon', '#other-formats', '#welcome h1', '#welcome p', '#table-of-contents h2').remove
if root_page?
at_css('h1').content = 'Phalcon'
end
css('#what-is-phalcon', '#other-formats').remove
css('#methods > p > strong, #constants > p > strong').each do |node|
node.parent.name = 'h3'
node.parent['id'] = node.content.parameterize
node.parent['class'] = 'method-signature'
node.parent.inner_html = node.parent.inner_html.sub(/inherited from .*/, '<small>\0</small>')
end
css('.headerlink').each do |node|
id = node['href'][1..-1]
node.parent['id'] ||= id
node.remove
end
css('div[class^="highlight-"]').each do |node|
code = node.at_css('pre').content
code.remove! %r{\A\s*<\?php\s*} unless code.include?(' ?>')
node.content = code
node.name = 'pre'
end
css('.section').each do |node|
node.before(node.children).remove
end
# Add id for constants and methods
css('#constants strong', '#methods strong').each do |node|
node.parent['id'] = node.content.strip
css('table[border]').each do |node|
node.remove_attribute('border')
end
doc

@ -1,31 +1,28 @@
module Docs
class Phalcon
class EntriesFilter < Docs::EntriesFilter
def get_name
node = css('h1').first
name = node.content.strip
node.remove
name
(at_css('h1 > strong') || at_css('h1')).content.strip.remove('Phalcon\\')
end
def get_type
if slug.start_with? 'reference'
if slug.start_with?('reference')
'Guides'
else
'Classes'
path = name.split('\\')
path[1] == 'Mvc' ? path[1..2].join('\\') : path[1]
end
end
def additional_entries
entries = []
css('#constants strong').each do |node|
entries << [node.content.strip, node.parent['id'], 'Constants']
end
css('#methods strong').each do |node|
entries << [node.content.strip, node.parent['id'], 'Methods']
css('.method-signature').each do |node|
next if node.content.include?('inherited from') || node.content.include?('protected ') || node.content.include?('private ')
name = node.at_css('strong').content.strip
next if name == '__construct' || name == '__toString'
name.prepend "#{self.name}::"
entries << [name, node['id']]
end
entries

@ -1,8 +1,7 @@
module Docs
class Phalcon < UrlScraper
self.name = 'Phalcon'
self.slug = 'phalcon'
self.type = 'phalcon'
self.version = '2.0.6'
self.base_url = 'https://docs.phalconphp.com/en/latest/'
self.root_path = 'index.html'
self.links = {
@ -10,14 +9,16 @@ module Docs
code: 'https://github.com/phalcon/cphalcon/'
}
html_filters.push 'phalcon/clean_html', 'phalcon/entries', 'title'
html_filters.push 'phalcon/clean_html', 'phalcon/entries'
options[:root_title] = 'Phalcon'
options[:only_patterns] = [/reference\//, /api\//]
options[:skip_patterns] = [/api\/index/]
options[:skip] = %w(
api/index.html
reference/license.html)
options[:attribution] = <<-HTML
&copy; 2012&ndash;2015 the Phalcon Team<br>
&copy; 2011&ndash;2015 Phalcon Framework Team<br>
Licensed under the Creative Commons Attribution License 3.0.
HTML
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 703 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Loading…
Cancel
Save