History

Update Bootstrap documentation (4.0.0-beta)

Thibaut Courouble committed 9 years ago

Commit e22cbb41 parent f5194d33 files · +27 −24Browse files

Unified · Split

3 files
  1. lib/docs/filters/bootstrap/clean_html_v4.rb +4 −0
  2. lib/docs/filters/bootstrap/entries_v4.rb +15 −8
  3. lib/docs/scrapers/bootstrap.rb +8 −16
lib/docs/filters/bootstrap/clean_html_v4.rb+4−0
@@ -53,6 +53,10 @@ module Docs · 52 unmodified lines
53 node.name = 'h4'53 node.name = 'h4'
54 end54 end
55 55
56 css('thead td').each do |node|
57 node.name = 'th'
58 end
59
56 css('table, tr, td, th, pre, code').each do |node|60 css('table, tr, td, th, pre, code').each do |node|
57 node.remove_attribute('class')61 node.remove_attribute('class')
58 node.remove_attribute('style')62 node.remove_attribute('style')
lib/docs/filters/bootstrap/entries_v4.rb+15−8
@@ -4,24 +4,22 @@ module Docs · 3 unmodified lines
4 def get_name4 def get_name
5 name = at_css('.bd-content h1').content.strip5 name = at_css('.bd-content h1').content.strip
6 name.remove! ' system'6 name.remove! ' system'
7 return type if name == 'Overview'7 name == 'Overview' ? type : name
8 name.prepend 'Utilities: ' if subpath.start_with?('utilities')
9 name
10 end8 end
11 9
12 def get_type10 def get_type
13 if subpath.start_with?('components')11 if subpath.start_with?('components')
14 at_css('.bd-content h1').content.strip.prepend 'Components: '12 at_css('.bd-content h1').content.strip.prepend 'Components: '
15 else13 else
16 at_css('.bd-pageheader h1').content14 at_css('.bd-toc-item.active > .bd-toc-link').content
17 end15 end
18 end16 end
19 17
20 def additional_entries18 def additional_entries
21 return [] if root_page? || subpath.start_with?('getting-started')19 return [] if root_page? || subpath.start_with?('getting-started') || subpath.start_with?('migration')
22 entries = []20 entries = []
23 21
24 css('#markdown-toc > li > a', '#markdown-toc > li li #markdown-toc-events').each do |node|22 css('.bd-toc > ul > li > a', '.bd-toc a[href="#events"]', '.bd-toc a[href="#methods"]', '.bd-toc a[href="#triggers"]').each do |node|
25 name = node.content23 name = node.content
26 next if name =~ /example/i || IGNORE_ENTRIES.include?(name)24 next if name =~ /example/i || IGNORE_ENTRIES.include?(name)
27 name.downcase!25 name.downcase!
@@ -48,17 +46,26 @@ module Docs · 20 unmodified lines
48 entries << [name, id]46 entries << [name, id]
49 end47 end
50 48
49 css("#events ~ table tbody td:first-child").each do |node|
50 name = node.content.strip
51 unless id = node.parent['id']
52 id = node.parent['id'] = "#{name.parameterize}-event"
53 end
54 name.prepend "#{self.name}: "
55 name << ' (event)'
56 entries << [name, id]
57 end
58
51 entries59 entries
52 end60 end
53 61
54 IGNORE_ENTRIES = %w(62 IGNORE_ENTRIES = %w(
55 Contents
56 How\ it\ works63 How\ it\ works
57 Approach64 Approach
58 JavaScript\ behavior65 JavaScript\ behavior
59 Usage66 Usage
60 Basics
61 Overview67 Overview
68 About
62 )69 )
63 end70 end
64 end71 end
lib/docs/scrapers/bootstrap.rb+8−16
@@ -6,7 +6,7 @@ module Docs · 5 unmodified lines
6 code: 'https://github.com/twbs/bootstrap'6 code: 'https://github.com/twbs/bootstrap'
7 }7 }
8 8
9 options[:trailing_slash] = false9 options[:trailing_slash] = true
10 10
11 options[:attribution] = <<-HTML11 options[:attribution] = <<-HTML
12 &copy; 2011&ndash;2017 Twitter, Inc.<br>12 &copy; 2011&ndash;2017 Twitter, Inc.<br>
@@ -16,31 +16,23 @@ module Docs · 3 unmodified lines
16 HTML16 HTML
17 17
18 version '4' do18 version '4' do
19 self.release = 'alpha.6'19 self.release = '4.0.0-beta'
20 self.base_url = 'https://v4-alpha.getbootstrap.com/'20 self.base_url = 'https://getbootstrap.com/docs/4.0/'
21 self.root_path = 'getting-started/introduction'21 self.root_path = 'getting-started/introduction/'
22 22
23 html_filters.push 'bootstrap/entries_v4', 'bootstrap/clean_html_v4'23 html_filters.push 'bootstrap/entries_v4', 'bootstrap/clean_html_v4'
24 24
25 options[:only_patterns] = [/\Agetting-started\//, /\Alayout\//, /\Acontent\//, /\Acomponents\//, /\Autilities\//]25 options[:only_patterns] = [/\Agetting-started\//, /\Alayout\//, /\Acontent\//, /\Acomponents\//, /\Autilities\//, /\Amigration\//]
26 end26 end
27 27
28 version '3' do28 version '3' do
29 self.release = '3.3.7'29 self.release = '3.3.7'
30 self.base_url = 'https://getbootstrap.com/'30 self.base_url = 'https://getbootstrap.com/docs/3.3/'
31 self.root_path = 'getting-started'31 self.root_path = 'getting-started/'
32 32
33 html_filters.push 'bootstrap/entries_v3', 'bootstrap/clean_html_v3'33 html_filters.push 'bootstrap/entries_v3', 'bootstrap/clean_html_v3'
34 34
35 options[:only] = %w(getting-started css components javascript)35 options[:only] = %w(getting-started/ css/ components/ javascript/)
36 end
37
38 private
39
40 def handle_response(response)
41 response.effective_url.scheme = 'https'
42 response.effective_url.path = response.effective_url.path.remove(/\/\z/)
43 super
44 end36 end
45 end37 end
46end38end