Răsfoiți Sursa

Add Fish Documentation

Phil Scherer 9 ani în urmă
părinte
comite
e25b0542c3

+ 1 - 0
assets/stylesheets/pages/_simple.scss

@@ -20,6 +20,7 @@
 ._apache_pig,
 ._chai,
 ._docker,
+._fish,
 ._gnu,
 ._grunt,
 ._haxe,

+ 30 - 0
lib/docs/filters/fish/clean_html.rb

@@ -0,0 +1,30 @@
+module Docs
+  class Fish
+    class CleanHtmlFilter < Filter
+      def call
+        @doc = at_css('.fish_right_bar')
+
+        css('hr').remove
+
+        css('h2').each do |node|
+          node.name = 'h3'
+        end
+
+        css('h1').drop(1).each do |node|
+          node.name = 'h2'
+        end
+
+        css('h2 > a').each do |node|
+          node.parent['id'] = node['id']
+        end
+
+        css('pre').each do |node|
+          node['class'] = 'fish' # Prism may support fish in the future
+          node.content = node.content
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 19 - 0
lib/docs/filters/fish/entries.rb

@@ -0,0 +1,19 @@
+module Docs
+  class Fish
+    class EntriesFilter < Docs::EntriesFilter
+
+      def include_default_entry?
+        false
+      end
+
+      def additional_entries
+        css('h2').each_with_object [] do |node, entries|
+          name = node.content.split(' - ').first
+          id = node['id']
+          type = root_page? ? 'Reference' : (slug == 'faq' ? 'FAQ' : slug.capitalize)
+          entries << [name, id, type]
+        end
+      end
+    end
+  end
+end

+ 36 - 0
lib/docs/scrapers/fish.rb

@@ -0,0 +1,36 @@
+module Docs
+  class Fish < UrlScraper
+    self.name = 'Fish'
+    self.type = 'fish'
+    self.links = {
+      home: 'http://fishshell.com/',
+      code: 'https://github.com/fish-shell/fish-shell'
+    }
+
+    html_filters.push 'fish/clean_html', 'fish/entries'
+
+    options[:only] = %w(
+      index.html
+      tutorial.html
+      commands.html
+      faq.html
+    )
+
+    options[:attribution] = <<-HTML
+      &copy; 2005&ndash;2009 Axel Liljencrantz<br>
+      &copy; 2009&ndash;2016 The fish contributors<br>
+      Licensed under the GNU General Public License, version 2.
+    HTML
+
+    version '2.3' do
+      self.release = '2.3.1'
+      self.base_url = "http://fishshell.com/docs/#{version}/"
+      self.root_path = 'index.html'
+    end
+    version '2.2' do
+      self.release = '2.2.0'
+      self.base_url = "http://fishshell.com/docs/#{version}/"
+      self.root_path = 'index.html'
+    end
+  end
+end

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

@@ -0,0 +1 @@
+https://github.com/fish-shell/fish-shell/blob/master/doc_src/ascii_fish.png