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 @@
1module Docs1module Docs
2 class Fish2 class Fish
3 class CleanHtmlFilter < Filter3 class CleanHtmlCustomFilter < Filter
4 def call4 def call
5 @doc = at_css('.fish_right_bar')5 @doc = at_css('.fish_right_bar')
6 6
lib/docs/filters/fish/clean_html_sphinx.rb+10−0
@@ -0,0 +1,10 @@
1module Docs
2 class Fish
3 class CleanHtmlSphinxFilter < Filter
4 def call
5 @doc = at_css('.body')
6 doc
7 end
8 end
9 end
10end
lib/docs/filters/fish/entries_custom.rbrenamed from lib/docs/filters/fish/entries.rb+1−1
@@ -1,6 +1,6 @@
1module Docs1module Docs
2 class Fish2 class Fish
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesCustomFilter < Docs::EntriesFilter
4 def get_name4 def get_name
5 if slug == 'faq'5 if slug == 'faq'
6 'FAQ'6 'FAQ'
lib/docs/filters/fish/entries_sphinx.rb+39−0
@@ -0,0 +1,39 @@
1module 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
39end
lib/docs/scrapers/fish.rb+22−3
@@ -8,49 +8,68 @@ module Docs · 7 unmodified lines
8 code: 'https://github.com/fish-shell/fish-shell'8 code: 'https://github.com/fish-shell/fish-shell'
9 }9 }
10 10
11 html_filters.push 'fish/clean_html', 'fish/entries'
12
13 options[:skip] = %w(design.html license.html)11 options[:skip] = %w(design.html license.html)
14 12
15 # https://fishshell.com/docs/current/license.html13 # https://fishshell.com/docs/current/license.html
16 options[:attribution] = <<-HTML14 options[:attribution] = <<-HTML
17 &copy; 2005&ndash;2009 Axel Liljencrantz<br>15 &copy; 2019 fish-shell developers<br>
18 Licensed under the GNU General Public License, version 2.16 Licensed under the GNU General Public License, version 2.
19 HTML17 HTML
20 18
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
21 version '3.0' do26 version '3.0' do
22 self.release = '3.0.1'27 self.release = '3.0.1'
23 self.base_url = "https://fishshell.com/docs/#{version}/"28 self.base_url = "https://fishshell.com/docs/#{version}/"
29
30 html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
24 end31 end
25 32
26 version '2.7' do33 version '2.7' do
27 self.release = '2.7.1'34 self.release = '2.7.1'
28 self.base_url = "https://fishshell.com/docs/#{version}/"35 self.base_url = "https://fishshell.com/docs/#{version}/"
36
37 html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
29 end38 end
30 39
31 version '2.6' do40 version '2.6' do
32 self.release = '2.6.0'41 self.release = '2.6.0'
33 self.base_url = "https://fishshell.com/docs/#{version}/"42 self.base_url = "https://fishshell.com/docs/#{version}/"
43
44 html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
34 end45 end
35 46
36 version '2.5' do47 version '2.5' do
37 self.release = '2.5.0'48 self.release = '2.5.0'
38 self.base_url = "https://fishshell.com/docs/#{version}/"49 self.base_url = "https://fishshell.com/docs/#{version}/"
50
51 html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
39 end52 end
40 53
41 version '2.4' do54 version '2.4' do
42 self.release = '2.4.0'55 self.release = '2.4.0'
43 self.base_url = "https://fishshell.com/docs/#{version}/"56 self.base_url = "https://fishshell.com/docs/#{version}/"
57
58 html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
44 end59 end
45 60
46 version '2.3' do61 version '2.3' do
47 self.release = '2.3.1'62 self.release = '2.3.1'
48 self.base_url = "https://fishshell.com/docs/#{version}/"63 self.base_url = "https://fishshell.com/docs/#{version}/"
64
65 html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
49 end66 end
50 67
51 version '2.2' do68 version '2.2' do
52 self.release = '2.2.0'69 self.release = '2.2.0'
53 self.base_url = "https://fishshell.com/docs/#{version}/"70 self.base_url = "https://fishshell.com/docs/#{version}/"
71
72 html_filters.push 'fish/clean_html_custom', 'fish/entries_custom'
54 end73 end
55 74
56 def get_latest_version(opts)75 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 @@
1https://fishshell.com/favicon.ico