cordova.rb 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. module Docs
  2. class Cordova < UrlScraper
  3. self.name = 'Cordova'
  4. self.type = 'cordova'
  5. self.root_path = 'guide/overview/index.html'
  6. self.links = {
  7. home: 'https://cordova.apache.org/',
  8. code: 'https://github.com/apache/cordova'
  9. }
  10. html_filters.replace 'clean_html', 'cordova/clean_html_core'
  11. html_filters.push 'cordova/entries', 'cordova/clean_html'
  12. options[:container] = '.docs'
  13. options[:skip] = %w(index.html)
  14. options[:fix_urls] = ->(url) do
  15. if url.include?('https://cordova.apache.org/docs') && !url.end_with?('.html')
  16. if url.end_with?('/')
  17. url << 'index.html'
  18. else
  19. url << '/index.html'
  20. end
  21. end
  22. end
  23. options[:attribution] = <<-HTML
  24. &copy; 2012, 2013, 2015 The Apache Software Foundation<br>
  25. Licensed under the Apache License 2.0.
  26. HTML
  27. version '9' do
  28. self.release = '9.0.0'
  29. self.base_url = "https://cordova.apache.org/docs/en/#{self.version}.x/"
  30. end
  31. version '8' do
  32. self.release = '8.1.2'
  33. self.base_url = "https://cordova.apache.org/docs/en/#{self.version}.x/"
  34. end
  35. version '7' do
  36. self.release = '7.1.0'
  37. self.base_url = "https://cordova.apache.org/docs/en/#{self.version}.x/"
  38. end
  39. version '6' do
  40. self.release = '6.5.0'
  41. self.base_url = "https://cordova.apache.org/docs/en/#{self.version}.x/"
  42. end
  43. def get_latest_version(opts)
  44. doc = fetch_doc('https://cordova.apache.org/docs/en/latest/', opts)
  45. label = doc.at_css('#versionDropdown').content.strip
  46. version = label.scan(/([0-9.]+)/)[0][0]
  47. version = version[0...-1] if version.end_with?('.')
  48. version
  49. end
  50. end
  51. end