History

Finish Vagrant scraper

Thibaut committed 11 years ago

Commit de1c8791 parent e6c909314 files · +48 −55Browse 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 +1 −1
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/javascripts/views/pages/vagrant.coffee +5 −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/_vagrant.scss +9 −0
  10. lib/docs/filters/vagrant/clean_html.rb +4 −6
  11. lib/docs/filters/vagrant/entries.rb +21 −48
  12. lib/docs/scrapers/vagrant.rb +4 −4
  13. public/icons/docs/vagrant/16.png +0 −0
  14. public/icons/docs/vagrant/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+1−1
@@ -1,7 +1,7 @@
11 [
22 [
33 "2015-11-08",
4− "New documentation: <a href=\"/elixir/\">Elixir</a>"
4+ "New documentations: <a href=\"/elixir/\">Elixir</a> and <a href=\"/vagrant/\">Vagrant</a>"
55 ], [
66 "2015-10-18",
77 "Added a \"Copy to clipboard\" button inside each code block."
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -379,6 +379,11 @@ credits = [ · 378 unmodified lines
379379 '2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',
380380 'MIT',
381381 'https://raw.github.com/jashkenas/underscore/master/LICENSE'
382+ ], [
383+ 'Vagrant',
384+ '2010-2015 Mitchell Hashimoto',
385+ 'MIT',
386+ 'https://raw.githubusercontent.com/mitchellh/vagrant/master/LICENSE'
382387 ], [
383388 'Vue.js',
384389 '2013-2015 Evan You, Vue.js contributors',
assets/javascripts/views/pages/vagrant.coffee+5−0
@@ -0,0 +1,5 @@
1+#= require views/pages/base
2+
3+class app.views.VagrantPage extends app.views.BasePage
4+ prepare: ->
5+ @highlightCode @findAll('pre.ruby'), 'ruby'
assets/stylesheets/application-dark.css.scss+1−0
@@ -72,6 +72,7 @@ · 71 unmodified lines
7272 'pages/socketio',
7373 'pages/sphinx',
7474 'pages/underscore',
75+ 'pages/vagrant',
7576 'pages/vue',
7677 'pages/yard',
7778 'pages/yii';
assets/stylesheets/application.css.scss+1−0
@@ -72,6 +72,7 @@ · 71 unmodified lines
7272 'pages/socketio',
7373 'pages/sphinx',
7474 'pages/underscore',
75+ 'pages/vagrant',
7576 'pages/vue',
7677 'pages/yard',
7778 'pages/yii';
assets/stylesheets/global/_icons.scss+1−0
@@ -117,3 +117,4 @@ · 116 unmodified lines
117117 %icon-clipboard { background-position: -2rem -9rem; }
118118 %icon-clipboard-white { background-position: -3rem -9rem; }
119119 ._icon-elixir:before { background-position: -4rem -9rem; @extend %darkIconFix !optional; }
120+._icon-vagrant:before { background-position: -5rem -9rem; }
assets/stylesheets/pages/_vagrant.scss+9−0
@@ -0,0 +1,9 @@
1+._vagrant {
2+ @extend %simple;
3+
4+ .alert { @extend %note; }
5+ .prev-button { float: left; }
6+ .prev-button:before { content: '\2190 '; }
7+ .next-button { float: right; }
8+ .next-button:after { content: ' \2192'; }
9+}
lib/docs/filters/vagrant/clean_html.rb+4−6
@@ -2,14 +2,12 @@ module Docs · 1 unmodified line
22 class Vagrant
33 class CleanHtmlFilter < Filter
44 def call
5− if root_page?
6− doc.children = css('h1, .category')
7− return doc
8− end
5+ @doc = at_css('.page-contents .span8')
96
10− css('nav', '.sidebar', 'footer').remove
7+ css('hr').remove
118
12− css('.wrapper', '.page', '.container', '.row', '.page-contents', '.span8').each do |node|
9+ css('pre > code').each do |node|
10+ node.parent['class'] = node['class']
1311 node.before(node.children).remove
1412 end
1513
lib/docs/filters/vagrant/entries.rb+21−48
@@ -3,59 +3,32 @@ module Docs · 2 unmodified lines
33 class EntriesFilter < Docs::EntriesFilter
44 def get_name
55 if slug.start_with?('push/')
6− if at_css('h2')
7− name = at_css('h2').content.strip
8− else
9− name = at_css('h1').content.strip
10− end
11− name
12− else
13− name = at_css('h1').content.strip
14− name
6+ name = at_css('h2').try(:content)
7+ elsif slug.start_with?('cli/')
8+ name = at_css('h1 + p > strong > code').try(:content).try(:[], /\s*vagrant\s+[\w\-]+/)
159 end
10+
11+ name || at_css('h1').content
1612 end
1713
1814 def get_type
19− if slug.start_with?('why-vagrant')
20− 'Why Vagrant?'
21− elsif slug.start_with?('installation')
22− 'Installation'
23− elsif slug.start_with?('getting-started')
24− 'Getting Started'
25− elsif slug.start_with?('cli')
26− 'Command-Line Interface'
27− elsif slug.start_with?('share')
28− 'Vagrant Share'
29− elsif slug.start_with?('vagrantfile')
30− 'Vagrantfile'
31− elsif slug.start_with?('boxes')
32− 'Boxes'
33− elsif slug.start_with?('provisioning')
34− 'Provisioning'
35− elsif slug.start_with?('networking')
36− 'Networking'
37− elsif slug.start_with?('synced-folders')
38− 'Synced Folders'
39− elsif slug.start_with?('multi-machine')
40− 'Multi-Machine'
41− elsif slug.start_with?('providers')
42− 'Providers'
43− elsif slug.start_with?('plugins')
44− 'Plugins'
45− elsif slug.start_with?('push')
46− 'Push'
47− elsif slug.start_with?('other')
48− 'Other'
49− elsif slug.start_with?('vmware')
50− 'VMware'
51− elsif slug.start_with?('docker')
52− 'Docker'
53− elsif slug.start_with?('virtualbox')
54− 'VirtualBox'
55− elsif slug.start_with?('hyperv')
56− 'Hyper-V'
15+ at_css('.sidebar-nav li.current').content
16+ end
17+
18+ def additional_entries
19+ case at_css('h1 + p > strong > code').try(:content)
20+ when /config\./
21+ h2 = nil
22+ css('.page-contents .span8 > *').each_with_object [] do |node, entries|
23+ if node.name == 'h2'
24+ h2 = node.content
25+ elsif h2 == 'Available Settings' && (code = node.at_css('code')) && (name = code.content) && name.start_with?('config.')
26+ id = code.parent['id'] = name.parameterize
27+ entries << [name, id, 'Config']
28+ end
29+ end
5730 else
58− 'Overview'
31+ []
5932 end
6033 end
6134 end
lib/docs/scrapers/vagrant.rb+4−4
@@ -1,15 +1,15 @@
11 module Docs
22 class Vagrant < UrlScraper
33 self.name = 'Vagrant'
4− self.slug = 'vagrant'
54 self.type = 'vagrant'
65 self.version = '1.7.4'
7− self.base_url = 'http://docs.vagrantup.com/v2/'
6+ self.base_url = 'https://docs.vagrantup.com/v2/'
87 self.links = {
9− home: 'http://www.vagrantup.com/'
8+ home: 'https://www.vagrantup.com/',
9+ code: 'https://github.com/mitchellh/vagrant'
1010 }
1111
12− html_filters.push 'vagrant/clean_html', 'vagrant/entries'
12+ html_filters.push 'vagrant/entries', 'vagrant/clean_html'
1313
1414 options[:attribution] = <<-HTML
1515 &copy; 2010&ndash;2015 Mitchell Hashimoto<br>
public/icons/docs/vagrant/16.png+0−0

Binary file not shown.

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

Binary file not shown.