Skip to content

Commit

Permalink
Merge pull request freeCodeCamp#1482 from MasterEnoc/openjdk
Browse files Browse the repository at this point in the history
Add overloaded methods to openjdk 11 & 8
  • Loading branch information
simon04 authored Feb 22, 2021
2 parents 38e0724 + ffd8023 commit 0f386fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
38 changes: 14 additions & 24 deletions lib/docs/filters/openjdk/entries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,24 @@ def get_type
end

def additional_entries
# Only keep the first found entry with a unique name,
# i.e. overloaded methods are skipped in index
if version == '8' || version == '8 Gui' || version == '8 Web'
css('a[name$=".summary"]').each_with_object({}) do |summary, entries|
next if summary['name'].include?('nested') || summary['name'].include?('constructor') ||
summary['name'].include?('field') || summary['name'].include?('constant')
summary.parent.css('.memberNameLink a').each do |node|
name = node.parent.parent.content.strip
name.sub! %r{\(.+?\)}m, '()'
id = node['href'].remove(%r{.*#})
entries[name] ||= ["#{self.name}.#{name}", id]
end
end.values
entries = []

else
css('a[id$=".summary"]').each_with_object({}) do |summary, entries|
next if summary['id'].include?('nested') || summary['id'].include?('constructor') ||
summary['id'].include?('field') || summary['id'].include?('constant')
summary.parent.css('.memberNameLink a').each do |node|
name = node.parent.parent.content.strip
name.sub! %r{\(.+?\)}m, '()'
id = node['href'].remove(%r{.*#})
entries[name] ||= ["#{self.name}.#{name}", id]
end
end.values
css('.memberNameLink a').each do |node|
next unless node['href'].match?(/[-(]/) # skip non-methods

if (version=='8' || version == '8 GUI' || version == '8 Web')
id = node['href'].gsub(/.*#/, '')
else
id = slug.downcase + node['href']
end

entries << [self.name + '.' + node.content + '()', id]
end

entries

end

end
end
end
3 changes: 3 additions & 0 deletions lib/docs/scrapers/openjdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Openjdk < FileScraper

version '8' do
self.release = '8'
self.base_url = 'https://docs.oracle.com/javase/8/docs/api/'

html_filters.push OLDFILTERS

Expand Down Expand Up @@ -90,6 +91,7 @@ class Openjdk < FileScraper

version '8 GUI' do
self.release = '8'
self.base_url = 'https://docs.oracle.com/javase/8/docs/api/'

html_filters.push OLDFILTERS

Expand All @@ -102,6 +104,7 @@ class Openjdk < FileScraper

version '8 Web' do
self.release = '8'
self.base_url = 'https://docs.oracle.com/javase/8/docs/api/'

html_filters.push OLDFILTERS

Expand Down

0 comments on commit 0f386fb

Please sign in to comment.