Add Astro documentation (1.4.7)
Unified · Split
| @@ -1,4 +1,8 @@ | ||
| 1 | 1 | [ |
| 2 | + [ | |
| 3 | + "2022-10-10", | |
| 4 | + "New documentation: <a href=\"/astro/\">Astro</a>" | |
| 5 | + ], | |
| 2 | 6 | [ |
| 3 | 7 | "2022-10-09", |
| 4 | 8 | "New documentations: <a href=\"/fastapi/\">FastAPI</a>, <a href=\"/vitest/\">Vitest</a>" |
| @@ -101,6 +101,11 @@ credits = [ · 100 unmodified lines | ||
| 101 | 101 | '2018 The Apache Software Foundation<br>Apache and the Apache feather logo are trademarks of The Apache Software Foundation.', |
| 102 | 102 | 'Apache', |
| 103 | 103 | 'https://www.apache.org/licenses/LICENSE-2.0' |
| 104 | + ], [ | |
| 105 | + 'Astro', | |
| 106 | + '2022 withastro', | |
| 107 | + 'MIT', | |
| 108 | + 'https://github.com/withastro/docs/blob/main/LICENSE' | |
| 104 | 109 | ], [ |
| 105 | 110 | 'Async', |
| 106 | 111 | '2010-2018 Caolan McMahon', |
| @@ -0,0 +1,28 @@ | ||
| 1 | +module Docs | |
| 2 | + class Astro | |
| 3 | + class CleanHtmlFilter < Filter | |
| 4 | + def call | |
| 5 | + @doc = at_css('article > section') | |
| 6 | + | |
| 7 | + css('.anchor-link').remove | |
| 8 | + | |
| 9 | + css('pre').each do |node| | |
| 10 | + node.content = node.css('.line').map(&:content).join("\n") | |
| 11 | + node['data-language'] = node.ancestors('figure').first['class'][/lang-(\w+)/, 1] | |
| 12 | + node.remove_attribute('style') | |
| 13 | + end | |
| 14 | + | |
| 15 | + css('figcaption').each do |node| | |
| 16 | + node.name = 'div' | |
| 17 | + node['class'] = '_pre-heading' | |
| 18 | + end | |
| 19 | + | |
| 20 | + css('figure').each do |node| | |
| 21 | + node.before(node.children).remove | |
| 22 | + end | |
| 23 | + | |
| 24 | + doc | |
| 25 | + end | |
| 26 | + end | |
| 27 | + end | |
| 28 | +end | |
| @@ -0,0 +1,25 @@ | ||
| 1 | +module Docs | |
| 2 | + class Astro | |
| 3 | + class EntriesFilter < Docs::EntriesFilter | |
| 4 | + def get_name | |
| 5 | + name = at_css('h1').content | |
| 6 | + name.sub! %r{\s*#\s*}, '' | |
| 7 | + name | |
| 8 | + end | |
| 9 | + | |
| 10 | + def get_type | |
| 11 | + aside = at_css('aside') | |
| 12 | + a = aside.at_css('a[aria-current="page"]', 'a[data-current-parent="true"]') | |
| 13 | + a.ancestors('details').at_css('summary').content | |
| 14 | + end | |
| 15 | + | |
| 16 | + def additional_entries | |
| 17 | + at_css('article').css('h2, h3').each_with_object [] do |node, entries| | |
| 18 | + type = node.content.strip | |
| 19 | + type.sub! %r{\s*#\s*}, '' | |
| 20 | + entries << ["#{name}: #{type}", node['id']] | |
| 21 | + end | |
| 22 | + end | |
| 23 | + end | |
| 24 | + end | |
| 25 | +end | |
| @@ -0,0 +1,38 @@ | ||
| 1 | +module Docs | |
| 2 | + class Astro < UrlScraper | |
| 3 | + self.name = 'Astro' | |
| 4 | + self.slug = 'astro' | |
| 5 | + self.type = 'simple' | |
| 6 | + self.links = { | |
| 7 | + home: 'https://docs.astro.build/', | |
| 8 | + code: 'https://github.com/withastro/astro' | |
| 9 | + } | |
| 10 | + | |
| 11 | + # https://github.com/withastro/astro/blob/main/LICENSE | |
| 12 | + options[:attribution] = <<-HTML | |
| 13 | + © 2021 Fred K. Schott<br> | |
| 14 | + Licensed under the MIT License. | |
| 15 | + HTML | |
| 16 | + | |
| 17 | + self.release = '1.4.7' | |
| 18 | + self.base_url = 'https://docs.astro.build/en/' | |
| 19 | + self.initial_paths = %w(getting-started/) | |
| 20 | + | |
| 21 | + html_filters.push 'astro/entries', 'astro/clean_html' | |
| 22 | + | |
| 23 | + def get_latest_version(opts) | |
| 24 | + get_npm_version('astro', opts) | |
| 25 | + end | |
| 26 | + | |
| 27 | + private | |
| 28 | + | |
| 29 | + def parse(response) | |
| 30 | + if response.url == self.base_url | |
| 31 | + # root_page is a redirect | |
| 32 | + response.body.gsub! %r{.*}, '<body><article><section><h1>Astro</h1><p> Astro is a website build tool for the modern web — powerful developer experience meets lightweight output.</p></section></article></body>' | |
| 33 | + end | |
| 34 | + super | |
| 35 | + end | |
| 36 | + | |
| 37 | + end | |
| 38 | +end | |
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1,2 @@ | ||
| 1 | +https://docs.astro.build/favicon.ico | |
| 2 | +https://docs.astro.build/favicon.svg | |