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
5353 node.name = 'h4'
5454 end
5555
56+ css('thead td').each do |node|
57+ node.name = 'th'
58+ end
59+
5660 css('table, tr, td, th, pre, code').each do |node|
5761 node.remove_attribute('class')
5862 node.remove_attribute('style')
lib/docs/filters/bootstrap/entries_v4.rb+15−8
@@ -4,24 +4,22 @@ module Docs · 3 unmodified lines
44 def get_name
55 name = at_css('.bd-content h1').content.strip
66 name.remove! ' system'
7− return type if name == 'Overview'
8− name.prepend 'Utilities: ' if subpath.start_with?('utilities')
9− name
7+ name == 'Overview' ? type : name
108 end
119
1210 def get_type
1311 if subpath.start_with?('components')
1412 at_css('.bd-content h1').content.strip.prepend 'Components: '
1513 else
16− at_css('.bd-pageheader h1').content
14+ at_css('.bd-toc-item.active > .bd-toc-link').content
1715 end
1816 end
1917
2018 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')
2220 entries = []
2321
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|
2523 name = node.content
2624 next if name =~ /example/i || IGNORE_ENTRIES.include?(name)
2725 name.downcase!
@@ -48,17 +46,26 @@ module Docs · 20 unmodified lines
4846 entries << [name, id]
4947 end
5048
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+
5159 entries
5260 end
5361
5462 IGNORE_ENTRIES = %w(
55− Contents
5663 How\ it\ works
5764 Approach
5865 JavaScript\ behavior
5966 Usage
60− Basics
6167 Overview
68+ About
6269 )
6370 end
6471 end
lib/docs/scrapers/bootstrap.rb+8−16
@@ -6,7 +6,7 @@ module Docs · 5 unmodified lines
66 code: 'https://github.com/twbs/bootstrap'
77 }
88
9− options[:trailing_slash] = false
9+ options[:trailing_slash] = true
1010
1111 options[:attribution] = <<-HTML
1212 &copy; 2011&ndash;2017 Twitter, Inc.<br>
@@ -16,31 +16,23 @@ module Docs · 3 unmodified lines
1616 HTML
1717
1818 version '4' do
19− self.release = 'alpha.6'
20− self.base_url = 'https://v4-alpha.getbootstrap.com/'
21− self.root_path = 'getting-started/introduction'
19+ self.release = '4.0.0-beta'
20+ self.base_url = 'https://getbootstrap.com/docs/4.0/'
21+ self.root_path = 'getting-started/introduction/'
2222
2323 html_filters.push 'bootstrap/entries_v4', 'bootstrap/clean_html_v4'
2424
25− options[:only_patterns] = [/\Agetting-started\//, /\Alayout\//, /\Acontent\//, /\Acomponents\//, /\Autilities\//]
25+ options[:only_patterns] = [/\Agetting-started\//, /\Alayout\//, /\Acontent\//, /\Acomponents\//, /\Autilities\//, /\Amigration\//]
2626 end
2727
2828 version '3' do
2929 self.release = '3.3.7'
30− self.base_url = 'https://getbootstrap.com/'
31− self.root_path = 'getting-started'
30+ self.base_url = 'https://getbootstrap.com/docs/3.3/'
31+ self.root_path = 'getting-started/'
3232
3333 html_filters.push 'bootstrap/entries_v3', 'bootstrap/clean_html_v3'
3434
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
35+ options[:only] = %w(getting-started/ css/ components/ javascript/)
4436 end
4537 end
4638 end