From 0478690c1959f288d8b23efe05e078a8f9065687 Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sun, 19 Jun 2016 10:29:44 -0400 Subject: [PATCH] Update Git documentation (2.9.0) Fixes #422. --- lib/docs/filters/git/clean_html.rb | 5 +++++ lib/docs/filters/git/entries.rb | 16 +++++++++++++++- lib/docs/scrapers/git.rb | 10 +++++----- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/lib/docs/filters/git/clean_html.rb b/lib/docs/filters/git/clean_html.rb index f3ce151a..6b76e1f0 100644 --- a/lib/docs/filters/git/clean_html.rb +++ b/lib/docs/filters/git/clean_html.rb @@ -2,6 +2,7 @@ module Docs class Git class CleanHtmlFilter < Filter def call + @doc = at_css('.man-page, #main') root_page? ? root : other doc end @@ -38,6 +39,10 @@ module Docs css('tt', 'p > em').each do |node| node.name = 'code' end + + css('pre').each do |node| + node.content = node.content.gsub("\t", ' ' * 8) + end end end end diff --git a/lib/docs/filters/git/entries.rb b/lib/docs/filters/git/entries.rb index afdca023..7ab8da79 100644 --- a/lib/docs/filters/git/entries.rb +++ b/lib/docs/filters/git/entries.rb @@ -2,7 +2,21 @@ module Docs class Git class EntriesFilter < Docs::EntriesFilter def get_name - slug.sub '-', ' ' + if slug == 'user-manual' + 'User Manual' + else + slug.sub '-', ' ' + end + end + + def get_type + if link = at_css("#topics-dropdown a[href='#{slug}']") + link.ancestors('ul').first.previous_element.content + elsif slug == 'git' || slug.start_with?('git-') + 'Git' + else + 'Miscellaenous' + end end end end diff --git a/lib/docs/scrapers/git.rb b/lib/docs/scrapers/git.rb index 31ff353f..80815361 100644 --- a/lib/docs/scrapers/git.rb +++ b/lib/docs/scrapers/git.rb @@ -1,7 +1,7 @@ module Docs class Git < UrlScraper self.type = 'git' - self.release = '2.8.0' + self.release = '2.9.0' self.base_url = 'https://git-scm.com/docs' self.initial_paths = %w(/git.html) self.links = { @@ -9,11 +9,11 @@ module Docs code: 'https://github.com/git/git' } - html_filters.push 'git/clean_html', 'git/entries' + html_filters.push 'git/entries', 'git/clean_html' - options[:container] = ->(filter) { filter.root_page? ? '#main' : '.man-page, #main' } - options[:follow_links] = ->(filter) { filter.root_page? } - options[:only_patterns] = [/\A\/git\-/] + options[:container] = '#content' + options[:only_patterns] = [/\A\/[^\/]+\z/] + options[:skip] = %w(/howto-index.html) options[:attribution] = <<-HTML © 2005–2016 Linus Torvalds and others