History

Add Openjdk version 13, 14, 15 and 16

MasterEnoc committed 5 years ago

Commit fc900c21 parent d03c98e5 files · +152 −22Browse files

Showing the changes to lib/docs (4 of 5 files). Show all

Unified · Split

4 files
  1. lib/docs/filters/openjdk/clean_html.rb +8 −0
  2. lib/docs/filters/openjdk/clean_html_new.rb +31 −0
  3. lib/docs/filters/openjdk/entries_new.rb +45 −0
  4. lib/docs/scrapers/openjdk.rb +60 −7
lib/docs/filters/openjdk/clean_html.rb+8−0
@@ -1,3 +1,4 @@
1+# coding: utf-8
12 # frozen_string_literal: true
23
34 module Docs
@@ -130,6 +131,13 @@ module Docs · 126 unmodified lines
130131 node.remove_attribute('class') unless node['class'] == 'inheritance'
131132 end
132133
134+ # fix ul section that contains summaries or tables
135+ css('ul').each do |node|
136+ node.css('section').each do |subnode|
137+ node.add_previous_sibling(subnode)
138+ end
139+ end
140+
133141 doc
134142 end
135143 end
lib/docs/filters/openjdk/clean_html_new.rb+31−0
@@ -0,0 +1,31 @@
1+module Docs
2+ class Openjdk
3+ class CleanHtmlNewFilter < Filter
4+ def call
5+
6+ if root_page?
7+ at_css('h1').content = "OpenJDK #{release} Documentation"
8+ end
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
19+
20+ # fix ul section that contains summaries or tables
21+ css('ul').each do |node|
22+ node.css('section').each do |subnode|
23+ node.add_previous_sibling(subnode)
24+ end
25+ end
26+
27+ doc
28+ end
29+ end
30+ end
31+end
lib/docs/filters/openjdk/entries_new.rb+45−0
@@ -0,0 +1,45 @@
1+module Docs
2+ class Openjdk
3+ class EntriesNewFilter < Docs::EntriesFilter
4+
5+ def get_name
6+ name = at_css('.header > .title').content.strip
7+ name.remove! 'Package '
8+ name.remove! 'Class '
9+ name.remove! 'Interface '
10+ name.remove! 'Annotation Type '
11+ name.remove! 'Enum '
12+ name.remove! %r{<.*}
13+ name
14+ end
15+
16+ def get_type
17+ return 'Packages' if slug.end_with?('package-summary')
18+ return 'Modules' if slug.end_with?('module-summary')
19+
20+ if subtitle = at_css('.header > .sub-title:last-of-type')
21+ type = subtitle.content.strip
22+ else
23+ type = at_css('.header > .title').content.strip.remove 'Package '
24+ type.remove!('Module ')
25+ end
26+ type = type.split('.')[0..2].join('.')
27+ type
28+ end
29+
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
41+ end
42+
43+ end
44+ end
45+end
lib/docs/scrapers/openjdk.rb+60−7
@@ -1,7 +1,6 @@
11 module Docs
22 class Openjdk < FileScraper
3− # Downloaded from packages.debian.org/sid/openjdk-8-doc
4− # Extracting subdirectory /usr/share/doc/openjdk-8-jre-headless/api
3+
54 self.name = 'OpenJDK'
65 self.type = 'openjdk'
76 self.root_path = 'overview-summary.html'
@@ -11,7 +10,6 @@ module Docs · 3 unmodified lines
1110 }
1211
1312 html_filters.insert_after 'internal_urls', 'openjdk/clean_urls'
14− html_filters.push 'openjdk/entries', 'openjdk/clean_html'
1513
1614 options[:skip_patterns] = [
1715 /compact[123]-/,
@@ -19,7 +17,12 @@ module Docs · 1 unmodified line
1917 /package-tree\.html/,
2018 /package-use\.html/,
2119 /class-use\//,
22− /doc-files\//]
20+ /doc-files\//,
21+ /\.svg/,
22+ /\.png/
23+ ]
24+
25+ options[:only_patterns] = [/\Ajava\./]
2326
2427 options[:attribution] = <<-HTML
2528 &copy; 1993, 2020, Oracle and/or its affiliates. All rights reserved.<br>
@@ -29,16 +32,59 @@ module Docs · 3 unmodified lines
2932 Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
3033 HTML
3134
35+ NEWFILTERS = ['openjdk/entries_new', 'openjdk/clean_html_new']
36+
37+ version '16' do
38+ self.release = '16'
39+ self.root_path = 'index.html'
40+
41+ html_filters.push NEWFILTERS
42+
43+ options[:container] = 'main'
44+ end
45+
46+ version '15' do
47+ self.release = '15.0.1'
48+ self.root_path = 'index.html'
49+
50+ html_filters.push NEWFILTERS
51+
52+ options[:container] = 'main'
53+ end
54+
55+ OLDFILTERS = ['openjdk/entries', 'openjdk/clean_html']
56+
57+ version '14' do
58+ self.release = '14.0.2'
59+ self.root_path = 'index.html'
60+
61+ html_filters.push OLDFILTERS
62+
63+ options[:container] = 'main'
64+ end
65+
66+ version '13' do
67+ self.release = '13.0.5'
68+ self.root_path = 'index.html'
69+
70+ html_filters.push OLDFILTERS
71+
72+ options[:container] = 'main'
73+ end
74+
3275 version '11' do
3376 self.release = '11.0.9'
3477 self.root_path = 'index.html'
3578 self.base_url = 'https://docs.oracle.com/en/java/javase/11/docs/api/'
36− options[:only_patterns] = [/\Ajava\./]
79+
80+ html_filters.push OLDFILTERS
3781 end
3882
3983 version '8' do
4084 self.release = '8'
4185
86+ html_filters.push OLDFILTERS
87+
4288 options[:only_patterns] = [
4389 /\Ajava\/beans\//,
4490 /\Ajava\/io\//,
@@ -61,20 +107,27 @@ module Docs · 16 unmodified lines
61107 /\Ajavax\/script\//,
62108 /\Ajavax\/security\//,
63109 /\Ajavax\/sound\//,
64− /\Ajavax\/tools\//]
110+ /\Ajavax\/tools\//
111+ ]
65112 end
66113
67114 version '8 GUI' do
68115 self.release = '8'
69116
117+ html_filters.push OLDFILTERS
118+
70119 options[:only_patterns] = [
71120 /\Ajava\/awt\//,
72− /\Ajavax\/swing\//]
121+ /\Ajavax\/swing\//
122+ ]
123+
73124 end
74125
75126 version '8 Web' do
76127 self.release = '8'
77128
129+ html_filters.push OLDFILTERS
130+
78131 options[:only_patterns] = [
79132 /\Ajava\/applet\//,
80133 /\Ajava\/rmi\//,