Fix Openjdk additional entries and style
Unified · Split
| @@ -5,14 +5,14 @@ module Docs · 4 unmodified lines | ||
| 5 | 5 | class Openjdk |
| 6 | 6 | class CleanHtmlFilter < Filter |
| 7 | 7 | def call |
| 8 | − css('.topNav', '.subNav', '.bottomNav', '.legalCopy', 'noscript', '.subTitle').remove | |
| 8 | + css('.topNav', '.subNav', '.bottomNav', '.legalCopy', 'noscript', '.subTitle', 'hr').remove | |
| 9 | 9 | |
| 10 | 10 | # Preserve internal fragment links |
| 11 | 11 | # Transform <a name="foo"><!-- --></a><bar>text</bar> |
| 12 | 12 | # into <bar id="foo">text</bar> |
| 13 | − css('a[name]').each do |node| | |
| 13 | + css('a[name]','a[id]').each do |node| | |
| 14 | 14 | if node.children.all?(&:blank?) |
| 15 | − node.next_element['id'] = node['name'] if node.next_element | |
| 15 | + node.next_element['id'] = (node['id'] || node['name'])if node.next_element | |
| 16 | 16 | node.remove |
| 17 | 17 | end |
| 18 | 18 | end |
| @@ -23,11 +23,9 @@ module Docs · 4 unmodified lines | ||
| 23 | 23 | node.remove |
| 24 | 24 | end |
| 25 | 25 | |
| 26 | − # Replace summary tables with their detail content | |
| 27 | − css('h3[id$=".summary"]').each do |node| | |
| 28 | − id = node['id'].sub('summary', 'detail') | |
| 29 | − detail = at_css("h3[id='#{id}']") || at_css("h3[id='#{id.remove('optional.').remove('required.')}']") | |
| 30 | − node.parent.children = detail.parent.children if detail | |
| 26 | + # remove captions in tables | |
| 27 | + css('table caption').each do |node| | |
| 28 | + node.remove | |
| 31 | 29 | end |
| 32 | 30 | |
| 33 | 31 | css('h3[id$=".summary"]', 'h3[id$=".detail"]').each do |node| |
| @@ -7,15 +7,7 @@ module Docs · 6 unmodified lines | ||
| 7 | 7 | at_css('h1').content = "OpenJDK #{release} Documentation" |
| 8 | 8 | end |
| 9 | 9 | |
| 10 | − css('.header .sub-title').remove | |
| 11 | − | |
| 12 | − css('blockquote pre').each do |node| | |
| 13 | − node.parent.name = 'pre' | |
| 14 | − node.parent['class'] = 'highlight' | |
| 15 | − node.parent['data-language'] = 'java' | |
| 16 | − node.parent.content = node.content | |
| 17 | − node.remove | |
| 18 | − end | |
| 10 | + css('.header .sub-title', 'hr', '.table-tabs').remove | |
| 19 | 11 | |
| 20 | 12 | # fix ul section that contains summaries or tables |
| 21 | 13 | css('ul').each do |node| |
| @@ -24,6 +16,13 @@ module Docs · 2 unmodified lines | ||
| 24 | 16 | end |
| 25 | 17 | end |
| 26 | 18 | |
| 19 | + css('ul.summary-list').each do |node| | |
| 20 | + node.css('li').each do |subnode| | |
| 21 | + subnode.name = 'div' | |
| 22 | + end | |
| 23 | + node.name = 'div' | |
| 24 | + end | |
| 25 | + | |
| 27 | 26 | # add syntax highlight to code blocks |
| 28 | 27 | css('pre > code').each do |node| |
| 29 | 28 | node.parent['class'] = 'lang-java' |
| @@ -29,16 +29,31 @@ module Docs · 28 unmodified lines | ||
| 29 | 29 | def additional_entries |
| 30 | 30 | # Only keep the first found entry with a unique name, |
| 31 | 31 | # i.e. overloaded methods are skipped in index |
| 32 | − css('a[name$=".summary"]').each_with_object({}) do |summary, entries| | |
| 33 | − next if summary['name'].include?('nested') || summary['name'].include?('constructor') || | |
| 34 | − summary['name'].include?('field') || summary['name'].include?('constant') | |
| 35 | − summary.parent.css('.memberNameLink a').each do |node| | |
| 36 | − name = node.parent.parent.content.strip | |
| 37 | − name.sub! %r{\(.+?\)}m, '()' | |
| 38 | − id = node['href'].remove(%r{.*#}) | |
| 39 | − entries[name] ||= ["#{self.name}.#{name}", id] | |
| 40 | − end | |
| 41 | − end.values | |
| 32 | + if version == '8' || version == '8 Gui' || version == '8 Web' | |
| 33 | + css('a[name$=".summary"]').each_with_object({}) do |summary, entries| | |
| 34 | + next if summary['name'].include?('nested') || summary['name'].include?('constructor') || | |
| 35 | + summary['name'].include?('field') || summary['name'].include?('constant') | |
| 36 | + summary.parent.css('.memberNameLink a').each do |node| | |
| 37 | + name = node.parent.parent.content.strip | |
| 38 | + name.sub! %r{\(.+?\)}m, '()' | |
| 39 | + id = node['href'].remove(%r{.*#}) | |
| 40 | + entries[name] ||= ["#{self.name}.#{name}", id] | |
| 41 | + end | |
| 42 | + end.values | |
| 43 | + | |
| 44 | + else | |
| 45 | + css('a[id$=".summary"]').each_with_object({}) do |summary, entries| | |
| 46 | + next if summary['id'].include?('nested') || summary['id'].include?('constructor') || | |
| 47 | + summary['id'].include?('field') || summary['id'].include?('constant') | |
| 48 | + summary.parent.css('.memberNameLink a').each do |node| | |
| 49 | + name = node.parent.parent.content.strip | |
| 50 | + name.sub! %r{\(.+?\)}m, '()' | |
| 51 | + id = node['href'].remove(%r{.*#}) | |
| 52 | + entries[name] ||= ["#{self.name}.#{name}", id] | |
| 53 | + end | |
| 54 | + end.values | |
| 55 | + end | |
| 56 | + | |
| 42 | 57 | end |
| 43 | 58 | end |
| 44 | 59 | end |
| @@ -28,16 +28,14 @@ module Docs · 27 unmodified lines | ||
| 28 | 28 | end |
| 29 | 29 | |
| 30 | 30 | def additional_entries |
| 31 | − css('a[name$=".summary"]').each_with_object({}) do |summary, entries| | |
| 32 | − next if summary['name'].include?('nested') || summary['name'].include?('constructor') || | |
| 33 | − summary['name'].include?('field') || summary['name'].include?('constant') | |
| 34 | − summary.parent.css('.memberNameLink a').each do |node| | |
| 35 | − name = node.parent.parent.content.strip | |
| 36 | − name.sub! %r{\(.+?\)}m, '()' | |
| 37 | − id = node['href'].remove(%r{.*#}) | |
| 38 | − entries[name] ||= ["#{self.name}.#{name}", id] | |
| 39 | − end | |
| 40 | − end.values | |
| 31 | + entries = [] | |
| 32 | + | |
| 33 | + css('section[id]').each do |node| | |
| 34 | + next if !(node['id'].match?(/\(/)) | |
| 35 | + entries << [self.name+ '.' +node.at_css('h3').content + '()', node['id']] | |
| 36 | + end | |
| 37 | + | |
| 38 | + entries | |
| 41 | 39 | end |
| 42 | 40 | |
| 43 | 41 | end |
| @@ -22,7 +22,10 @@ module Docs · 21 unmodified lines | ||
| 22 | 22 | /\.png/ |
| 23 | 23 | ] |
| 24 | 24 | |
| 25 | − options[:only_patterns] = [/\Ajava\./] | |
| 25 | + options[:only_patterns] = [ | |
| 26 | + /\Ajava\./, | |
| 27 | + /\Ajdk\./ | |
| 28 | + ] | |
| 26 | 29 | |
| 27 | 30 | options[:attribution] = <<-HTML |
| 28 | 31 | © 1993, 2020, Oracle and/or its affiliates. All rights reserved.<br> |
| @@ -37,6 +40,7 @@ module Docs · 8 unmodified lines | ||
| 37 | 40 | version '15' do |
| 38 | 41 | self.release = '15.0.1' |
| 39 | 42 | self.root_path = 'index.html' |
| 43 | + self.base_url = 'https://docs.oracle.com/en/java/javase/15/docs/api/' | |
| 40 | 44 | |
| 41 | 45 | html_filters.push NEWFILTERS |
| 42 | 46 | |