Finish Codeception scraper

pull/547/head
Thibaut Courouble 8 years ago
parent 72ab343572
commit 802a8d3804

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

@ -1,7 +1,7 @@
[ [
[ [
"2016-12-04", "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", "2016-11-20",
"New documentations: <a href=\"/yarn/\">Yarn</a>, <a href=\"/immutable/\">Immutable.js</a> and <a href=\"/async/\">Async</a>" "New documentations: <a href=\"/yarn/\">Yarn</a>, <a href=\"/immutable/\">Immutable.js</a> and <a href=\"/async/\">Async</a>"

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

@ -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

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

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

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

@ -2,17 +2,40 @@ module Docs
class Codeception class Codeception
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
root_page? ? root : other @doc = doc.at_css('div.page, div.content')
doc
while doc.element_children.length == 1
doc.first_element_child.before(doc.first_element_child.children).remove
end end
def root if root_page?
doc.inner_html = ' ' 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 end
def other
@doc = doc.at_css('div.page, div.content')
css('.btn-group').remove 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 doc
end end
end end

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

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

Loading…
Cancel
Save