Merge pull request #1475 from MasterEnoc/openjdk

Fix Openjdk additional entries and style
pull/1480/head
Simon Legner 4 years ago committed by GitHub
commit 06dbf8a0f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,14 +5,14 @@ module Docs
class Openjdk
class CleanHtmlFilter < Filter
def call
css('.topNav', '.subNav', '.bottomNav', '.legalCopy', 'noscript', '.subTitle').remove
css('.topNav', '.subNav', '.bottomNav', '.legalCopy', 'noscript', '.subTitle', 'hr').remove
# Preserve internal fragment links
# Transform <a name="foo"><!-- --></a><bar>text</bar>
# into <bar id="foo">text</bar>
css('a[name]').each do |node|
css('a[name]','a[id]').each do |node|
if node.children.all?(&:blank?)
node.next_element['id'] = node['name'] if node.next_element
node.next_element['id'] = (node['id'] || node['name'])if node.next_element
node.remove
end
end
@ -23,11 +23,9 @@ module Docs
node.remove
end
# Replace summary tables with their detail content
css('h3[id$=".summary"]').each do |node|
id = node['id'].sub('summary', 'detail')
detail = at_css("h3[id='#{id}']") || at_css("h3[id='#{id.remove('optional.').remove('required.')}']")
node.parent.children = detail.parent.children if detail
# remove captions in tables
css('table caption').each do |node|
node.remove
end
css('h3[id$=".summary"]', 'h3[id$=".detail"]').each do |node|

@ -7,15 +7,7 @@ module Docs
at_css('h1').content = "OpenJDK #{release} Documentation"
end
css('.header .sub-title').remove
css('blockquote pre').each do |node|
node.parent.name = 'pre'
node.parent['class'] = 'highlight'
node.parent['data-language'] = 'java'
node.parent.content = node.content
node.remove
end
css('.header .sub-title', 'hr', '.table-tabs').remove
# fix ul section that contains summaries or tables
css('ul').each do |node|
@ -24,6 +16,13 @@ module Docs
end
end
css('ul.summary-list').each do |node|
node.css('li').each do |subnode|
subnode.name = 'div'
end
node.name = 'div'
end
# add syntax highlight to code blocks
css('pre > code').each do |node|
node.parent['class'] = 'lang-java'

@ -29,16 +29,31 @@ module Docs
def additional_entries
# Only keep the first found entry with a unique name,
# i.e. overloaded methods are skipped in index
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
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
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
end
end
end
end

@ -28,16 +28,14 @@ module Docs
end
def additional_entries
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 = []
css('section[id]').each do |node|
next if !(node['id'].match?(/\(/))
entries << [self.name+ '.' +node.at_css('h3').content + '()', node['id']]
end
entries
end
end

@ -22,7 +22,10 @@ module Docs
/\.png/
]
options[:only_patterns] = [/\Ajava\./]
options[:only_patterns] = [
/\Ajava\./,
/\Ajdk\./
]
options[:attribution] = <<-HTML
&copy; 1993, 2020, Oracle and/or its affiliates. All rights reserved.<br>
@ -37,6 +40,7 @@ module Docs
version '15' do
self.release = '15.0.1'
self.root_path = 'index.html'
self.base_url = 'https://docs.oracle.com/en/java/javase/15/docs/api/'
html_filters.push NEWFILTERS

Loading…
Cancel
Save