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