History

Finish Fish scraper

Thibaut Courouble committed 10 years ago

Commit 575e5591 parent e25b05411 files · +29 −19Browse files

Unified · Split

11 files
  1. assets/images/docs.png +0 −0
  2. assets/images/docs@2x.png +0 −0
  3. assets/javascripts/news.json +1 −1
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/stylesheets/global/_icons.scss +1 −0
  6. lib/docs/filters/fish/clean_html.rb +2 −2
  7. lib/docs/filters/fish/entries.rb +18 −7
  8. lib/docs/scrapers/fish.rb +6 −12
  9. public/icons/docs/fish/16.png +0 −0
  10. public/icons/docs/fish/16@2x.png +0 −0
  11. public/icons/docs/fish/SOURCE +0 −1
assets/images/docs.png+0−0

Binary file not shown.

assets/images/docs@2x.png+0−0

Binary file not shown.

assets/javascripts/news.json+1−1
@@ -1,7 +1,7 @@
11 [
22 [
33 "2016-09-05",
4− "New documentation: <a href=\"/bottle/\">Bottle</a>"
4+ "New documentations: <a href=\"/fish/\">Fish</a> and <a href=\"/bottle/\">Bottle</a>"
55 ], [
66 "2016-08-07",
77 "New documentation: <a href=\"/docker/\">Docker</a>"
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -219,6 +219,11 @@ credits = [ · 218 unmodified lines
219219 '2016 StrongLoop, IBM, and other expressjs.com contributors.',
220220 'Unknown',
221221 'https://github.com/expressjs/expressjs.com/issues/413'
222+ ], [
223+ 'Fish',
224+ '2005-2009 Axel Liljencrantz',
225+ 'GPLv2',
226+ 'https://fishshell.com/docs/current/license.html'
222227 ], [
223228 'GCC<br>GNU Fortran',
224229 'Free Software Foundation',
assets/stylesheets/global/_icons.scss+1−0
@@ -116,6 +116,7 @@ · 115 unmodified lines
116116 ._icon-socketio:before { background-position: -2rem -6rem; }
117117 ._icon-modernizr:before { background-position: -3rem -6rem; }
118118 ._icon-bower:before { background-position: -4rem -6rem; }
119+._icon-fish:before { background-position: -5rem -6rem; @extend %darkIconFix !optional; }
119120 ._icon-bottle:before { background-position: 0 -7rem; }
120121 ._icon-docker:before { background-position: -1rem -7rem; }
121122 ._icon-cakephp:before { background-position: -2rem -7rem; }
lib/docs/filters/fish/clean_html.rb+2−2
@@ -14,12 +14,12 @@ module Docs · 13 unmodified lines
1414 node.name = 'h2'
1515 end
1616
17− css('h2 > a').each do |node|
17+ css('.anchor').each do |node|
1818 node.parent['id'] = node['id']
1919 end
2020
2121 css('pre').each do |node|
22− node['class'] = 'fish' # Prism may support fish in the future
22+ node['data-language'] = 'fish' # Prism may support fish in the future
2323 node.content = node.content
2424 end
2525
lib/docs/filters/fish/entries.rb+18−7
@@ -1,17 +1,28 @@
11 module Docs
22 class Fish
33 class EntriesFilter < Docs::EntriesFilter
4+ def get_name
5+ if slug == 'faq'
6+ 'FAQ'
7+ else
8+ slug.capitalize
9+ end
10+ end
411
5− def include_default_entry?
6− false
12+ def get_type
13+ if root_page? || slug == 'faq'
14+ 'Manual'
15+ else
16+ name
17+ end
718 end
819
920 def additional_entries
10− css('h2').each_with_object [] do |node, entries|
11− name = node.content.split(' - ').first
12− id = node['id']
13− type = root_page? ? 'Reference' : (slug == 'faq' ? 'FAQ' : slug.capitalize)
14− entries << [name, id, type]
21+ return [] if slug == 'faq'
22+ css('h2').map.with_index do |node, i|
23+ name = node.content.split(' - ').first.strip
24+ name.prepend "#{i + 1}. " unless slug == 'commands'
25+ [name, node['id'], get_type]
1526 end
1627 end
1728 end
lib/docs/scrapers/fish.rb+6−12
@@ -2,35 +2,29 @@ module Docs · 1 unmodified line
22 class Fish < UrlScraper
33 self.name = 'Fish'
44 self.type = 'fish'
5+ self.root_path = 'index.html'
56 self.links = {
6− home: 'http://fishshell.com/',
7+ home: 'https://fishshell.com/',
78 code: 'https://github.com/fish-shell/fish-shell'
89 }
910
1011 html_filters.push 'fish/clean_html', 'fish/entries'
1112
12− options[:only] = %w(
13− index.html
14− tutorial.html
15− commands.html
16− faq.html
17− )
13+ options[:skip] = %w(design.html license.html)
1814
1915 options[:attribution] = <<-HTML
2016 &copy; 2005&ndash;2009 Axel Liljencrantz<br>
21− &copy; 2009&ndash;2016 The fish contributors<br>
2217 Licensed under the GNU General Public License, version 2.
2318 HTML
2419
2520 version '2.3' do
2621 self.release = '2.3.1'
27− self.base_url = "http://fishshell.com/docs/#{version}/"
28− self.root_path = 'index.html'
22+ self.base_url = "https://fishshell.com/docs/#{version}/"
2923 end
24+
3025 version '2.2' do
3126 self.release = '2.2.0'
32− self.base_url = "http://fishshell.com/docs/#{version}/"
33− self.root_path = 'index.html'
27+ self.base_url = "https://fishshell.com/docs/#{version}/"
3428 end
3529 end
3630 end
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+0−1
@@ -1 +0,0 @@
1−https://github.com/fish-shell/fish-shell/blob/master/doc_src/ascii_fish.png