Skip to content

Commit 4c9c4d8

Browse files
committed
Update Bootstrap documentation (6.0.0-alpha.1)
1 parent 5af15e1 commit 4c9c4d8

4 files changed

Lines changed: 133 additions & 1 deletion

File tree

‎assets/stylesheets/pages/_bootstrap.scss‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
.bs-callout-danger { @extend %note-red; }
1818
.bs-callout > h4, .bs-callout > h5 { margin-top: .25rem; }
1919

20+
.bd-callout { @extend %note; }
21+
.bd-callout-info { @extend %note-blue; }
22+
.bd-callout-warning { @extend %note-orange; }
23+
.bd-callout-danger { @extend %note-red; }
24+
2025
.text-danger { @extend %label, %label-red; }
2126

2227
p.bs-example {
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
module Docs
2+
class Bootstrap
3+
class CleanHtmlV6Filter < Filter
4+
def call
5+
6+
@doc = at_css('main')
7+
at_css('.bd-content').prepend_child(at_css('h1').remove)
8+
@doc = at_css('.bd-content')
9+
10+
at_css('h1').content = 'Bootstrap' if root_page?
11+
12+
# Live examples and demo dialogs
13+
css('.bd-example', 'dialog', 'script', 'button[data-bs-toggle]').remove
14+
15+
# Interactive playgrounds, swatches and prev/next navigation
16+
css('.bd-links-nav', '.bd-colors-grid', '.bd-playground', '.bd-scrollspy-debug', 'svg:has(symbol)').remove
17+
18+
css('.anchor-link', '.bd-details-icon').remove
19+
20+
css('.bd-code-snippet').each do |node|
21+
label = node.at_css('.highlight-toolbar .font-monospace')&.content&.strip&.downcase
22+
tabs = node.css('.code-tab-btn').map { |btn| btn.content.strip }
23+
24+
html = node.css('pre').each_with_index.map do |pre, i|
25+
out = Nokogiri::XML::Node.new('pre', doc)
26+
lang = tabs.empty? ? language(label) : 'shell'
27+
out['data-language'] = lang if lang
28+
out.content = pre.content
29+
tabs[i] ? "<p><strong>#{tabs[i]}</strong></p>#{out.to_html}" : out.to_html
30+
end.join
31+
32+
node.replace(html)
33+
end
34+
35+
# Remaining live demos (option pickers etc.)
36+
doc.element_children.each do |node|
37+
node.remove if node.name == 'div' && node.at_css('button, input, select')
38+
end
39+
40+
css('.bd-callout').each do |node|
41+
node.name = 'blockquote'
42+
end
43+
44+
css('table').each do |node|
45+
node.remove_attribute('class')
46+
end
47+
48+
css('td[data-cell]').remove_attr('data-cell')
49+
50+
doc
51+
52+
end
53+
54+
def language(label)
55+
label = File.extname(label)[1..] if label.include?('.')
56+
case label
57+
when 'js', 'javascript' then 'javascript'
58+
when 'ts', 'typescript' then 'typescript'
59+
when 'sh', 'bash', 'shell', 'console' then 'shell'
60+
when 'text', 'plaintext' then nil
61+
else label
62+
end
63+
end
64+
end
65+
end
66+
end
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
module Docs
2+
class Bootstrap
3+
class EntriesV6Filter < Docs::EntriesFilter
4+
5+
def get_name
6+
at_css('.bd-title').content.strip
7+
end
8+
9+
def get_type
10+
type = subpath.match(/\A.*?\//).to_s[0..-2]
11+
type.gsub!('-', ' ')
12+
type.capitalize!
13+
type << ": #{name}" if type == 'Components'
14+
type
15+
end
16+
17+
def additional_entries
18+
return [] if root_page? || subpath.start_with?('getting-started', 'guides')
19+
20+
entries = []
21+
22+
css('h2', 'h3').each do |node|
23+
entries << [name + ': ' + node.content.strip, node['id']] if node['id']
24+
end
25+
26+
# methods and events
27+
css('table').each do |node|
28+
first_th = node.at_css('th')&.content
29+
kind = case first_th
30+
when 'Method' then 'Method'
31+
when 'Event', 'Event type' then 'Event'
32+
end
33+
next unless kind
34+
35+
node.css('tbody tr').each do |row|
36+
code = row.at_css('td code')
37+
next unless code
38+
code['id'] = code.content
39+
entries << ["#{name}: #{code.content} (#{kind})", code['id']]
40+
end
41+
end
42+
43+
entries
44+
end
45+
46+
end
47+
end
48+
end

‎lib/docs/scrapers/bootstrap.rb‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,24 @@ class Bootstrap < UrlScraper
1010

1111
# https://github.com/twbs/bootstrap/blob/master/LICENSE
1212
options[:attribution] = <<-HTML
13-
&copy; 2011&ndash;2023 The Bootstrap Authors<br>
13+
&copy; 2011&ndash;2026 The Bootstrap Authors<br>
1414
Code licensed under the MIT License.<br>
1515
Documentation licensed under the Creative Commons Attribution License v3.0.
1616
HTML
1717

18+
version '6' do
19+
self.release = '6.0.0-alpha.1'
20+
self.base_url = 'https://getbootstrap.com/docs/6.0/'
21+
self.root_path = 'getting-started/install/'
22+
23+
html_filters.push 'bootstrap/entries_v6', 'bootstrap/clean_html_v6'
24+
25+
options[:skip_patterns] = [
26+
/\Aabout\//, /\Aexamples\//
27+
]
28+
29+
end
30+
1831
version '5' do
1932
self.release = '5.3'
2033
self.base_url = "https://getbootstrap.com/docs/#{self.release}/"

0 commit comments

Comments
 (0)