Add Bootstrap version 5.0

pull/1453/head
MasterEnoc 4 years ago
parent e832d3b801
commit 564b02fee4

@ -4,7 +4,10 @@ module Docs
def call def call
@doc = at_css('.bd-content') @doc = at_css('.bd-content')
at_css('h1').content = 'Bootstrap 4' if root_page? # 'View on Github' button
css('.btn').remove
at_css('h1').content = 'Bootstrap' if root_page?
css('hr', '.bd-clipboard', '.modal', '.bd-example .bd-example').remove css('hr', '.bd-clipboard', '.modal', '.bd-example .bd-example').remove
@ -21,15 +24,6 @@ module Docs
if node.previous_element['class'].try(:include?, 'bd-example') if node.previous_element['class'].try(:include?, 'bd-example')
node.remove 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 || prev['id']
anchor = prev ? %(##{prev['id']}) : ''
node.inner_html = %(<a href="#{current_url}#{anchor}">Open example on getbootstrap.com</a>)
end end
end end

@ -0,0 +1,32 @@
module Docs
class Bootstrap
class CleanHtmlV5Filter < Filter
def call
@doc = at_css('main')
# Toc
css('.bd-toc').remove
# 'View on Github' button
css('.btn').remove
at_css('h1').content = 'Bootstrap' if root_page?
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-example').each do |node|
node.remove
end
doc
end
end
end
end

@ -0,0 +1,62 @@
module Docs
class Bootstrap
class EntriesV5Filter < Docs::EntriesFilter
def get_name
at_css('.bd-title').content.strip
end
def get_type
type = subpath.match(/\A.*?\//).to_s[0..-2]
type.gsub!('-', ' ')
type.capitalize!
type << ": #{name}" if type == 'Components'
type
end
def additional_entries
return [] if root_page? || subpath.start_with?('getting-started')
entries = []
# titles
css('h2', 'h3').each do |node|
entries << [ name + ': ' + node.content, node['id']]
end
# methods and events
# traverse through all '.tables' and search for a 'Method' or 'Event type' in the first <th>
css('.table').each do |node|
firstTh = node.at_css('th').content
if firstTh == 'Method'
# traverse all <tr> and search only the first <code> of each tr
node.css('tr').each do |subnode|
if subnode
method = subnode.at_css('code')
if method
method['id'] = method.content
entries << [method.content + ' (Method)', method['id']]
end
end
end
end
if firstTh == 'Event type'
node.css('tr').each do |subnode|
event = subnode.at_css('code')
if event
event['id'] = event.content
entries << [event.content + ' (Event)', event['id']]
end
end
end
end
entries
end
end
end
end

@ -16,14 +16,36 @@ module Docs
Documentation licensed under the Creative Commons Attribution License v3.0. Documentation licensed under the Creative Commons Attribution License v3.0.
HTML HTML
version '5' do
self.release = '5.0'
self.base_url = "https://getbootstrap.com/docs/#{self.release}/"
self.root_path = 'getting-started/introduction/'
html_filters.push 'bootstrap/entries_v5', 'bootstrap/clean_html_v5'
options[:only_patterns] = [
/\Agetting-started\//, /\Alayout\//, /\Acontent\//,
/\Acomponents\//, /\Autilities\/.+/, /\Ahelpers\//
]
options[:replace_paths] = {
'components/breadcrumb//' => '/components/breadcrumb/'
}
end
version '4' do version '4' do
self.release = '4.5' self.release = '4.5'
self.base_url = 'https://getbootstrap.com/docs/4.5/' self.base_url = "https://getbootstrap.com/docs/#{self.release}/"
self.root_path = 'getting-started/introduction/' self.root_path = 'getting-started/introduction/'
html_filters.push 'bootstrap/entries_v4', 'bootstrap/clean_html_v4' html_filters.push 'bootstrap/entries_v4', 'bootstrap/clean_html_v4'
options[:only_patterns] = [/\Agetting-started\//, /\Alayout\//, /\Acontent\//, /\Acomponents\//, /\Autilities\/.+/, /\Amigration\//] options[:only_patterns] = [
/\Agetting-started\//, /\Alayout\//, /\Acontent\//,
/\Acomponents\//, /\Autilities\/.+/, /\Amigration\//
]
end end
version '3' do version '3' do
@ -40,5 +62,6 @@ module Docs
doc = fetch_doc('https://getbootstrap.com/docs/versions/', opts) doc = fetch_doc('https://getbootstrap.com/docs/versions/', opts)
doc.at_css('span:contains("Latest")').parent.content.split(' ').first doc.at_css('span:contains("Latest")').parent.content.split(' ').first
end end
end end
end end

Loading…
Cancel
Save