Fixes #422.
Unified · Split
| @@ -2,6 +2,7 @@ module Docs · 1 unmodified line | |||
| 2 | class Git | 2 | class Git |
| 3 | class CleanHtmlFilter < Filter | 3 | class CleanHtmlFilter < Filter |
| 4 | def call | 4 | def call |
| 5 | @doc = at_css('.man-page, #main') | ||
| 5 | root_page? ? root : other | 6 | root_page? ? root : other |
| 6 | doc | 7 | doc |
| 7 | end | 8 | end |
| @@ -38,6 +39,10 @@ module Docs · 30 unmodified lines | |||
| 38 | css('tt', 'p > em').each do |node| | 39 | css('tt', 'p > em').each do |node| |
| 39 | node.name = 'code' | 40 | node.name = 'code' |
| 40 | end | 41 | end |
| 42 | |||
| 43 | css('pre').each do |node| | ||
| 44 | node.content = node.content.gsub("\t", ' ' * 8) | ||
| 45 | end | ||
| 41 | end | 46 | end |
| 42 | end | 47 | end |
| 43 | end | 48 | end |
| @@ -2,7 +2,21 @@ module Docs · 1 unmodified line | |||
| 2 | class Git | 2 | class Git |
| 3 | class EntriesFilter < Docs::EntriesFilter | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | def get_name | 4 | def get_name |
| 5 | slug.sub '-', ' ' | 5 | if slug == 'user-manual' |
| 6 | 'User Manual' | ||
| 7 | else | ||
| 8 | slug.sub '-', ' ' | ||
| 9 | end | ||
| 10 | end | ||
| 11 | |||
| 12 | def get_type | ||
| 13 | if link = at_css("#topics-dropdown a[href='#{slug}']") | ||
| 14 | link.ancestors('ul').first.previous_element.content | ||
| 15 | elsif slug == 'git' || slug.start_with?('git-') | ||
| 16 | 'Git' | ||
| 17 | else | ||
| 18 | 'Miscellaenous' | ||
| 19 | end | ||
| 6 | end | 20 | end |
| 7 | end | 21 | end |
| 8 | end | 22 | end |
| @@ -1,7 +1,7 @@ | |||
| 1 | module Docs | 1 | module Docs |
| 2 | class Git < UrlScraper | 2 | class Git < UrlScraper |
| 3 | self.type = 'git' | 3 | self.type = 'git' |
| 4 | self.release = '2.8.0' | 4 | self.release = '2.9.0' |
| 5 | self.base_url = 'https://git-scm.com/docs' | 5 | self.base_url = 'https://git-scm.com/docs' |
| 6 | self.initial_paths = %w(/git.html) | 6 | self.initial_paths = %w(/git.html) |
| 7 | self.links = { | 7 | self.links = { |
| @@ -9,11 +9,11 @@ module Docs · 1 unmodified line | |||
| 9 | code: 'https://github.com/git/git' | 9 | code: 'https://github.com/git/git' |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | html_filters.push 'git/clean_html', 'git/entries' | 12 | html_filters.push 'git/entries', 'git/clean_html' |
| 13 | 13 | ||
| 14 | options[:container] = ->(filter) { filter.root_page? ? '#main' : '.man-page, #main' } | 14 | options[:container] = '#content' |
| 15 | options[:follow_links] = ->(filter) { filter.root_page? } | 15 | options[:only_patterns] = [/\A\/[^\/]+\z/] |
| 16 | options[:only_patterns] = [/\A\/git\-/] | 16 | options[:skip] = %w(/howto-index.html) |
| 17 | 17 | ||
| 18 | options[:attribution] = <<-HTML | 18 | options[:attribution] = <<-HTML |
| 19 | © 2005–2016 Linus Torvalds and others<br> | 19 | © 2005–2016 Linus Torvalds and others<br> |