tensorflow.rb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. module Docs
  2. class Tensorflow < UrlScraper
  3. self.name = 'TensorFlow'
  4. self.type = 'tensorflow'
  5. self.root_path = '/'
  6. self.links = {
  7. home: 'https://www.tensorflow.org/',
  8. code: 'https://github.com/tensorflow/tensorflow'
  9. }
  10. html_filters.push 'tensorflow/entries', 'tensorflow/clean_html'
  11. options[:max_image_size] = 300_000
  12. options[:container] = '.devsite-main-content'
  13. options[:attribution] = <<-HTML
  14. &copy; 2020 The TensorFlow Authors. All rights reserved.<br>
  15. Licensed under the Creative Commons Attribution License 3.0.<br>
  16. Code samples licensed under the Apache 2.0 License.
  17. HTML
  18. version '2.3' do
  19. self.release = "#{version}.0"
  20. self.base_url = "https://www.tensorflow.org/versions/r#{version}/api_docs/python/tf"
  21. end
  22. version '1.15' do
  23. self.release = "#{version}.0"
  24. self.base_url = "https://www.tensorflow.org/versions/r#{version}/api_docs/python/tf"
  25. end
  26. def get_latest_version(opts)
  27. get_latest_github_release('tensorflow', 'tensorflow', opts)
  28. end
  29. private
  30. def parse(response)
  31. unless response.url == root_url
  32. response.body.sub!(/<nav class="devsite-nav-responsive-sidebar.+?<\/nav>/m, '')
  33. response.body.gsub!(/<li class="devsite-nav-item">.+?<\/li>/m, '')
  34. end
  35. super
  36. end
  37. end
  38. end