tensorflow.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. module Docs
  2. class Tensorflow < UrlScraper
  3. self.name = 'TensorFlow'
  4. self.type = 'tensorflow'
  5. self.root_path = 'all_symbols'
  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. for version in ['2.3', '2.2', '2.1', '2.0', '1.15'] do
  19. self.release = version + '.0'
  20. self.base_url = "https://www.tensorflow.org/versions/r#{version}/api_docs/python/tf"
  21. end
  22. def get_latest_version(opts)
  23. get_latest_github_release('tensorflow', 'tensorflow', opts)
  24. end
  25. private
  26. def parse(response)
  27. unless response.url == root_url
  28. response.body.sub!(/<nav class="devsite-nav-responsive-sidebar.+?<\/nav>/m, '')
  29. response.body.gsub!(/<li class="devsite-nav-item">.+?<\/li>/m, '')
  30. end
  31. super
  32. end
  33. end
  34. end