History

Update Fish scraper

Phil Scherer committed 5 years ago

Commit be80d181 parent 674dc1e8 files · +72 −3Browse files

Unified · Split

8 files
  1. lib/docs/filters/fish/clean_html_custom.rb +1 −1
  2. lib/docs/filters/fish/clean_html_sphinx.rb +10 −0
  3. lib/docs/filters/fish/entries_custom.rb +1 −1
  4. lib/docs/filters/fish/entries_sphinx.rb +39 −0
  5. lib/docs/scrapers/fish.rb +22 −3
  6. public/icons/docs/fish/16.png +0 −0
  7. public/icons/docs/fish/16@2x.png +0 −0
  8. public/icons/docs/fish/SOURCE +1 −0
lib/docs/filters/fish/clean_html_custom.rbrenamed from lib/docs/filters/fish/clean_html.rb+1−1
@@ -1,6 +1,6 @@
11 module Docs
22 class Fish
3− class CleanHtmlFilter < Filter
3+ class CleanHtmlCustomFilter < Filter
44 def call
55 @doc = at_css('.fish_right_bar')
66
lib/docs/filters/fish/clean_html_sphinx.rb+10−0
@@ -0,0 +1,10 @@
1+module Docs
2+ class Fish
3+ class CleanHtmlSphinxFilter < Filter
4+ def call
5+ @doc = at_css('.body')
6+ doc
7+ end
8+ end
9+ end
10+end
lib/docs/filters/fish/entries_custom.rbrenamed from lib/docs/filters/fish/entries.rb+1−1
@@ -1,6 +1,6 @@
11 module Docs
22 class Fish
3− class EntriesFilter < Docs::EntriesFilter
3+ class EntriesCustomFilter < Docs::EntriesFilter
44 def get_name
55 if slug == 'faq'
66 'FAQ'
lib/docs/filters/fish/entries_sphinx.rb+39−0
@@ -0,0 +1,39 @@
1+module Docs
2+ class Fish
3+ class EntriesSphinxFilter < Docs::EntriesFilter
4+ def get_name
5+ if slug == 'faq'
6+ 'FAQ'
7+ elsif slug.starts_with?('cmds/')
8+ slug.split('/').last
9+ else
10+ slug.capitalize
11+ end
12+ end
13+
14+ def get_type
15+ if root_page? || slug == 'faq'
16+ 'Manual'
17+ elsif slug.starts_with?('cmds')
18+ 'Commands'
19+ elsif slug == 'tutorial'
20+ 'Tutorial'
21+ else
22+ nil # Remaining pages are indexes we don't need
23+ end
24+ end
25+
26+ def additional_entries
27+ if root_page? || slug == 'tutorial'
28+ css('h2').map.with_index do |node, i|
29+ name = node.content.split(' - ').first.strip
30+ name.prepend "#{i + 1}. "
31+ [name, node['id'], get_type]
32+ end
33+ else
34+ []
35+ end
36+ end
37+ end
38+ end
39+end
lib/docs/scrapers/fish.rb+22−3
@@ -8,49 +8,68 @@ module Docs · 7 unmodified lines
88 code: 'https://github.com/fish-shell/fish-shell'
99 }
1010
11− html_filters.push 'fish/clean_html', 'fish/entries'
12−
1311 options[:skip] = %w(design.html license.html)
1412
1513 # https://fishshell.com/docs/current/license.html
1614 options[:attribution] = <<-HTML
17− &copy; 2005&ndash;2009 Axel Liljencrantz<br>
15+ &copy; 2019 fish-shell developers<br>
1816 Licensed under the GNU General Public License, version 2.
1917 HTML
2018
19+ version '3.1' do
20+ self.release = '3.1.2'
21+ self.base_url = "https://fishshell.com/docs/#{version}/"
22+
23+ html_filters.push 'sphinx/clean_html', 'fish/clean_html_sphinx', 'fish/entries_sphinx'
24+ end
25+
2126 version '3.0' do
2227 self.release = '3.0.1'
2328 self.base_url = "https://fishshell.com/docs/#{version}/"
29+
30+ html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
2431 end
2532
2633 version '2.7' do
2734 self.release = '2.7.1'
2835 self.base_url = "https://fishshell.com/docs/#{version}/"
36+
37+ html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
2938 end
3039
3140 version '2.6' do
3241 self.release = '2.6.0'
3342 self.base_url = "https://fishshell.com/docs/#{version}/"
43+
44+ html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
3445 end
3546
3647 version '2.5' do
3748 self.release = '2.5.0'
3849 self.base_url = "https://fishshell.com/docs/#{version}/"
50+
51+ html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
3952 end
4053
4154 version '2.4' do
4255 self.release = '2.4.0'
4356 self.base_url = "https://fishshell.com/docs/#{version}/"
57+
58+ html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
4459 end
4560
4661 version '2.3' do
4762 self.release = '2.3.1'
4863 self.base_url = "https://fishshell.com/docs/#{version}/"
64+
65+ html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
4966 end
5067
5168 version '2.2' do
5269 self.release = '2.2.0'
5370 self.base_url = "https://fishshell.com/docs/#{version}/"
71+
72+ html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
5473 end
5574
5675 def get_latest_version(opts)
public/icons/docs/fish/16.png+0−0

Binary file not shown.

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

Binary file not shown.

public/icons/docs/fish/SOURCE+1−0
@@ -0,0 +1 @@
1+https://fishshell.com/favicon.ico