Skip to content
Merged
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
28 changes: 24 additions & 4 deletions lib/docs/filters/homebrew/entries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,20 @@ class Homebrew
class EntriesFilter < Docs::EntriesFilter
def get_name
header = at_css('h1')
name = header.nil? ? current_url.normalized_path[1..-1].gsub(/-/, ' ') : header.content.strip
name.remove! %r{\(.*}

if current_url.path.start_with?('/rubydoc')
# Titles in rubydoc content follow a different format, with a bit of cleanup needed.
name = header
.content
.gsub('Class: ', '')
.gsub('Module: ', '')
.gsub('Exception: ', '')
.gsub(' Private', '')
else
name = header.nil? ? current_url.normalized_path[1..-1].gsub(/-/, ' ') : header.content.strip
name.remove! %r{\(.*}
end

name
end

Expand All @@ -26,13 +38,21 @@ def get_name
Building-Against-Non-Homebrew-Dependencies
How-to-Create-and-Maintain-a-Tap
Brew-Test-Bot
Prose-Style-Guidelines
Typechecking
Reproducible-Builds
)

def get_type
if CONTRIBUTOR_SLUGS.include?(slug)
if current_url.path.start_with?('/rubydoc')
header = at_css('h1').content
if header.start_with?('Module')
'API Modules'
elsif header.start_with?('Class')
'API Classes'
else
'API Exceptions'
end
elsif CONTRIBUTOR_SLUGS.include?(slug)
'Contributors'
else
'Users'
Expand Down
7 changes: 3 additions & 4 deletions lib/docs/scrapers/haskell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ class Haskell < UrlScraper
end

def get_latest_version(opts)
doc = fetch_doc('https://www.haskell.org/ghc/download.html', opts)
links = doc.css('a').to_a
versions = links.map {|link| link.content.scan(/\A([0-9.]+)\Z/)}
versions.find {|version| !version.empty?}[0][0]
tags = get_github_tags('ghc', 'ghc', opts)
tag = tags.find {|t| t['name'].ends_with?('-release') }['name']
tag[/ghc-(.*)-release/, 1]
end

end
Expand Down
28 changes: 25 additions & 3 deletions lib/docs/scrapers/homebrew.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module Docs
class Homebrew < UrlScraper
# include MultipleBaseUrls

self.name = 'Homebrew'
self.type = 'simple'
self.release = '4.6.15'
self.release = '6.0.3'
self.base_url = 'https://docs.brew.sh/'
self.links = {
home: 'https://brew.sh',
Expand All @@ -11,9 +13,29 @@ class Homebrew < UrlScraper

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

options[:container] = ->(filter) { filter.root_page? ? '#home' : '#page' }
options[:container] = ->(filter) do
if filter.current_url.path.include?('rubydoc')
'#content'
else
'#default'
end
end

options[:skip_patterns] = [/maintainer/i, /core\-contributor/i, /kickstarter/i, /governance/i]
# Mostly handbook articles with no code.
options[:skip_patterns] = [
/maintainer/i,
/core\-contributor/i,
/kickstarter/i,
/governance/i,
/responsible/i,
/leadership/i,
/prose/i,
/expense/i,
/creating-a-homebrew-issue/i,
/homebrew-and-java/i,
/checksum_deprecation/i,
/Working-with/i
]

options[:attribution] = <<-HTML
&copy; 2009&ndash;present Homebrew contributors<br>
Expand Down
3 changes: 1 addition & 2 deletions lib/docs/scrapers/love.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ class Love < UrlScraper
HTML

def get_latest_version(opts)
doc = fetch_doc('https://love2d.org/wiki/Version_History', opts)
doc.at_css('#mw-content-text table a').content
get_github_tags('love2d', 'love', opts).first['name']
end
end
end
4 changes: 1 addition & 3 deletions lib/docs/scrapers/mongoose.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ class Mongoose < UrlScraper
HTML

def get_latest_version(opts)
doc = fetch_doc('https://mongoosejs.com/docs/', opts)
label = doc.at_css('.pure-menu-link').content.strip
label.sub(/Version /, '')
get_github_tags('Automattic', 'mongoose', opts).find {|t| t['name'].starts_with?(/\d/)}['name']
end
end
end
3 changes: 2 additions & 1 deletion lib/docs/scrapers/python.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Python < UrlScraper

options[:skip_patterns] = [/whatsnew/]
options[:skip] = %w(
archives/
library/2to3.html
library/formatter.html
library/intro.html
Expand All @@ -28,7 +29,7 @@ class Python < UrlScraper
HTML

version '3.14' do
self.release = '3.14.4'
self.release = '3.14.6'
self.base_url = "https://docs.python.org/#{self.version}/"

html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
Expand Down
4 changes: 2 additions & 2 deletions lib/docs/scrapers/tensorflow/tensorflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class Tensorflow < UrlScraper
end

def get_latest_version(opts)
doc = fetch_doc(self.base_url, opts)
doc.title[/TensorFlow v([.\d]+)/, 1]
tag = get_github_tags('tensorflow', 'tensorflow', opts).find { |t| !t['name'].include?('-rc') }
tag['name'][1..-1]
end

private
Expand Down
8 changes: 4 additions & 4 deletions lib/docs/scrapers/threejs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ class Threejs < UrlScraper
self.base_url = "https://threejs.org/docs"

def get_latest_version(opts)
get_latest_github_release('mrdoob', 'three.js', opts)[1..]
get_github_tags('mrdoob', 'three.js', opts).first['name'][1..]
end

def initial_paths
paths = []
url = 'https://threejs.org/docs/list.json'
url = 'https://threejs.org/docs/search.json'
response = Request.run(url)
json_data = JSON.parse(response.body)

# Process both API and manual sections
process_documentation(json_data['en'], paths)
process_documentation(json_data, paths)
paths
end

Expand All @@ -78,4 +78,4 @@ def process_documentation(data, paths, prefix = '')
end
end
end
end
end
Loading