From be80d182e5ee4621bcba33aba66aa05e2fe8b55c Mon Sep 17 00:00:00 2001 From: Phil Scherer Date: Sun, 15 Nov 2020 00:00:15 +0000 Subject: [PATCH] Update Fish scraper --- .../{clean_html.rb => clean_html_custom.rb} | 2 +- lib/docs/filters/fish/clean_html_sphinx.rb | 10 +++++ .../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(-) rename lib/docs/filters/fish/{clean_html.rb => clean_html_custom.rb} (93%) create mode 100755 lib/docs/filters/fish/clean_html_sphinx.rb rename lib/docs/filters/fish/{entries.rb => entries_custom.rb} (91%) create mode 100755 lib/docs/filters/fish/entries_sphinx.rb create mode 100644 public/icons/docs/fish/SOURCE 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 - © 2005–2009 Axel Liljencrantz
+ © 2019 fish-shell developers
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 aea9980a83b8fefc4d89ffc85e117024c2a5f9ad..6baa7a833fd9a147e0f849992a31e0ac61bb454f 100644 GIT binary patch literal 6538 zcmeHLdpMNq`W}Rm94b=C7_6k`Jj2X1&f_pK2)iiNn!`5?bLyMHWT~W7A|(|jsp+u#$%Ax(uQ0ceVZ|&W6?fqX|GvZrPqbj?o$bY_wL6qK6MW;$1YzZm(;2^ zrm@ca`Da(k&7Okx?8*+#XjJy*DvI~uvo&I9rE>echOw|ieX}fX^u%dzJ##4TP34}E zoZrw}wagC9BuiUO_i33%{IXeVbLIV0*kjTDId9ubJ!ZArP1=SJmW@O{tik?EF3?<+6WoW^#x zZzOv^4(rSSo@i%QbYx~fQ`%WsC>gB{39ao}b-vHcbKY*>RIB6Lcd7o=9lrR9?uhco zQ-`*?&8RF>&f*?N%B(EF7+}v)*L1aa_m>yyG@kFDQY5+m`k+=d zK9V3MG=?2{(e76>U*Uumbjy?4z#;){UYH{-Wxl z`A#N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