[devdocsgjs/main: 1161/1867] Update Fish scraper




commit be80d182e5ee4621bcba33aba66aa05e2fe8b55c
Author: Phil Scherer <pnscher evoforge org>
Date:   Sun Nov 15 00:00:15 2020 +0000

    Update Fish scraper

 .../fish/{clean_html.rb => clean_html_custom.rb}   |   2 +-
 lib/docs/filters/fish/clean_html_sphinx.rb         |  10 ++++++
 .../filters/fish/{entries.rb => entries_custom.rb} |   2 +-
 lib/docs/filters/fish/entries_sphinx.rb            |  39 +++++++++++++++++++++
 lib/docs/scrapers/fish.rb                          |  25 +++++++++++--
 public/icons/docs/fish/16.png                      | Bin 115 -> 6538 bytes
 public/icons/docs/fish/16 2x png                   | Bin 134 -> 1504 bytes
 public/icons/docs/fish/SOURCE                      |   1 +
 8 files changed, 74 insertions(+), 5 deletions(-)
---
diff --git a/lib/docs/filters/fish/clean_html.rb b/lib/docs/filters/fish/clean_html_custom.rb
similarity index 93%
rename from lib/docs/filters/fish/clean_html.rb
rename to lib/docs/filters/fish/clean_html_custom.rb
index 230f29e4..3fd146b8 100644
--- a/lib/docs/filters/fish/clean_html.rb
+++ b/lib/docs/filters/fish/clean_html_custom.rb
@@ -1,6 +1,6 @@
 module Docs
   class Fish
-    class CleanHtmlFilter < Filter
+    class CleanHtmlCustomFilter < Filter
       def call
         @doc = at_css('.fish_right_bar')
 
diff --git a/lib/docs/filters/fish/clean_html_sphinx.rb b/lib/docs/filters/fish/clean_html_sphinx.rb
new file mode 100755
index 00000000..1d59c13b
--- /dev/null
+++ b/lib/docs/filters/fish/clean_html_sphinx.rb
@@ -0,0 +1,10 @@
+module Docs
+  class Fish
+    class CleanHtmlSphinxFilter < Filter
+      def call
+        @doc = at_css('.body')
+        doc
+      end
+    end
+  end
+end
diff --git a/lib/docs/filters/fish/entries.rb b/lib/docs/filters/fish/entries_custom.rb
similarity index 91%
rename from lib/docs/filters/fish/entries.rb
rename to lib/docs/filters/fish/entries_custom.rb
index 9c30f750..0ee9ddf6 100644
--- a/lib/docs/filters/fish/entries.rb
+++ b/lib/docs/filters/fish/entries_custom.rb
@@ -1,6 +1,6 @@
 module Docs
   class Fish
-    class EntriesFilter < Docs::EntriesFilter
+    class EntriesCustomFilter < Docs::EntriesFilter
       def get_name
         if slug == 'faq'
           'FAQ'
diff --git a/lib/docs/filters/fish/entries_sphinx.rb b/lib/docs/filters/fish/entries_sphinx.rb
new file mode 100755
index 00000000..f4fc939d
--- /dev/null
+++ b/lib/docs/filters/fish/entries_sphinx.rb
@@ -0,0 +1,39 @@
+module Docs
+  class Fish
+    class EntriesSphinxFilter < Docs::EntriesFilter
+      def get_name
+        if slug == 'faq'
+          'FAQ'
+        elsif slug.starts_with?('cmds/')
+          slug.split('/').last
+        else
+          slug.capitalize
+        end
+      end
+
+      def get_type
+        if root_page? || slug == 'faq'
+          'Manual'
+        elsif slug.starts_with?('cmds')
+          'Commands'
+        elsif slug == 'tutorial'
+          'Tutorial'
+        else
+          nil # Remaining pages are indexes we don't need
+        end
+      end
+
+      def additional_entries
+        if root_page? || slug == 'tutorial'
+          css('h2').map.with_index do |node, i|
+            name = node.content.split(' - ').first.strip
+            name.prepend "#{i + 1}. "
+            [name, node['id'], get_type]
+          end
+        else
+          []
+        end
+      end
+    end
+  end
+end
diff --git a/lib/docs/scrapers/fish.rb b/lib/docs/scrapers/fish.rb
index a8b1ce8b..b57dbd9f 100644
--- a/lib/docs/scrapers/fish.rb
+++ b/lib/docs/scrapers/fish.rb
@@ -8,49 +8,68 @@ module Docs
       code: 'https://github.com/fish-shell/fish-shell'
     }
 
-    html_filters.push 'fish/clean_html', 'fish/entries'
-
     options[:skip] = %w(design.html license.html)
 
     # https://fishshell.com/docs/current/license.html
     options[:attribution] = <<-HTML
-      &copy; 2005&ndash;2009 Axel Liljencrantz<br>
+      &copy; 2019 fish-shell developers<br>
       Licensed under the GNU General Public License, version 2.
     HTML
 
+    version '3.1' do
+      self.release = '3.1.2'
+      self.base_url = "https://fishshell.com/docs/#{version}/";
+
+      html_filters.push 'sphinx/clean_html', 'fish/clean_html_sphinx', 'fish/entries_sphinx'
+    end
+
     version '3.0' do
       self.release = '3.0.1'
       self.base_url = "https://fishshell.com/docs/#{version}/";
+
+      html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
     end
 
     version '2.7' do
       self.release = '2.7.1'
       self.base_url = "https://fishshell.com/docs/#{version}/";
+
+      html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
     end
 
     version '2.6' do
       self.release = '2.6.0'
       self.base_url = "https://fishshell.com/docs/#{version}/";
+
+      html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
     end
 
     version '2.5' do
       self.release = '2.5.0'
       self.base_url = "https://fishshell.com/docs/#{version}/";
+
+      html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
     end
 
     version '2.4' do
       self.release = '2.4.0'
       self.base_url = "https://fishshell.com/docs/#{version}/";
+
+      html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
     end
 
     version '2.3' do
       self.release = '2.3.1'
       self.base_url = "https://fishshell.com/docs/#{version}/";
+
+      html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
     end
 
     version '2.2' do
       self.release = '2.2.0'
       self.base_url = "https://fishshell.com/docs/#{version}/";
+
+      html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
     end
 
     def get_latest_version(opts)
diff --git a/public/icons/docs/fish/16.png b/public/icons/docs/fish/16.png
index aea9980a..6baa7a83 100644
Binary files a/public/icons/docs/fish/16.png and b/public/icons/docs/fish/16.png differ
diff --git a/public/icons/docs/fish/16 2x png b/public/icons/docs/fish/16 2x png
index 848b77f2..6101c029 100644
Binary files a/public/icons/docs/fish/16 2x png and b/public/icons/docs/fish/16 2x png differ
diff --git a/public/icons/docs/fish/SOURCE b/public/icons/docs/fish/SOURCE
new file mode 100644
index 00000000..6043fbfb
--- /dev/null
+++ b/public/icons/docs/fish/SOURCE
@@ -0,0 +1 @@
+https://fishshell.com/favicon.ico


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]