diff --git a/lib/docs/filters/bazel/clean_html.rb b/lib/docs/filters/bazel/clean_html.rb new file mode 100644 index 00000000..d772908e --- /dev/null +++ b/lib/docs/filters/bazel/clean_html.rb @@ -0,0 +1,17 @@ +module Docs + class Bazel + class CleanHtmlFilter < Filter + + def call + css('.devsite-article-meta').remove + css('devsite-feature-tooltip').remove + css('devsite-thumb-rating').remove + css('devsite-toc').remove + css('a.button-with-icon').remove + css('button.devsite-heading-link').remove + doc + end + + end + end +end diff --git a/lib/docs/filters/bazel/entries.rb b/lib/docs/filters/bazel/entries.rb new file mode 100644 index 00000000..3c1ad9cd --- /dev/null +++ b/lib/docs/filters/bazel/entries.rb @@ -0,0 +1,37 @@ +module Docs + class Bazel + class EntriesFilter < Docs::EntriesFilter + + def get_name + at_css('h1').content.strip + end + + def get_type + "Build encyclopedia" + end + + def additional_entries + entries = [] + + special_page_types = { + 'functions' => 'Function', + 'make-variables' => 'Make Variable', + 'common-definitions' => 'Common Definition', + } + page_type = special_page_types[subpath] + unless page_type.nil? + # only first ul + at_css('.devsite-article-body > ul').css('li > a').each do |node| + entries << [node.content.strip, node['href'].sub('#', ''), page_type] + end + end + css('h2#rules + ul > li > a').each do |node| + entries << [node.content.strip, node['href'].sub('#', ''), "Rule"] + end + + entries + end + + end + end +end diff --git a/lib/docs/scrapers/bazel.rb b/lib/docs/scrapers/bazel.rb new file mode 100644 index 00000000..3f2f9447 --- /dev/null +++ b/lib/docs/scrapers/bazel.rb @@ -0,0 +1,50 @@ +module Docs + class Bazel < UrlScraper + self.name = 'Bazel' + self.type = 'bazel' + + html_filters.push 'bazel/entries', 'bazel/clean_html' + + options[:skip] = %w(platform) + + options[:container] = "devsite-content" + options[:attribution] = <<-HTML + Licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. + HTML + + version '7.0' do + self.release = '7.0.0' + self.base_url = 'https://bazel.build/versions/7.0.0/reference/be/' + end + + version '6.4' do + self.release = '6.4.0' + self.base_url = 'https://bazel.build/versions/6.4.0/reference/be/' + end + + version '6.3' do + self.release = '6.3.0' + self.base_url = 'https://bazel.build/versions/6.3.0/reference/be/' + end + + version '6.2' do + self.release = '6.2.0' + self.base_url = 'https://bazel.build/versions/6.2.0/reference/be/' + end + + version '6.1' do + self.release = '6.1.0' + self.base_url = 'https://bazel.build/versions/6.1.0/reference/be/' + end + + version '6.0' do + self.release = '6.0.0' + self.base_url = 'https://bazel.build/versions/6.0.0/reference/be/' + end + + def get_latest_version(opts) + get_latest_github_release('bazelbuild', 'bazel', opts) + end + + end +end diff --git a/public/icons/docs/bazel/16.png b/public/icons/docs/bazel/16.png new file mode 100644 index 00000000..6bc04077 Binary files /dev/null and b/public/icons/docs/bazel/16.png differ diff --git a/public/icons/docs/bazel/16@2x.png b/public/icons/docs/bazel/16@2x.png new file mode 100644 index 00000000..a8e26f2f Binary files /dev/null and b/public/icons/docs/bazel/16@2x.png differ diff --git a/public/icons/docs/bazel/SOURCE b/public/icons/docs/bazel/SOURCE new file mode 100644 index 00000000..3bf431c4 --- /dev/null +++ b/public/icons/docs/bazel/SOURCE @@ -0,0 +1 @@ +https://upload.wikimedia.org/wikipedia/en/7/7d/Bazel_logo.svg