Finish Vagrant scraper

pull/292/head
Thibaut 9 years ago
parent e6c90931d5
commit de1c879730

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 91 KiB

@ -1,7 +1,7 @@
[
[
"2015-11-08",
"New documentation: <a href=\"/elixir/\">Elixir</a>"
"New documentations: <a href=\"/elixir/\">Elixir</a> and <a href=\"/vagrant/\">Vagrant</a>"
], [
"2015-10-18",
"Added a \"Copy to clipboard\" button inside each code block."

@ -379,6 +379,11 @@ credits = [
'2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',
'MIT',
'https://raw.github.com/jashkenas/underscore/master/LICENSE'
], [
'Vagrant',
'2010-2015 Mitchell Hashimoto',
'MIT',
'https://raw.githubusercontent.com/mitchellh/vagrant/master/LICENSE'
], [
'Vue.js',
'2013-2015 Evan You, Vue.js contributors',

@ -0,0 +1,5 @@
#= require views/pages/base
class app.views.VagrantPage extends app.views.BasePage
prepare: ->
@highlightCode @findAll('pre.ruby'), 'ruby'

@ -72,6 +72,7 @@
'pages/socketio',
'pages/sphinx',
'pages/underscore',
'pages/vagrant',
'pages/vue',
'pages/yard',
'pages/yii';

@ -72,6 +72,7 @@
'pages/socketio',
'pages/sphinx',
'pages/underscore',
'pages/vagrant',
'pages/vue',
'pages/yard',
'pages/yii';

@ -117,3 +117,4 @@
%icon-clipboard { background-position: -2rem -9rem; }
%icon-clipboard-white { background-position: -3rem -9rem; }
._icon-elixir:before { background-position: -4rem -9rem; @extend %darkIconFix !optional; }
._icon-vagrant:before { background-position: -5rem -9rem; }

@ -0,0 +1,9 @@
._vagrant {
@extend %simple;
.alert { @extend %note; }
.prev-button { float: left; }
.prev-button:before { content: '\2190 '; }
.next-button { float: right; }
.next-button:after { content: ' \2192'; }
}

@ -2,14 +2,12 @@ module Docs
class Vagrant
class CleanHtmlFilter < Filter
def call
if root_page?
doc.children = css('h1, .category')
return doc
end
@doc = at_css('.page-contents .span8')
css('nav', '.sidebar', 'footer').remove
css('hr').remove
css('.wrapper', '.page', '.container', '.row', '.page-contents', '.span8').each do |node|
css('pre > code').each do |node|
node.parent['class'] = node['class']
node.before(node.children).remove
end

@ -3,59 +3,32 @@ module Docs
class EntriesFilter < Docs::EntriesFilter
def get_name
if slug.start_with?('push/')
if at_css('h2')
name = at_css('h2').content.strip
else
name = at_css('h1').content.strip
end
name
else
name = at_css('h1').content.strip
name
name = at_css('h2').try(:content)
elsif slug.start_with?('cli/')
name = at_css('h1 + p > strong > code').try(:content).try(:[], /\s*vagrant\s+[\w\-]+/)
end
name || at_css('h1').content
end
def get_type
if slug.start_with?('why-vagrant')
'Why Vagrant?'
elsif slug.start_with?('installation')
'Installation'
elsif slug.start_with?('getting-started')
'Getting Started'
elsif slug.start_with?('cli')
'Command-Line Interface'
elsif slug.start_with?('share')
'Vagrant Share'
elsif slug.start_with?('vagrantfile')
'Vagrantfile'
elsif slug.start_with?('boxes')
'Boxes'
elsif slug.start_with?('provisioning')
'Provisioning'
elsif slug.start_with?('networking')
'Networking'
elsif slug.start_with?('synced-folders')
'Synced Folders'
elsif slug.start_with?('multi-machine')
'Multi-Machine'
elsif slug.start_with?('providers')
'Providers'
elsif slug.start_with?('plugins')
'Plugins'
elsif slug.start_with?('push')
'Push'
elsif slug.start_with?('other')
'Other'
elsif slug.start_with?('vmware')
'VMware'
elsif slug.start_with?('docker')
'Docker'
elsif slug.start_with?('virtualbox')
'VirtualBox'
elsif slug.start_with?('hyperv')
'Hyper-V'
at_css('.sidebar-nav li.current').content
end
def additional_entries
case at_css('h1 + p > strong > code').try(:content)
when /config\./
h2 = nil
css('.page-contents .span8 > *').each_with_object [] do |node, entries|
if node.name == 'h2'
h2 = node.content
elsif h2 == 'Available Settings' && (code = node.at_css('code')) && (name = code.content) && name.start_with?('config.')
id = code.parent['id'] = name.parameterize
entries << [name, id, 'Config']
end
end
else
'Overview'
[]
end
end
end

@ -1,15 +1,15 @@
module Docs
class Vagrant < UrlScraper
self.name = 'Vagrant'
self.slug = 'vagrant'
self.type = 'vagrant'
self.version = '1.7.4'
self.base_url = 'http://docs.vagrantup.com/v2/'
self.base_url = 'https://docs.vagrantup.com/v2/'
self.links = {
home: 'http://www.vagrantup.com/'
home: 'https://www.vagrantup.com/',
code: 'https://github.com/mitchellh/vagrant'
}
html_filters.push 'vagrant/clean_html', 'vagrant/entries'
html_filters.push 'vagrant/entries', 'vagrant/clean_html'
options[:attribution] = <<-HTML
&copy; 2010&ndash;2015 Mitchell Hashimoto<br>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 863 B

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Loading…
Cancel
Save