openjdk.rb 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. module Docs
  2. class Openjdk < FileScraper
  3. self.name = 'OpenJDK'
  4. self.type = 'openjdk'
  5. self.root_path = 'overview-summary.html'
  6. self.links = {
  7. home: 'https://openjdk.java.net/',
  8. code: 'https://github.com/openjdk/jdk'
  9. }
  10. html_filters.insert_after 'internal_urls', 'openjdk/clean_urls'
  11. options[:skip_patterns] = [
  12. /compact[123]-/,
  13. /package-frame\.html/,
  14. /package-tree\.html/,
  15. /package-use\.html/,
  16. /class-use\//,
  17. /doc-files\//,
  18. /\.svg/,
  19. /\.png/
  20. ]
  21. options[:only_patterns] = [/\Ajava\./]
  22. options[:attribution] = <<-HTML
  23. &copy; 1993, 2020, Oracle and/or its affiliates. All rights reserved.<br>
  24. Documentation extracted from Debian's OpenJDK Development Kit package.<br>
  25. Licensed under the GNU General Public License, version 2, with the Classpath Exception.<br>
  26. Various third party code in OpenJDK is licensed under different licenses (see Debian package).<br>
  27. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  28. HTML
  29. NEWFILTERS = ['openjdk/entries_new', 'openjdk/clean_html_new']
  30. version '16' do
  31. self.release = '16'
  32. self.root_path = 'index.html'
  33. html_filters.push NEWFILTERS
  34. options[:container] = 'main'
  35. end
  36. version '15' do
  37. self.release = '15.0.1'
  38. self.root_path = 'index.html'
  39. html_filters.push NEWFILTERS
  40. options[:container] = 'main'
  41. end
  42. OLDFILTERS = ['openjdk/entries', 'openjdk/clean_html']
  43. version '14' do
  44. self.release = '14.0.2'
  45. self.root_path = 'index.html'
  46. html_filters.push OLDFILTERS
  47. options[:container] = 'main'
  48. end
  49. version '13' do
  50. self.release = '13.0.5'
  51. self.root_path = 'index.html'
  52. html_filters.push OLDFILTERS
  53. options[:container] = 'main'
  54. end
  55. version '11' do
  56. self.release = '11.0.9'
  57. self.root_path = 'index.html'
  58. self.base_url = 'https://docs.oracle.com/en/java/javase/11/docs/api/'
  59. html_filters.push OLDFILTERS
  60. end
  61. version '8' do
  62. self.release = '8'
  63. html_filters.push OLDFILTERS
  64. options[:only_patterns] = [
  65. /\Ajava\/beans\//,
  66. /\Ajava\/io\//,
  67. /\Ajava\/lang\//,
  68. /\Ajava\/math\//,
  69. /\Ajava\/net\//,
  70. /\Ajava\/nio\//,
  71. /\Ajava\/security\//,
  72. /\Ajava\/text\//,
  73. /\Ajava\/time\//,
  74. /\Ajava\/util\//,
  75. /\Ajavax\/annotation\//,
  76. /\Ajavax\/crypto\//,
  77. /\Ajavax\/imageio\//,
  78. /\Ajavax\/lang\//,
  79. /\Ajavax\/management\//,
  80. /\Ajavax\/naming\//,
  81. /\Ajavax\/net\//,
  82. /\Ajavax\/print\//,
  83. /\Ajavax\/script\//,
  84. /\Ajavax\/security\//,
  85. /\Ajavax\/sound\//,
  86. /\Ajavax\/tools\//
  87. ]
  88. end
  89. version '8 GUI' do
  90. self.release = '8'
  91. html_filters.push OLDFILTERS
  92. options[:only_patterns] = [
  93. /\Ajava\/awt\//,
  94. /\Ajavax\/swing\//
  95. ]
  96. end
  97. version '8 Web' do
  98. self.release = '8'
  99. html_filters.push OLDFILTERS
  100. options[:only_patterns] = [
  101. /\Ajava\/applet\//,
  102. /\Ajava\/rmi\//,
  103. /\Ajava\/sql\//,
  104. /\Ajavax\/accessibility\//,
  105. /\Ajavax\/activation\//,
  106. /\Ajavax\/activity\//,
  107. /\Ajavax\/jws\//,
  108. /\Ajavax\/rmi\//,
  109. /\Ajavax\/sql\//,
  110. /\Ajavax\/transaction\//,
  111. /\Ajavax\/xml\//,
  112. /\Aorg\/ietf\//,
  113. /\Aorg\/omg\//,
  114. /\Aorg\/w3c\//,
  115. /\Aorg\/xml\//]
  116. end
  117. # Monkey patch to properly read HTML files encoded in ISO-8859-1
  118. def read_file(path)
  119. File.read(path).force_encoding('iso-8859-1').encode('utf-8') rescue nil
  120. end
  121. def get_latest_version(opts)
  122. latest_version = 8
  123. current_attempt = latest_version
  124. attempts = 0
  125. while attempts < 3
  126. current_attempt += 1
  127. doc = fetch_doc("https://packages.debian.org/sid/openjdk-#{current_attempt}-doc", opts)
  128. if doc.at_css('.perror').nil?
  129. latest_version = current_attempt
  130. attempts = 0
  131. else
  132. attempts += 1
  133. end
  134. end
  135. latest_version
  136. end
  137. end
  138. end