Skip to content

Commit 3325c5d

Browse files
authored
Merge pull request #2608 from freeCodeCamp/bun
Add Bun documentation (1.3.0)
2 parents cd48972 + d795fce commit 3325c5d

File tree

8 files changed

+109
-1
lines changed

8 files changed

+109
-1
lines changed

assets/javascripts/news.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
[
33
"2025-10-19",
4-
"New documentations: <a href=\"/lit/\">Lit</a>, <a href=\"/graphviz/\">Graphviz</a>"
4+
"New documentations: <a href=\"/lit/\">Lit</a>, <a href=\"/graphviz/\">Graphviz</a>, <a href=\"/bun/\">Bun</a>"
55
],
66
[
77
"2025-07-14",

lib/docs/filters/bun/clean_html.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module Docs
2+
class Bun
3+
class CleanHtmlFilter < Filter
4+
def call
5+
@doc = at_css('section > .w-full')
6+
7+
header = at_css('header:has(h1)')
8+
if header
9+
header.content = header.at_css('h1').content
10+
header.name = 'h1'
11+
end
12+
13+
css('.CodeBlockTab').remove
14+
css('.CopyIcon').remove
15+
css('svg').remove
16+
css('a:contains("Edit on GitHub")').remove
17+
css('a:contains("Previous")').remove
18+
css('a:contains("Next")').remove
19+
20+
css('pre').each do |node|
21+
node.content = node.content
22+
node['data-language'] = 'typescript'
23+
node.remove_attribute('style')
24+
end
25+
26+
css('.font-mono').each do |node|
27+
node.name = 'code'
28+
end
29+
30+
css('.font-mono.text-blue-600').each do |node|
31+
node[:class] = 'token keyword'
32+
end
33+
34+
css('*[class]').each do |node|
35+
next if node.name == 'code'
36+
node.remove_attribute('class')
37+
end
38+
39+
doc
40+
end
41+
end
42+
end
43+
end

lib/docs/filters/bun/entries.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module Docs
2+
class Bun
3+
class EntriesFilter < Docs::EntriesFilter
4+
def get_name
5+
name = at_css('h1') ? at_css('h1').content : at_css('h2').content
6+
name
7+
end
8+
9+
def get_type
10+
slug.split('/').first
11+
end
12+
13+
def additional_entries
14+
if slug.start_with?('cli')
15+
css('h2[id]').each_with_object [] do |node, entries|
16+
name = get_name + " " + node.content.strip
17+
entries << [name, node['id']]
18+
end
19+
elsif slug.start_with?('api')
20+
css('h2[id]').each_with_object [] do |node, entries|
21+
name = get_name + ": " + node.content.strip
22+
entries << [name, node['id']]
23+
end
24+
else
25+
[]
26+
end
27+
end
28+
end
29+
end
30+
end

lib/docs/filters/core/images.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def call
3131

3232
self.class.cache[src] = false
3333

34+
next if src.start_with? 'data:image/'
3435
url = Docs::URL.parse(src)
3536
url.scheme = 'https' if url.scheme.nil?
3637
next unless url.scheme == 'http' || url.scheme == 'https'

lib/docs/scrapers/bun.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module Docs
2+
class Bun < UrlScraper
3+
self.name = 'Bun'
4+
self.type = 'simple'
5+
self.slug = 'bun'
6+
self.links = {
7+
home: 'https://leafletjs.com/',
8+
code: 'https://github.com/oven-sh/bun'
9+
}
10+
self.release = '1.3.0'
11+
self.base_url = "https://bun.com/docs/"
12+
self.root_path = 'installation'
13+
14+
html_filters.push 'bun/clean_html', 'bun/entries'
15+
16+
# https://bun.com/docs/project/licensing
17+
options[:attribution] = <<-HTML
18+
&copy; bun.com, oven-sh, Jarred Sumner<br>
19+
Licensed under the MIT License.
20+
HTML
21+
22+
options[:skip_patterns] = [/^project/]
23+
options[:fix_urls] = ->(url) do
24+
url.sub! %r{.md$}, ''
25+
url
26+
end
27+
28+
def get_latest_version(opts)
29+
tags = get_github_tags('oven-sh', 'bun', opts)
30+
end
31+
end
32+
end

public/icons/docs/bun/16.png

662 Bytes
Loading
1.49 KB
Loading

public/icons/docs/bun/SOURCE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
https://bun.com/icons/favicon-16x16.png
2+
https://bun.com/icons/favicon-32x32.png

0 commit comments

Comments
 (0)