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

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

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

@ -28,16 +28,14 @@ module Docs
end end
def additional_entries def additional_entries
css('a[name$=".summary"]').each_with_object({}) do |summary, entries| entries = []
next if summary['name'].include?('nested') || summary['name'].include?('constructor') ||
summary['name'].include?('field') || summary['name'].include?('constant') css('section[id]').each do |node|
summary.parent.css('.memberNameLink a').each do |node| next if !(node['id'].match?(/\(/))
name = node.parent.parent.content.strip entries << [self.name+ '.' +node.at_css('h3').content + '()', node['id']]
name.sub! %r{\(.+?\)}m, '()' end
id = node['href'].remove(%r{.*#})
entries[name] ||= ["#{self.name}.#{name}", id] entries
end
end.values
end end
end end

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

Loading…
Cancel
Save