Skip to content

Commit

Permalink
Split Tensorflow into separate Python, C++ and Guide docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lgeiger committed Nov 15, 2020
1 parent d7ca038 commit c7a2a37
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/docs/filters/tensorflow/entries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def get_name
end

def get_type
if version == 'Guide' and base_url.path.start_with?('/guide')
if base_url.path.start_with?('/guide')
'Guides'
elsif version == 'Guide' and base_url.path.start_with?('/tutorials')
elsif base_url.path.start_with?('/tutorials')
'Tutorials'
elsif slug.start_with?('tf/audio')
'tf.audio'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# frozen_string_literal: true

module Docs
class Tensorflow < UrlScraper
self.name = 'TensorFlow'
self.type = 'tensorflow'
self.release = '2.1'
self.root_path = 'index.html'
self.links = {
home: 'https://www.tensorflow.org/',
Expand All @@ -22,17 +19,19 @@ class Tensorflow < UrlScraper
Code samples licensed under the Apache 2.0 License.
HTML

version 'Python' do
self.base_url = 'https://www.tensorflow.org/api_docs/python/'
version '2.1' do
self.release = '2.1.0'
self.base_url = "https://www.tensorflow.org/versions/r#{version}/api_docs/python"
end

version 'C++' do
self.base_url = 'https://www.tensorflow.org/api_docs/cc/'
version '2.0' do
self.release = '2.0.0'
self.base_url = "https://www.tensorflow.org/versions/r#{version}/api_docs/python"
end

version 'Guide' do
include MultipleBaseUrls
self.base_urls = ['https://www.tensorflow.org/guide/', 'https://www.tensorflow.org/tutorials/']
version '1.15' do
self.release = '1.15.0'
self.base_url = "https://www.tensorflow.org/versions/r#{version}/api_docs/python"
end

def get_latest_version(opts)
Expand All @@ -42,7 +41,7 @@ def get_latest_version(opts)
private

def parse(response)
unless response.url == root_url || self.class.version == 'Guide'
unless response.url == root_url
response.body.sub!(/<nav class="devsite-nav-responsive-sidebar.+?<\/nav>/m, '')
response.body.gsub!(/<li class="devsite-nav-item">.+?<\/li>/m, '')
end
Expand Down
21 changes: 21 additions & 0 deletions lib/docs/scrapers/tensorflow/tensorflow_cpp.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Docs
class TensorflowCpp < Tensorflow
self.name = 'TensorFlow C++'
self.slug = 'tensorflow_cpp'

version '2.1' do
self.release = '2.1.0'
self.base_url = "https://www.tensorflow.org/versions/r#{version}/api_docs/cc"
end

version '2.0' do
self.release = '2.0.0'
self.base_url = "https://www.tensorflow.org/versions/r#{version}/api_docs/cc"
end

version '1.15' do
self.release = '1.15.0'
self.base_url = "https://www.tensorflow.org/versions/r#{version}/api_docs/cc"
end
end
end
9 changes: 9 additions & 0 deletions lib/docs/scrapers/tensorflow/tensorflow_guide.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Docs
class TensorflowGuide < Tensorflow
include MultipleBaseUrls

self.name = 'TensorFlow Guides'
self.slug = 'tensorflow_guide'
self.base_urls = ['https://www.tensorflow.org/guide/', 'https://www.tensorflow.org/tutorials/']
end
end
Binary file added public/icons/docs/tensorflow_cpp/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/docs/tensorflow_cpp/16@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/docs/tensorflow_cpp/SOURCE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://www.tensorflow.org/images/favicon.png
Binary file added public/icons/docs/tensorflow_guide/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/docs/tensorflow_guide/16@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/docs/tensorflow_guide/SOURCE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://www.tensorflow.org/images/favicon.png

0 comments on commit c7a2a37

Please sign in to comment.