History

Update Git documentation (2.9.0)

Fixes #422.

Thibaut Courouble committed 10 years ago

Commit 04786901 parent 203903f3 files · +25 −6Browse files

Unified · Split

3 files
  1. lib/docs/filters/git/clean_html.rb +5 −0
  2. lib/docs/filters/git/entries.rb +15 −1
  3. lib/docs/scrapers/git.rb +5 −5
lib/docs/filters/git/clean_html.rb+5−0
@@ -2,6 +2,7 @@ module Docs · 1 unmodified line
22 class Git
33 class CleanHtmlFilter < Filter
44 def call
5+ @doc = at_css('.man-page, #main')
56 root_page? ? root : other
67 doc
78 end
@@ -38,6 +39,10 @@ module Docs · 30 unmodified lines
3839 css('tt', 'p > em').each do |node|
3940 node.name = 'code'
4041 end
42+
43+ css('pre').each do |node|
44+ node.content = node.content.gsub("\t", ' ' * 8)
45+ end
4146 end
4247 end
4348 end
lib/docs/filters/git/entries.rb+15−1
@@ -2,7 +2,21 @@ module Docs · 1 unmodified line
22 class Git
33 class EntriesFilter < Docs::EntriesFilter
44 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
620 end
721 end
822 end
lib/docs/scrapers/git.rb+5−5
@@ -1,7 +1,7 @@
11 module Docs
22 class Git < UrlScraper
33 self.type = 'git'
4− self.release = '2.8.0'
4+ self.release = '2.9.0'
55 self.base_url = 'https://git-scm.com/docs'
66 self.initial_paths = %w(/git.html)
77 self.links = {
@@ -9,11 +9,11 @@ module Docs · 1 unmodified line
99 code: 'https://github.com/git/git'
1010 }
1111
12− html_filters.push 'git/clean_html', 'git/entries'
12+ html_filters.push 'git/entries', 'git/clean_html'
1313
14− options[:container] = ->(filter) { filter.root_page? ? '#main' : '.man-page, #main' }
15− options[:follow_links] = ->(filter) { filter.root_page? }
16− options[:only_patterns] = [/\A\/git\-/]
14+ options[:container] = '#content'
15+ options[:only_patterns] = [/\A\/[^\/]+\z/]
16+ options[:skip] = %w(/howto-index.html)
1717
1818 options[:attribution] = <<-HTML
1919 &copy; 2005&ndash;2016 Linus Torvalds and others<br>

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t