Add Boostrap 4 documentation

pull/447/merge
Thibaut Courouble 9 years ago
parent 175308b914
commit 58c57e02b6

@ -1,7 +1,7 @@
[
[
"2016-07-31",
"New documentation: <a href=\"/bootstrap/\">Bootstrap</a>"
"New documentations: <a href=\"/bootstrap~3/\">Bootstrap 3</a> and <a href=\"/bootstrap~4/\">Bootstrap 4</a>"
], [
"2016-07-24",
"New documentations: <a href=\"/julia/\">Julia</a>, <a href=\"/crystal/\">Crystal</a> and <a href=\"/redux/\">Redux</a>"

@ -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 =

@ -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;

@ -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|

@ -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 = %(<a href="#{current_url}/##{prev['id']}">Open example on getbootstrap.com</a>)
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

@ -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

@ -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
&copy; 2011&ndash;2016 Twitter, Inc.<br>
Code licensed under the MIT License.<br>
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

Loading…
Cancel
Save