dart.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. module Docs
  2. class Dart < FileScraper
  3. self.type = 'dart'
  4. self.root_path = 'index.html'
  5. self.links = {
  6. home: 'https://www.dartlang.org/',
  7. code: 'https://github.com/dart-lang/sdk'
  8. }
  9. html_filters.push 'dart/entries', 'dart/clean_html'
  10. options[:fix_urls] = ->(url) do
  11. # localhost/dart-web_audio/..dart-io/dart-io-library.html > localhost/dart-io/dart-io-library.html
  12. url.remove!(/[^\/]+\/\.\./)
  13. url
  14. end
  15. options[:attribution] = <<-HTML
  16. &copy; 2012 the Dart project authors<br>
  17. Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
  18. HTML
  19. # Download the documentation from https://www.dartlang.org/tools/sdk/archive
  20. version '2' do
  21. self.release = '2.0.0'
  22. self.base_url = "https://api.dartlang.org/stable/#{release}/"
  23. end
  24. version '1' do
  25. self.release = '1.24.3'
  26. self.base_url = "https://api.dartlang.org/stable/#{release}/"
  27. end
  28. def get_latest_version(opts)
  29. doc = fetch_doc('https://api.dartlang.org/', opts)
  30. label = doc.at_css('footer > span').content.strip
  31. label.sub(/Dart /, '')
  32. end
  33. end
  34. end