Bladeren bron

Add Vagrant documentation

Lyubomir Popov 10 jaren geleden
bovenliggende
commit
e6c90931d5

+ 20 - 0
lib/docs/filters/vagrant/clean_html.rb

@@ -0,0 +1,20 @@
+module Docs
+  class Vagrant
+    class CleanHtmlFilter < Filter
+      def call
+        if root_page?
+          doc.children = css('h1, .category')
+          return doc
+        end
+
+        css('nav', '.sidebar', 'footer').remove
+
+        css('.wrapper', '.page', '.container', '.row', '.page-contents', '.span8').each do |node|
+          node.before(node.children).remove
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 63 - 0
lib/docs/filters/vagrant/entries.rb

@@ -0,0 +1,63 @@
+module Docs
+  class Vagrant
+    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
+        end
+      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'
+        else
+          'Overview'
+        end
+      end
+    end
+  end
+end

+ 19 - 0
lib/docs/scrapers/vagrant.rb

@@ -0,0 +1,19 @@
+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.links = {
+      home: 'http://www.vagrantup.com/'
+    }
+
+    html_filters.push 'vagrant/clean_html', 'vagrant/entries'
+
+    options[:attribution] = <<-HTML
+      &copy; 2010&ndash;2015 Mitchell Hashimoto<br>
+      Licensed under the MIT License.
+    HTML
+  end
+end

BIN
public/icons/docs/vagrant/16.png


BIN
public/icons/docs/vagrant/16@2x.png


+ 1 - 0
public/icons/docs/vagrant/SOURCE

@@ -0,0 +1 @@
+http://www.vagrantup.com