diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index 89c7490a0d..1f821abae4 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,7 +1,7 @@ [ [ "2025-10-19", - "New documentations: Lit, Graphviz" + "New documentations: Lit, Graphviz, Bun" ], [ "2025-07-14", diff --git a/lib/docs/filters/bun/clean_html.rb b/lib/docs/filters/bun/clean_html.rb new file mode 100644 index 0000000000..90dca441d8 --- /dev/null +++ b/lib/docs/filters/bun/clean_html.rb @@ -0,0 +1,43 @@ +module Docs + class Bun + class CleanHtmlFilter < Filter + def call + @doc = at_css('section > .w-full') + + header = at_css('header:has(h1)') + if header + header.content = header.at_css('h1').content + header.name = 'h1' + end + + css('.CodeBlockTab').remove + css('.CopyIcon').remove + css('svg').remove + css('a:contains("Edit on GitHub")').remove + css('a:contains("Previous")').remove + css('a:contains("Next")').remove + + css('pre').each do |node| + node.content = node.content + node['data-language'] = 'typescript' + node.remove_attribute('style') + end + + css('.font-mono').each do |node| + node.name = 'code' + end + + css('.font-mono.text-blue-600').each do |node| + node[:class] = 'token keyword' + end + + css('*[class]').each do |node| + next if node.name == 'code' + node.remove_attribute('class') + end + + doc + end + end + end +end diff --git a/lib/docs/filters/bun/entries.rb b/lib/docs/filters/bun/entries.rb new file mode 100644 index 0000000000..7ae0e1b4ae --- /dev/null +++ b/lib/docs/filters/bun/entries.rb @@ -0,0 +1,30 @@ +module Docs + class Bun + class EntriesFilter < Docs::EntriesFilter + def get_name + name = at_css('h1') ? at_css('h1').content : at_css('h2').content + name + end + + def get_type + slug.split('/').first + end + + def additional_entries + if slug.start_with?('cli') + css('h2[id]').each_with_object [] do |node, entries| + name = get_name + " " + node.content.strip + entries << [name, node['id']] + end + elsif slug.start_with?('api') + css('h2[id]').each_with_object [] do |node, entries| + name = get_name + ": " + node.content.strip + entries << [name, node['id']] + end + else + [] + end + end + end + end +end diff --git a/lib/docs/filters/core/images.rb b/lib/docs/filters/core/images.rb index f63016e332..5d945522b9 100644 --- a/lib/docs/filters/core/images.rb +++ b/lib/docs/filters/core/images.rb @@ -31,6 +31,7 @@ def call self.class.cache[src] = false + next if src.start_with? 'data:image/' url = Docs::URL.parse(src) url.scheme = 'https' if url.scheme.nil? next unless url.scheme == 'http' || url.scheme == 'https' diff --git a/lib/docs/scrapers/bun.rb b/lib/docs/scrapers/bun.rb new file mode 100644 index 0000000000..e161cf3d4f --- /dev/null +++ b/lib/docs/scrapers/bun.rb @@ -0,0 +1,32 @@ +module Docs + class Bun < UrlScraper + self.name = 'Bun' + self.type = 'simple' + self.slug = 'bun' + self.links = { + home: 'https://leafletjs.com/', + code: 'https://github.com/oven-sh/bun' + } + self.release = '1.3.0' + self.base_url = "https://bun.com/docs/" + self.root_path = 'installation' + + html_filters.push 'bun/clean_html', 'bun/entries' + + # https://bun.com/docs/project/licensing + options[:attribution] = <<-HTML + © bun.com, oven-sh, Jarred Sumner
+ Licensed under the MIT License. + HTML + + options[:skip_patterns] = [/^project/] + options[:fix_urls] = ->(url) do + url.sub! %r{.md$}, '' + url + end + + def get_latest_version(opts) + tags = get_github_tags('oven-sh', 'bun', opts) + end + end +end diff --git a/public/icons/docs/bun/16.png b/public/icons/docs/bun/16.png new file mode 100644 index 0000000000..7d6d524b12 Binary files /dev/null and b/public/icons/docs/bun/16.png differ diff --git a/public/icons/docs/bun/16@2x.png b/public/icons/docs/bun/16@2x.png new file mode 100644 index 0000000000..83db03e3c5 Binary files /dev/null and b/public/icons/docs/bun/16@2x.png differ diff --git a/public/icons/docs/bun/SOURCE b/public/icons/docs/bun/SOURCE new file mode 100644 index 0000000000..afc7429638 --- /dev/null +++ b/public/icons/docs/bun/SOURCE @@ -0,0 +1,2 @@ +https://bun.com/icons/favicon-16x16.png +https://bun.com/icons/favicon-32x32.png