tensorflow.rb 1.5 KB

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