From 03d3f206d10b9e1b5e87e675d7bb3fdd6d963dbb Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Mon, 10 Oct 2022 23:03:44 +0200 Subject: [PATCH] Add Astro documentation (1.4.7) --- assets/javascripts/news.json | 4 ++ .../templates/pages/about_tmpl.coffee | 5 +++ lib/docs/filters/astro/clean_html.rb | 28 +++++++++++++ lib/docs/filters/astro/entries.rb | 25 ++++++++++++ lib/docs/scrapers/astro.rb | 38 ++++++++++++++++++ public/icons/docs/astro/16.png | Bin 0 -> 900 bytes public/icons/docs/astro/16@2x.png | Bin 0 -> 1057 bytes public/icons/docs/astro/SOURCE | 2 + 8 files changed, 102 insertions(+) create mode 100644 lib/docs/filters/astro/clean_html.rb create mode 100644 lib/docs/filters/astro/entries.rb create mode 100644 lib/docs/scrapers/astro.rb create mode 100644 public/icons/docs/astro/16.png create mode 100644 public/icons/docs/astro/16@2x.png create mode 100644 public/icons/docs/astro/SOURCE diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index b951eabd..1dbc759f 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,4 +1,8 @@ [ + [ + "2022-10-10", + "New documentation: Astro" + ], [ "2022-10-09", "New documentations: FastAPI, Vitest" diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 087e7e3d..387a8f52 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -101,6 +101,11 @@ credits = [ '2018 The Apache Software Foundation
Apache and the Apache feather logo are trademarks of The Apache Software Foundation.', 'Apache', 'https://www.apache.org/licenses/LICENSE-2.0' + ], [ + 'Astro', + '2022 withastro', + 'MIT', + 'https://github.com/withastro/docs/blob/main/LICENSE' ], [ 'Async', '2010-2018 Caolan McMahon', diff --git a/lib/docs/filters/astro/clean_html.rb b/lib/docs/filters/astro/clean_html.rb new file mode 100644 index 00000000..245bf8b8 --- /dev/null +++ b/lib/docs/filters/astro/clean_html.rb @@ -0,0 +1,28 @@ +module Docs + class Astro + class CleanHtmlFilter < Filter + def call + @doc = at_css('article > section') + + css('.anchor-link').remove + + css('pre').each do |node| + node.content = node.css('.line').map(&:content).join("\n") + node['data-language'] = node.ancestors('figure').first['class'][/lang-(\w+)/, 1] + node.remove_attribute('style') + end + + css('figcaption').each do |node| + node.name = 'div' + node['class'] = '_pre-heading' + end + + css('figure').each do |node| + node.before(node.children).remove + end + + doc + end + end + end +end diff --git a/lib/docs/filters/astro/entries.rb b/lib/docs/filters/astro/entries.rb new file mode 100644 index 00000000..c451058c --- /dev/null +++ b/lib/docs/filters/astro/entries.rb @@ -0,0 +1,25 @@ +module Docs + class Astro + class EntriesFilter < Docs::EntriesFilter + def get_name + name = at_css('h1').content + name.sub! %r{\s*#\s*}, '' + name + end + + def get_type + aside = at_css('aside') + a = aside.at_css('a[aria-current="page"]', 'a[data-current-parent="true"]') + a.ancestors('details').at_css('summary').content + end + + def additional_entries + at_css('article').css('h2, h3').each_with_object [] do |node, entries| + type = node.content.strip + type.sub! %r{\s*#\s*}, '' + entries << ["#{name}: #{type}", node['id']] + end + end + end + end +end diff --git a/lib/docs/scrapers/astro.rb b/lib/docs/scrapers/astro.rb new file mode 100644 index 00000000..1bf3e083 --- /dev/null +++ b/lib/docs/scrapers/astro.rb @@ -0,0 +1,38 @@ +module Docs + class Astro < UrlScraper + self.name = 'Astro' + self.slug = 'astro' + self.type = 'simple' + self.links = { + home: 'https://docs.astro.build/', + code: 'https://github.com/withastro/astro' + } + + # https://github.com/withastro/astro/blob/main/LICENSE + options[:attribution] = <<-HTML + © 2021 Fred K. Schott
+ Licensed under the MIT License. + HTML + + self.release = '1.4.7' + self.base_url = 'https://docs.astro.build/en/' + self.initial_paths = %w(getting-started/) + + html_filters.push 'astro/entries', 'astro/clean_html' + + def get_latest_version(opts) + get_npm_version('astro', opts) + end + + private + + def parse(response) + if response.url == self.base_url + # root_page is a redirect + response.body.gsub! %r{.*}, '

Astro

Astro is a website build tool for the modern web — powerful developer experience meets lightweight output.

' + end + super + end + + end +end diff --git a/public/icons/docs/astro/16.png b/public/icons/docs/astro/16.png new file mode 100644 index 0000000000000000000000000000000000000000..6a34a3ff182615f2052c57663e79b290049546dd GIT binary patch literal 900 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GY}JiEBhjN@7W>RY_)UYH>+oZUKXl zfsv7}p#czu7#UcZm|GbbX&V?=85kVeSe*^j!;&U>cv7h@-A}f%ukn9oU%fL{j z#=y|f!octgDAe$RfuYoZf#FpG1B2BJ1_tqhIlBUFfD-H_p1!W^&$zfm^qJ26{2|W3 zz!($Y6XN>+Kg0jY4F6*p|Hm@?k74*9$^1Q<>01=jRyUp;BZ*i&sUU4xD-}fn8Fdi} zbpa_g0Z9!(33WjUH6d{g0icM4nxMG401%0(GceczE#j9@1q$+k1^LBQ`Nh=v!Rmp^ zfaVK`s{wWKhyhJd_tcODvVnqN1Hpz!sDadgjD;u$Gk|Ub3j&pa+zD3?GFJV698^8f zQlKuN!+>f)c7er#o&pPkHG=%e2(b%lBg6!t$FYe+G$N}9S%;(&$VTSEW#NK513oy&r85ucw1w~a2EfZ5S3riatM^`T&pTMBd z@QA3`jO?7;{L<>Wrr!QZlc&#FxOmC(ox67LKXvZLt=o^EJbV87?Ys9Mzkd7v`=1ks z=Lw*lj7i?^E+zMKSL6aYS3F%DLn;_q4?6lc8%Q)f+#auaHZ5BsVUCKN&mYNu|0h>{ zNSc=MWrI$!^dU7#vCI#ZA*_Wb@=XdadvS3t*s=d|&*tTZtt=9oA2DhCkre3AN&8cB zW^*P>WAPc=cB$}V3{2N_zr=r*^)(Y0IAFbN*UJxb0&Njizk+W+UMC^Y;cB(@__m{B zOiZUw-@hC8`mWuNn27>!6H9A+uRhk)f0Gd+n!8rc$2RToD$Qn31)sfZryZ-QxyjIU z&GDMP`tI842PL+!U(db1{o&8vYz4-E4IAehG5%rppC4-K`G?~!D1bd({an^LB{Ts5 DRcr^8 literal 0 HcmV?d00001 diff --git a/public/icons/docs/astro/16@2x.png b/public/icons/docs/astro/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..7e4c97e589efc7d3c3a6ca504e1b5b48460f1db1 GIT binary patch literal 1057 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dy8YQj~B`Jv|sa7SKxv9k^iMa&~ zMg~Skx`qZo6k=pxWnyM!YN2glU}a!%@Ude(P!CJGqpu?a!^VE@KZ&d$1Cu?1d>I(3 z)EF2VS{N990fib~Fff!FFfhDIU|_JC!N4G1FlSew4N!u;#M9T6{TUaRh@RE|2ZbjX z7#Q0Ed_r7-QUVeh0s;#E6Bq;~)C48efk;4HO;8-jPy;f+NL>IZ2tsNg5-12Fp@Lxb za4uL1O)!DI}>e;|UG0B1uO5OFjz4jAC-AY=dk z|Cg3_85k4wB|(0{K$^iOF2SlS=g}P#ou;Y_Clr=#`XiC!5RkI#0}IcOO#;7G?fAkK zk&x#np)}{+sVmQzTpGG8CYac@-FwEwaz$^RQcXxy!KpuIrtk?(yRc8{h?qo{fS!qs z2G;~OHH9aAVOAziS?hioh{@ggbs%dNOTZ%~CV^FAKT3AI&^X01kJCs8=mN$hZ+DkQ zp9O#jb;iIXgz))?}&rphTXe`-{`%`b9LSL{$I(=$dC>l`HzXG@G&{Km8eS7hj(c@v0nY-NY}ciXD;6zY&6suKiWGyk?K-{% z^BUM{-(?&r6uy;KqPx~=LGQP%i{C2TUdg;G<5uss_MG+a+`m5DP|xsJ;jWnq^WiPo zE}!EJwHT94q{C-(W~r$jP;IHss&dOsd;TofNhjm8>-R~uk=7BBrIy!C{{CWHXLxDh z?C4+lPjBAi+!f1Ta4Yy5KVN^Jzu)f(-YK yE0}+F%lmv;wWo3AJ^Pwx2cC=nQT)IC&VPoRTkEb$Z1K+nMXRT)pUXO@geCy|wqVr& literal 0 HcmV?d00001 diff --git a/public/icons/docs/astro/SOURCE b/public/icons/docs/astro/SOURCE new file mode 100644 index 00000000..40392a4a --- /dev/null +++ b/public/icons/docs/astro/SOURCE @@ -0,0 +1,2 @@ +https://docs.astro.build/favicon.ico +https://docs.astro.build/favicon.svg