Skip to content

Commit

Permalink
Merge pull request #2304 from Lippiece/main
Browse files Browse the repository at this point in the history
Update Astro docs to 4.12.3
  • Loading branch information
simon04 committed Aug 18, 2024
2 parents a49e13d + 837c6e6 commit 38ce1af
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
5 changes: 2 additions & 3 deletions lib/docs/filters/astro/clean_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Docs
class Astro
class CleanHtmlFilter < Filter
def call
@doc = at_css('article > section')
@doc = at_css('main')

css('.anchor-link').remove
css('.avatar-list').remove
Expand All @@ -12,8 +12,7 @@ def call
end

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.content = node.css('.ec-line').map(&:content).join("\n")
node.remove_attribute('style')
end

Expand Down
18 changes: 9 additions & 9 deletions lib/docs/filters/astro/entries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ module Docs
class Astro
class EntriesFilter < Docs::EntriesFilter
def get_name
name = at_css('article h1').content
name.sub! %r{\s*#\s*}, ''
name = at_css('h1') ? at_css('h1').content : at_css('h2').content
name.sub!(/\s*#\s*/, '')
name
end

def get_type
return 'Guides' if slug.start_with?('contribute/')
return 'Guides' if slug.start_with?('guides/')
aside = at_css('aside')
a = aside.at_css('a[aria-current="page"]', 'a[data-current-parent="true"]')
a.ancestors('details').at_css('summary').content
return 'Contribute' if slug.start_with?('contribute/')

a = at_css('a[aria-current="page"]')
a ? a.content : 'Other'
end

def additional_entries
return [] if slug.start_with?('guides/deploy')
return [] if slug.start_with?('guides/integrations-guide')
at_css('article').css('h2[id], h3[id]').each_with_object [] do |node, entries|

at_css('main').css('h2[id], h3[id]').each_with_object [] do |node, entries|
type = node.content.strip
type.sub! %r{\s*#\s*}, ''
type.sub!(/\s*#\s*/, '')
entries << ["#{name}: #{type}", node['id']]
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/docs/scrapers/astro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ class Astro < UrlScraper

# https://github.com/withastro/astro/blob/main/LICENSE
options[:attribution] = <<-HTML
&copy; 2021 Fred K. Schott<br>
Copyright (c) 2022 withastro<br>
Licensed under the MIT License.
HTML

options[:skip_patterns] = [/tutorial/]

self.release = '3.2.0'
self.release = '4.12.3'
self.base_url = 'https://docs.astro.build/en/'
self.initial_paths = %w(getting-started/)
self.initial_paths = %w(install-and-setup/)

html_filters.push 'astro/entries', 'astro/clean_html'

Expand Down

0 comments on commit 38ce1af

Please sign in to comment.