1
0

cordova.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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://git-wip-us.apache.org/repos/asf/cordova-cli.git'
  9. }
  10. html_filters.push 'cordova/entries', 'cordova/clean_html'
  11. options[:container] = '.docs'
  12. options[:skip] = %w(index.html)
  13. options[:fix_urls] = ->(url) do
  14. if url.include?('https://cordova.apache.org/docs') && !url.end_with?('.html')
  15. if url.end_with?('/')
  16. url << 'index.html'
  17. else
  18. url << '/index.html'
  19. end
  20. end
  21. end
  22. options[:attribution] = <<-HTML
  23. &copy; 2012&ndash;2018 The Apache Software Foundation<br>
  24. Licensed under the Apache License 2.0.
  25. HTML
  26. version '8' do
  27. self.release = '8.1.2'
  28. self.base_url = 'https://cordova.apache.org/docs/en/8.x/'
  29. end
  30. version '7' do
  31. self.release = '7.1.0'
  32. self.base_url = 'https://cordova.apache.org/docs/en/7.x/'
  33. end
  34. version '6' do
  35. self.release = '6.5.0'
  36. self.base_url = 'https://cordova.apache.org/docs/en/6.x/'
  37. end
  38. def get_latest_version(opts)
  39. doc = fetch_doc('https://cordova.apache.org/docs/en/latest/', opts)
  40. label = doc.at_css('#versionDropdown').content.strip
  41. version = label.scan(/([0-9.]+)/)[0][0]
  42. version = version[0...-1] if version.end_with?('.')
  43. version
  44. end
  45. end
  46. end