History

Finish Phalcon scraper

Thibaut committed 11 years ago

Commit ece7a751 parent 4cde9d214 files · +69 −19Browse files

Unified · Split

14 files
  1. assets/images/icons.png +0 −0
  2. assets/images/icons@2x.png +0 −0
  3. assets/javascripts/news.json +3 −0
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/javascripts/views/pages/phalcon.coffee +7 −0
  6. assets/stylesheets/application-dark.css.scss +1 −0
  7. assets/stylesheets/application.css.scss +1 −0
  8. assets/stylesheets/global/_icons.scss +1 −0
  9. assets/stylesheets/pages/_phalcon.scss +8 −0
  10. lib/docs/filters/phalcon/clean_html.rb +31 −5
  11. lib/docs/filters/phalcon/entries.rb +10 −13
  12. lib/docs/scrapers/phalcon.rb +6 −5
  13. public/icons/docs/phalcon/16.png +0 −0
  14. public/icons/docs/phalcon/16@2x.png +0 −0
assets/images/icons.png+0−0

Binary file not shown.

assets/images/icons@2x.png+0−0

Binary file not shown.

assets/javascripts/news.json+3−0
@@ -1,5 +1,8 @@
1[1[
2 [2 [
3 "2015-09-13",
4 "New documentation: <a href=\"/phalcon/\">Phalcon</a>"
5 ], [
3 "2015-08-09",6 "2015-08-09",
4 "New documentation: <a href=\"/react_native/\">React Native</a>"7 "New documentation: <a href=\"/react_native/\">React Native</a>"
5 ], [8 ], [
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -279,6 +279,11 @@ credits = [ · 278 unmodified lines
279 '2010-2015 The OpenTSDB Authors',279 '2010-2015 The OpenTSDB Authors',
280 'LGPLv2.1',280 'LGPLv2.1',
281 'https://raw.githubusercontent.com/OpenTSDB/opentsdb.net/gh-pages/COPYING.LESSER'281 'https://raw.githubusercontent.com/OpenTSDB/opentsdb.net/gh-pages/COPYING.LESSER'
282 ], [
283 'Phalcon',
284 '2011-2015 Phalcon Framework Team',
285 'CC BY',
286 'https://docs.phalconphp.com/en/latest/reference/license.html'
282 ], [287 ], [
283 'Phaser',288 'Phaser',
284 '2015 Richard Davey, Photon Storm Ltd.',289 '2015 Richard Davey, Photon Storm Ltd.',
assets/javascripts/views/pages/phalcon.coffee+7−0
@@ -0,0 +1,7 @@
1#= require views/pages/base
2
3class app.views.PhalconPage extends app.views.BasePage
4 afterRender: ->
5 @highlightCode @findAll('pre[class*="php"]'), 'php'
6 @highlightCode @findAll('pre.highlight-html'), 'markup'
7 return
assets/stylesheets/application-dark.css.scss+1−0
@@ -55,6 +55,7 @@ · 54 unmodified lines
55 'pages/node',55 'pages/node',
56 'pages/npm',56 'pages/npm',
57 'pages/opentsdb',57 'pages/opentsdb',
58 'pages/phalcon',
58 'pages/phaser',59 'pages/phaser',
59 'pages/php',60 'pages/php',
60 'pages/phpunit',61 'pages/phpunit',
assets/stylesheets/application.css.scss+1−0
@@ -55,6 +55,7 @@ · 54 unmodified lines
55 'pages/node',55 'pages/node',
56 'pages/npm',56 'pages/npm',
57 'pages/opentsdb',57 'pages/opentsdb',
58 'pages/phalcon',
58 'pages/phaser',59 'pages/phaser',
59 'pages/php',60 'pages/php',
60 'pages/phpunit',61 'pages/phpunit',
assets/stylesheets/global/_icons.scss+1−0
@@ -112,3 +112,4 @@ · 111 unmodified lines
112%icon-expand-white { background-position: -8rem -8rem; }112%icon-expand-white { background-position: -8rem -8rem; }
113%icon-contract-white { background-position: -9rem -8rem; }113%icon-contract-white { background-position: -9rem -8rem; }
114._icon-react_native:before { background-position: 0 -9rem; }114._icon-react_native:before { background-position: 0 -9rem; }
115._icon-phalcon:before { background-position: -1rem -9rem; }
assets/stylesheets/pages/_phalcon.scss+8−0
@@ -0,0 +1,8 @@
1._phalcon {
2 @extend %simple;
3
4 h3 > small {
5 float: right;
6 color: $textColorLight;
7 }
8}
lib/docs/filters/phalcon/clean_html.rb+31−5
@@ -4,12 +4,38 @@ module Docs · 3 unmodified lines
4 def call4 def call
5 @doc = at_css('.body')5 @doc = at_css('.body')
6 6
7 # Remove unnecessary things7 if root_page?
8 css('.headerlink', '#what-is-phalcon', '#other-formats', '#welcome h1', '#welcome p', '#table-of-contents h2').remove8 at_css('h1').content = 'Phalcon'
9 end
10
11 css('#what-is-phalcon', '#other-formats').remove
12
13 css('#methods > p > strong, #constants > p > strong').each do |node|
14 node.parent.name = 'h3'
15 node.parent['id'] = node.content.parameterize
16 node.parent['class'] = 'method-signature'
17 node.parent.inner_html = node.parent.inner_html.sub(/inherited from .*/, '<small>\0</small>')
18 end
19
20 css('.headerlink').each do |node|
21 id = node['href'][1..-1]
22 node.parent['id'] ||= id
23 node.remove
24 end
25
26 css('div[class^="highlight-"]').each do |node|
27 code = node.at_css('pre').content
28 code.remove! %r{\A\s*<\?php\s*} unless code.include?(' ?>')
29 node.content = code
30 node.name = 'pre'
31 end
32
33 css('.section').each do |node|
34 node.before(node.children).remove
35 end
9 36
10 # Add id for constants and methods37 css('table[border]').each do |node|
11 css('#constants strong', '#methods strong').each do |node|38 node.remove_attribute('border')
12 node.parent['id'] = node.content.strip
13 end39 end
14 40
15 doc41 doc
lib/docs/filters/phalcon/entries.rb+10−13
@@ -1,31 +1,28 @@
1module Docs1module Docs
2 class Phalcon2 class Phalcon
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4
5 def get_name4 def get_name
6 node = css('h1').first5 (at_css('h1 > strong') || at_css('h1')).content.strip.remove('Phalcon\\')
7 name = node.content.strip
8 node.remove
9 name
10 end6 end
11 7
12 def get_type8 def get_type
13 if slug.start_with? 'reference'9 if slug.start_with?('reference')
14 'Guides'10 'Guides'
15 else11 else
16 'Classes'12 path = name.split('\\')
13 path[1] == 'Mvc' ? path[1..2].join('\\') : path[1]
17 end14 end
18 end15 end
19 16
20 def additional_entries17 def additional_entries
21 entries = []18 entries = []
22 19
23 css('#constants strong').each do |node|20 css('.method-signature').each do |node|
24 entries << [node.content.strip, node.parent['id'], 'Constants']21 next if node.content.include?('inherited from') || node.content.include?('protected ') || node.content.include?('private ')
25 end22 name = node.at_css('strong').content.strip
26 23 next if name == '__construct' || name == '__toString'
27 css('#methods strong').each do |node|24 name.prepend "#{self.name}::"
28 entries << [node.content.strip, node.parent['id'], 'Methods']25 entries << [name, node['id']]
29 end26 end
30 27
31 entries28 entries
lib/docs/scrapers/phalcon.rb+6−5
@@ -1,8 +1,7 @@
1module Docs1module Docs
2 class Phalcon < UrlScraper2 class Phalcon < UrlScraper
3 self.name = 'Phalcon'
4 self.slug = 'phalcon'
5 self.type = 'phalcon'3 self.type = 'phalcon'
4 self.version = '2.0.6'
6 self.base_url = 'https://docs.phalconphp.com/en/latest/'5 self.base_url = 'https://docs.phalconphp.com/en/latest/'
7 self.root_path = 'index.html'6 self.root_path = 'index.html'
8 self.links = {7 self.links = {
@@ -10,14 +9,16 @@ module Docs · 1 unmodified line
10 code: 'https://github.com/phalcon/cphalcon/'9 code: 'https://github.com/phalcon/cphalcon/'
11 }10 }
12 11
13 html_filters.push 'phalcon/clean_html', 'phalcon/entries', 'title'12 html_filters.push 'phalcon/clean_html', 'phalcon/entries'
14 13
15 options[:root_title] = 'Phalcon'14 options[:root_title] = 'Phalcon'
16 options[:only_patterns] = [/reference\//, /api\//]15 options[:only_patterns] = [/reference\//, /api\//]
17 options[:skip_patterns] = [/api\/index/]16 options[:skip] = %w(
17 api/index.html
18 reference/license.html)
18 19
19 options[:attribution] = <<-HTML20 options[:attribution] = <<-HTML
20 &copy; 2012&ndash;2015 the Phalcon Team<br>21 &copy; 2011&ndash;2015 Phalcon Framework Team<br>
21 Licensed under the Creative Commons Attribution License 3.0.22 Licensed under the Creative Commons Attribution License 3.0.
22 HTML23 HTML
23 end24 end
public/icons/docs/phalcon/16.png+0−0

Binary file not shown.

public/icons/docs/phalcon/16@2x.png+0−0

Binary file not shown.