Sfoglia il codice sorgente

Update Git documentation (2.9.0)

Fixes #422.
Thibaut Courouble 9 anni fa
parent
commit
0478690c19

+ 5 - 0
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

+ 15 - 1
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

+ 5 - 5
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
       &copy; 2005&ndash;2016 Linus Torvalds and others<br>