diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json
index 4d5944c4..a541571c 100644
--- a/assets/javascripts/news.json
+++ b/assets/javascripts/news.json
@@ -1,7 +1,7 @@
[
[
"2016-07-31",
- "New documentation: Bootstrap"
+ "New documentations: Bootstrap 3 and Bootstrap 4"
], [
"2016-07-24",
"New documentations: Julia, Crystal and Redux"
diff --git a/assets/javascripts/views/pages/simple.coffee b/assets/javascripts/views/pages/simple.coffee
index 6675e9b1..c2f31bbf 100644
--- a/assets/javascripts/views/pages/simple.coffee
+++ b/assets/javascripts/views/pages/simple.coffee
@@ -8,7 +8,7 @@ class app.views.SimplePage extends app.views.BasePage
app.views.AngularPage =
app.views.AngularjsPage =
-app.views.Bsv3Page =
+app.views.BootstrapPage =
app.views.CakephpPage =
app.views.ChaiPage =
app.views.CrystalPage =
diff --git a/assets/stylesheets/pages/_bootstrap.scss b/assets/stylesheets/pages/_bootstrap.scss
index 8f89d167..06931ccf 100644
--- a/assets/stylesheets/pages/_bootstrap.scss
+++ b/assets/stylesheets/pages/_bootstrap.scss
@@ -1,7 +1,7 @@
-._bsv3 {
+._bootstrap {
@extend %simple;
- h4 > code, h5 > code { @extend %label; }
+ h4 > code, h5 > code, strong > code { @extend %label; }
h2 > small {
color: $textColorLight;
diff --git a/lib/docs/filters/bootstrap/clean_html_v3.rb b/lib/docs/filters/bootstrap/clean_html_v3.rb
index becd1e3d..a96102c9 100644
--- a/lib/docs/filters/bootstrap/clean_html_v3.rb
+++ b/lib/docs/filters/bootstrap/clean_html_v3.rb
@@ -9,6 +9,7 @@ module Docs
node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
end
at_css('h2').name = 'h1'
+ at_css('h1').content = 'Bootstrap 3' if root_page?
css('hr', '.zero-clipboard', '.modal', '.panel-group').remove
@@ -51,6 +52,7 @@ module Docs
css('table, tr, td, th, pre').each do |node|
node.remove_attribute('class')
+ node.remove_attribute('style')
end
css('thead td:empty').each do |node|
diff --git a/lib/docs/filters/bootstrap/clean_html_v4.rb b/lib/docs/filters/bootstrap/clean_html_v4.rb
new file mode 100644
index 00000000..7e1dc86f
--- /dev/null
+++ b/lib/docs/filters/bootstrap/clean_html_v4.rb
@@ -0,0 +1,69 @@
+module Docs
+ class Bootstrap
+ class CleanHtmlV4Filter < Filter
+ def call
+ @doc = at_css('.bd-content')
+
+ at_css('h1').content = 'Bootstrap 4' if root_page?
+
+ css('hr', '.bd-clipboard', '.modal', '.bd-example .bd-example').remove
+
+ css('#markdown-toc-contents').each do |node|
+ node.parent.remove
+ end
+
+ css('.bd-example-row', '.table-responsive').each do |node|
+ node.before(node.children).remove
+ end
+
+ css('.bd-example', '.responsive-utilities-test').each do |node|
+ if node.previous_element['class'].try(:include?, 'bd-example')
+ node.remove
+ else
+ node.content = ''
+ node.name = 'p'
+ node['class'] = 'bd-example'
+ node.remove_attribute('data-example-id')
+ prev = node.previous_element
+ prev = prev.previous_element until prev['id']
+ node.inner_html = %(Open example on getbootstrap.com)
+ end
+ end
+
+ css('.bd-example + .highlight').each do |node|
+ node.previous_element.name = 'div'
+ end
+
+ css('div[class*="col-"]').each do |node|
+ node['class'] = 'col'
+ end
+
+ css('.__cf_email__').each do |node|
+ node.replace(decode_cloudflare_email(node['data-cfemail']))
+ end
+
+ css('.highlight').each do |node|
+ code = node.at_css('code')
+ node['data-language'] = code['data-lang']
+ node.content = code.content
+ node.name = 'pre'
+ end
+
+ css('bd-callout h3').each do |node|
+ node.name = 'h4'
+ end
+
+ css('table, tr, td, th, pre, code').each do |node|
+ node.remove_attribute('class')
+ node.remove_attribute('style')
+ end
+
+ css('[class*="bd-"]').each do |node|
+ node['class'] = node['class'].gsub('bd-', 'bs-')
+ end
+
+ doc
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/bootstrap/entries_v4.rb b/lib/docs/filters/bootstrap/entries_v4.rb
new file mode 100644
index 00000000..e69ddbee
--- /dev/null
+++ b/lib/docs/filters/bootstrap/entries_v4.rb
@@ -0,0 +1,62 @@
+module Docs
+ class Bootstrap
+ class EntriesV4Filter < Docs::EntriesFilter
+ def get_name
+ name = at_css('.bd-content h1').content.strip
+ name.remove! ' system'
+ return type if name == 'Overview'
+ name
+ end
+
+ def get_type
+ if subpath.start_with?('components')
+ at_css('.bd-content h1').content.strip.prepend 'Components: '
+ else
+ at_css('.bd-pageheader h1').content
+ end
+ end
+
+ def additional_entries
+ return [] if root_page? || subpath.start_with?('getting-started')
+ entries = []
+
+ css('#markdown-toc > li > a', '#markdown-toc > li li #markdown-toc-events').each do |node|
+ name = node.content
+ next if name =~ /example/i || IGNORE_ENTRIES.include?(name)
+ name.downcase!
+ name.prepend "#{self.name}: "
+ id = node['href'].remove('#')
+ entries << [name, id]
+ end
+
+ css("#options + p + div tbody td:first-child").each do |node|
+ name = node.content.strip
+ id = node.parent['id'] = "#{name.parameterize}-option"
+ name.prepend "#{self.name}: "
+ name << ' (option)'
+ entries << [name, id]
+ end
+
+ css("#methods + table tbody td:first-child, #methods ~ h4 code").each do |node|
+ next unless name = node.content[/\('(\w+)'\)/, 1]
+ id = node.parent['id'] = "#{name.parameterize}-method"
+ name.prepend "#{self.name}: "
+ name << ' (method)'
+ entries << [name, id]
+ end
+
+ entries
+ end
+
+ IGNORE_ENTRIES = %w(
+ Contents
+ How\ it\ works
+ Approach
+ JavaScript\ behavior
+ Usage
+ Basics
+ Overview
+ )
+ end
+ end
+end
diff --git a/lib/docs/scrapers/bootstrap.rb b/lib/docs/scrapers/bootstrap.rb
index d0c10d66..cfac7fd3 100644
--- a/lib/docs/scrapers/bootstrap.rb
+++ b/lib/docs/scrapers/bootstrap.rb
@@ -1,24 +1,36 @@
module Docs
class Bootstrap < UrlScraper
+ self.type = 'bootstrap'
+ self.links = {
+ home: 'https://getbootstrap.com/',
+ code: 'https://github.com/twbs/bootstrap'
+ }
+
+ options[:trailing_slash] = false
+
options[:attribution] = <<-HTML
© 2011–2016 Twitter, Inc.
Code licensed under the MIT License.
Documentation licensed under the Creative Commons Attribution License v3.0.
HTML
+ version '4' do
+ self.release = 'alpha.3'
+ self.base_url = 'https://v4-alpha.getbootstrap.com/'
+ self.root_path = 'getting-started/introduction'
+
+ html_filters.push 'bootstrap/entries_v4', 'bootstrap/clean_html_v4'
+
+ options[:only_patterns] = [/\Agetting-started\//, /\Alayout\//, /\Acontent\//, /\Acomponents\//]
+ end
+
version '3' do
- self.type = 'bsv3'
self.release = '3.3.7'
self.base_url = 'https://getbootstrap.com/'
self.root_path = 'getting-started'
- self.links = {
- home: 'https://getbootstrap.com/',
- code: 'https://github.com/twbs/bootstrap'
- }
html_filters.push 'bootstrap/entries_v3', 'bootstrap/clean_html_v3'
- options[:trailing_slash] = false
options[:only] = %w(getting-started css components javascript)
end