Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Drupal UrlScraper #1790

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/docs/filters/drupal/entries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_type
elsif subpath =~ /core!themes/
'themes'
else
css('.breadcrumb > a')[1].content
css('.breadcrumb a')[1].content
end
end

Expand Down
114 changes: 94 additions & 20 deletions lib/docs/scrapers/drupal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ class Drupal < UrlScraper
self.base_url = 'https://api.drupal.org/api/drupal/'
self.links = {
home: 'https://www.drupal.org/',
code: 'http://cgit.drupalcode.org/drupal'
code: 'https://git.drupalcode.org/project/drupal'
}

html_filters.push 'drupal/entries', 'drupal/clean_html', 'title'

options[:decode_and_clean_paths] = true
options[:container] = '#page-inner'
options[:container] = '#page'
options[:title] = false
options[:root_title] = 'Drupal'

Expand Down Expand Up @@ -38,34 +38,108 @@ class Drupal < UrlScraper
]

options[:attribution] = <<-HTML
&copy; 2001&ndash;2016 by the original authors<br>
&copy; 2001&ndash;2022 by the original authors<br>
Licensed under the GNU General Public License, version 2 and later.<br>
Drupal is a registered trademark of Dries Buytaert.
HTML

version '10' do
self.release = '10.0.0-alpha6'
self.root_path = '10.0.x'
self.initial_paths = %w(groups/10.0.x groups/10.0.x?page=1)

options[:only_patterns] = [
/\/class\/[^\/]+\/10\.0\.x\z/,
/\/group\/[^\/]+\/10\.0\.x\z/,
/\/function\/[^\/]+\/10\.0\.x\z/,
/\/constant\/[^\/]+\/10\.0\.x\z/,
/\/interface\/[^\/]+\/10\.0\.x\z/,
/\/property\/[^\/]+\/10\.0\.x\z/,
/\/global\/[^\/]+\/10\.0\.x\z/,
/\/trait\/[^\/]+\/10\.0\.x\z/,
/modules.*\/10\.0\.x\z/,
/includes.*\/10\.0\.x\z/,
/\A[\w\-\.]+\.php\/10\.0\.x\z/
]

options[:skip] = %w(index.php/8.1.x update.php/10.0.x)

options[:skip_patterns] += [
/[^\w\-\.].*\.php\/10\.0\.x\z/,
/\!src\!/,
/migrate/,
/Assertion/,
/listing_page/,
/update_api/,
/vendor/,
/deprecated/,
/namespace/,
/\.yml/,
/Plugin/,
/\.theme\//
]
end

version '9' do
self.release = '9.3.19'
self.root_path = '9.3.x'
self.initial_paths = %w(groups/9.3.x groups/9.3.x?page=1)

options[:only_patterns] = [
/\/class\/[^\/]+\/9\.3\.x\z/,
/\/group\/[^\/]+\/9\.3\.x\z/,
/\/function\/[^\/]+\/9\.3\.x\z/,
/\/constant\/[^\/]+\/9\.3\.x\z/,
/\/interface\/[^\/]+\/9\.3\.x\z/,
/\/property\/[^\/]+\/9\.3\.x\z/,
/\/global\/[^\/]+\/9\.3\.x\z/,
/\/trait\/[^\/]+\/9\.3\.x\z/,
/modules.*\/9\.3\.x\z/,
/includes.*\/9\.3\.x\z/,
/\A[\w\-\.]+\.php\/9\.3\.x\z/
]

options[:skip] = %w(index.php/8.1.x update.php/9.3.x)

options[:skip_patterns] += [
/[^\w\-\.].*\.php\/9\.3\.x\z/,
/\!src\!/,
/migrate/,
/Assertion/,
/listing_page/,
/update_api/,
/vendor/,
/deprecated/,
/namespace/,
/\.yml/,
/Plugin/,
/\.theme\//
]
end

version '8' do
self.release = '8.1.7'
self.root_path = '8.1.x'
self.initial_paths = %w(groups/8.1.x groups/8.1.x?page=1)
self.release = '8.9.20'
self.root_path = '8.9.x'
self.initial_paths = %w(groups/8.9.x groups/8.9.x?page=1)

options[:only_patterns] = [
/\/class\/[^\/]+\/8\.1\.x\z/,
/\/group\/[^\/]+\/8\.1\.x\z/,
/\/function\/[^\/]+\/8\.1\.x\z/,
/\/constant\/[^\/]+\/8\.1\.x\z/,
/\/interface\/[^\/]+\/8\.1\.x\z/,
/\/property\/[^\/]+\/8\.1\.x\z/,
/\/global\/[^\/]+\/8\.1\.x\z/,
/\/trait\/[^\/]+\/8\.1\.x\z/,
/modules.*\/8\.1\.x\z/,
/includes.*\/8\.1\.x\z/,
/\A[\w\-\.]+\.php\/8\.1\.x\z/
/\/class\/[^\/]+\/8\.9\.x\z/,
/\/group\/[^\/]+\/8\.9\.x\z/,
/\/function\/[^\/]+\/8\.9\.x\z/,
/\/constant\/[^\/]+\/8\.9\.x\z/,
/\/interface\/[^\/]+\/8\.9\.x\z/,
/\/property\/[^\/]+\/8\.9\.x\z/,
/\/global\/[^\/]+\/8\.9\.x\z/,
/\/trait\/[^\/]+\/8\.9\.x\z/,
/modules.*\/8\.9\.x\z/,
/includes.*\/8\.9\.x\z/,
/\A[\w\-\.]+\.php\/8\.9\.x\z/
]

options[:skip] = %w(index.php/8.1.x update.php/8.1.x)
options[:skip] = %w(index.php/8.9.x update.php/8.9.x)

options[:skip_patterns] += [
/[^\w\-\.].*\.php\/8\.1\.x\z/,
/[^\w\-\.].*\.php\/8\.9\.x\z/,
/\!src\!/,
/migrate/,
/Assertion/,
Expand All @@ -81,7 +155,7 @@ class Drupal < UrlScraper
end

version '7' do
self.release = '7.50'
self.release = '7.91'
self.root_path = '7.x'
self.initial_paths = %w(groups/7.x groups/7.x?page=1)

Expand Down