tensorflow.rb 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # frozen_string_literal: true
  2. module Docs
  3. class Tensorflow < UrlScraper
  4. self.name = 'TensorFlow'
  5. self.type = 'tensorflow'
  6. self.release = '1.8'
  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[:fix_urls] = ->(url) do
  16. url.sub! 'how_tos/../tutorials', 'tutorials'
  17. url
  18. end
  19. options[:attribution] = <<-HTML
  20. &copy; 2018 The TensorFlow Authors. All rights reserved.<br>
  21. Licensed under the Creative Commons Attribution License 3.0.<br>
  22. Code samples licensed under the Apache 2.0 License.
  23. HTML
  24. version 'Python' do
  25. include MultipleBaseUrls
  26. self.base_urls = ['https://www.tensorflow.org/api_docs/python/', 'https://www.tensorflow.org/api_guides/python/']
  27. end
  28. version 'C++' do
  29. include MultipleBaseUrls
  30. self.base_urls = ['https://www.tensorflow.org/api_docs/cc/', 'https://www.tensorflow.org/api_guides/cc/']
  31. end
  32. version 'Guide' do
  33. self.base_url = 'https://www.tensorflow.org/'
  34. self.root_path = 'get_started/get_started'
  35. self.initial_paths = %w(
  36. programmers_guide/reading_data
  37. tutorials/mandelbrot
  38. performance/performance_guide
  39. deploy/hadoop
  40. extend/architecture)
  41. options[:only_patterns] = [
  42. /\Aget_started/,
  43. /\Aprogrammers_guide/,
  44. /\Atutorials/,
  45. /\Aperformance/,
  46. /\Adeploy/,
  47. /\Aextend/]
  48. end
  49. def get_latest_version(opts)
  50. get_latest_github_release('tensorflow', 'tensorflow', opts)
  51. end
  52. private
  53. def parse(response)
  54. unless response.url == root_url || self.class.version == 'Guide'
  55. response.body.sub!(/<nav class="devsite-nav-responsive-sidebar.+?<\/nav>/m, '')
  56. response.body.gsub!(/<li class="devsite-nav-item">.+?<\/li>/m, '')
  57. end
  58. super
  59. end
  60. end
  61. end