From 169651c1b75018a872051103c01253adc0a5ae51 Mon Sep 17 00:00:00 2001 From: Yikai Zhao Date: Tue, 19 Dec 2023 00:51:43 +0800 Subject: [PATCH] Add bazel doc --- lib/docs/filters/bazel/clean_html.rb | 17 +++++++++ lib/docs/filters/bazel/entries.rb | 37 ++++++++++++++++++++ lib/docs/scrapers/bazel.rb | 50 +++++++++++++++++++++++++++ public/icons/docs/bazel/16.png | Bin 0 -> 1328 bytes public/icons/docs/bazel/16@2x.png | Bin 0 -> 2418 bytes public/icons/docs/bazel/SOURCE | 1 + 6 files changed, 105 insertions(+) create mode 100644 lib/docs/filters/bazel/clean_html.rb create mode 100644 lib/docs/filters/bazel/entries.rb create mode 100644 lib/docs/scrapers/bazel.rb create mode 100644 public/icons/docs/bazel/16.png create mode 100644 public/icons/docs/bazel/16@2x.png create mode 100644 public/icons/docs/bazel/SOURCE 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 0000000000000000000000000000000000000000..6bc04077adfd3c6ae0ac074bbf53b17af8b9e824 GIT binary patch literal 1328 zcmeAS@N?(olHy`uVBq!ia0vp^0w65F1SAhIZYc#)3dtTpz6=aiY77hwEes65fI!_=LUp?N*q6L`MW6c2BVAkhP7g89w7-U z9g}2AOuQB>b5xrgJALY`G?C1vD^A+8nGBf(b1y^%6vs4IL>4HmVGN#PRIp)D#!X(g zj;Xu7FK*jV@P6m_cddJCBkV#vHeY^!`R9lFfBR>qpJQ%WdWCCoQ=|WPxhLk_Y>6R1 zJRX|oFAM>-fnSa?agmSm#11Yt}8B= zirRkrv`@H9WX>w*pZ_OyGaWC_*?BnO(q!qVU7iPcCj4DwA)!Lav7Pv6W>C!S1` zp1k|!>&b?b*Ke?$thvm_Xy?-BcAmC77e3wfSgQI;;Ir(uygqAF>GU;!wtial>z>>B z)7zd0il1=X%fQGW@PUb8kCO_ASjUCg3b{uW1e#eL&g3xJUf%e@+<<%Me)YYQ4~*X* zYtQ$39r9Iwk8JFpNBSLBM=V!7Jh(P_qqE88hQ$$*IW2A(3=9qoHTm1-u6(lYo8{WG ze;4H6iMszjZT8Hdb+wt3CO+8u=G4JA8-FNjeq~Ev{!S@^`P0F|8tLd6?{jyWO|xlH z-q;;@&}0fvsD;$#Gq*mgIe}B;Pj9g4d@XSLXej&s9V|i*)%NDNvASlynD4czI zYhjAvzDD*Laq*iawjC6_(!l4Ssc(qtv=ie6eg;eN)JS=X|r21<&IJwSMnT&G+3H^{a2D={sY; zqdnnT9r_-!R!e{F_!ih}`0v`e+m9SXG!}{NU-=|CW#XRAuMfA#oqfKG{mRu_DoH*n zllQnUz3}pj^R&&vE0+|#lT>SvoqM`)>e*Mi>D8OhTnw30T=mW%QOwr0W~DRd(pw#| zxt#VHzf^fMTt5AKq^M(?XP5d=On<$_&Ap3{IhE}BHZ@D0VZE5U*@@<^)r-2GBwDsN zzhgN1-_EjQOnSs?_ z%a37#V5?W>xt?5?N=_pwZ-Ln_PbL{pe;pb2LI3R2SG6ul4^@}8c2s`blCz6Na(>hkMTnu9m5GIwv7xqsft7(l z+PuZhC>nC}Q!>*kff@|Wbq&mQjer^qtV~U<3@soU%5F@p1ZvQL+fb63n_66wm|K8u aiKUgHDMXKCUC{=h9tKZWKbLh*2~7Z<^G!zp literal 0 HcmV?d00001 diff --git a/public/icons/docs/bazel/16@2x.png b/public/icons/docs/bazel/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..a8e26f2fbaa4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