Finish Codeception scraper

This commit is contained in:
Thibaut Courouble 2016-12-04 17:44:42 -05:00
parent 72ab343572
commit 802a8d3804
13 changed files with 69 additions and 71 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 137 KiB

View file

@ -1,7 +1,7 @@
[
[
"2016-12-04",
"New documentation: <a href=\"/sqlite/\">SQLite</a>"
"New documentations: <a href=\"/sqlite/\">SQLite</a> and <a href=\"/codeception/\">Codeception</a>"
], [
"2016-11-20",
"New documentations: <a href=\"/yarn/\">Yarn</a>, <a href=\"/immutable/\">Immutable.js</a> and <a href=\"/async/\">Async</a>"

View file

@ -154,6 +154,11 @@ credits = [
'2000-2016 Kitware, Inc.<br>&copy; 2000-2011 Insight Software Consortium',
'BSD',
'https://cmake.org/licensing/'
], [
'Codeception',
'2011-2016 Michael Bodnarchuk and contributors',
'MIT',
'https://raw.githubusercontent.com/Codeception/Codeception/master/LICENSE'
], [
'CodeIgniter',
'2014-2016 British Columbia Institute of Technology',

View file

@ -1,10 +0,0 @@
#= require views/pages/base
class app.views.CodeceptionPage extends app.views.BasePage
LANGUAGE_RGX = /language-(\w+)/
prepare: ->
for el in @findAll('pre > code')
if el.className.match(LANGUAGE_RGX)
@highlightCode(el, el.className.match(LANGUAGE_RGX)[1])
return

View file

@ -14,6 +14,7 @@ app.views.BowerPage =
app.views.CPage =
app.views.CakephpPage =
app.views.ChaiPage =
app.views.CodeceptionPage =
app.views.CoffeescriptPage =
app.views.CordovaPage =
app.views.CrystalPage =

View file

@ -56,6 +56,7 @@
%icon-close-white { background-position: -2rem -5rem; }
%icon-back { background-position: -3rem -5rem; @extend %darkIconFix !optional; }
._icon-codeception:before { background-position: -4rem 0; }
._icon-sqlite:before { background-position: -5rem 0; @extend %darkIconFix !optional; }
._icon-async:before { background-position: -6rem 0; @extend %darkIconFix !optional; }
._icon-http:before { background-position: -7rem 0; @extend %darkIconFix !optional; }

View file

@ -1,29 +1,7 @@
._codeception {
@extend %simple;
.warning, .alert {
@extend %note;
}
h4 {
@extend %block-label;
}
h4 { @extend %block-label; }
.warning, .alert { @extend %note; }
.alert-danger { @extend %note-red; }
.language-yaml {
@extend .token;
.c1 {
@extend .token.comment;
}
.pi {
@extend .token.operator;
}
.s {
@extend .token.string;
}
}
}

View file

@ -2,17 +2,40 @@ module Docs
class Codeception
class CleanHtmlFilter < Filter
def call
root_page? ? root : other
doc
end
def root
doc.inner_html = ' '
end
def other
@doc = doc.at_css('div.page, div.content')
while doc.element_children.length == 1
doc.first_element_child.before(doc.first_element_child.children).remove
end
if root_page?
at_css('h1').content = 'Codeception Documentation'
end
unless at_css('h1')
at_css('h2').name = 'h1'
end
unless at_css('h2')
css('h3').each { |node| node.name = 'h2' }
css('h4').each { |node| node.name = 'h3' }
end
css('.btn-group').remove
css('.alert:last-child').each do |node|
node.remove if node.content.include?('taken from the source code')
end
css('.highlight').each do |node|
node.before(node.children).remove
end
css('pre > code').each do |node|
node.parent['data-language'] = node['data-lang']
node.parent.content = node.parent.content
end
doc
end
end

View file

@ -2,46 +2,48 @@ module Docs
class Codeception
class EntriesFilter < Docs::EntriesFilter
def get_name
(subpath.scan(/\d\d/).first || '') + ' ' + (at_css('h1') || at_css('h2')).content
name = (at_css('h1') || at_css('h2')).content
if number = subpath[/\A\d+/]
name.prepend "#{number.to_i}. "
end
name
end
def get_type
return 'Module::' + (at_css('h1') || at_css('h2')).content if subpath.start_with?('modules')
return 'Guides' if subpath =~ /\d\d/
(at_css('h1') || at_css('h2')).content
end
def include_default_entry?
return true if %w(Guides).include? type
return true if type =~ /(Module)|(Util)/
false
if subpath =~ /\d\d/
'Guides'
elsif subpath.start_with?('modules')
"Module: #{name}"
elsif name.include?('Util')
"Util Class: #{name.split('\\').last}"
else
"Reference: #{name}"
end
end
def additional_entries
if type =~ /Module/
prefix = type.sub(/Module::/, '')+ '::'
prefix = "#{name}::"
pattern = '#actions ~ h4'
elsif type =~ /Functions/
prefix = ''
pattern = 'h4'
elsif type =~ /Util/
prefix = type.sub(/Codeception\/Util/, '')+ '::'
pattern = '#page h4'
elsif name =~ /Util/
prefix = "#{name.remove('Codeception\\Util\\')}::"
pattern = 'h3'
elsif type =~ /(Commands)|(Configuration)/
prefix = ''
pattern = 'h2'
else
prefix = ''
pattern = 'none'
pattern = 'h2'
end
return [] unless pattern
css(pattern).map do |node|
[prefix + node.content, node['id']]
end.compact
end
end
end
end

View file

@ -2,22 +2,20 @@ module Docs
class Codeception < UrlScraper
self.name = 'Codeception'
self.type = 'codeception'
self.root_path = 'index.html'
self.release = '2.2'
self.release = '2.2.6'
self.base_url = 'http://codeception.com/docs/'
self.root_path = 'index.html'
self.links = {
home: 'http://codeception.com/',
code: 'https://github.com/codeception/codeception'
}
html_filters.push 'codeception/clean_html', 'codeception/entries', 'title'
html_filters.push 'codeception/entries', 'codeception/clean_html'
options[:root_title] = 'Codeception'
options[:title] = false
options[:skip_patterns] = [/install/]
options[:attribution] = <<-HTML
&copy; 20112016 Michael Bodnarchuk and Contributors<br>
&copy; 2011&ndash;2016 Michael Bodnarchuk and contributors<br>
Licensed under the MIT License.
HTML
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 521 B

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB