[devdocsgjs/main: 980/1867] Upgrade TensorFlow docs to v2.0




commit 02e4a384b67ca71bd669e59a4fbf41a6653540ff
Author: Lukas Geiger <lukas geiger94 gmail com>
Date:   Thu Dec 26 21:45:45 2019 +0100

    Upgrade TensorFlow docs to v2.0

 .../javascripts/templates/pages/about_tmpl.coffee  |   2 +-
 assets/stylesheets/pages/_tensorflow.scss          |   1 +
 lib/docs/filters/tensorflow/clean_html.rb          |   2 +-
 lib/docs/filters/tensorflow/entries.rb             | 115 +++++++++++++++++----
 lib/docs/scrapers/tensorflow.rb                    |  33 ++----
 public/icons/docs/tensorflow/16.png                | Bin 701 -> 599 bytes
 public/icons/docs/tensorflow/16 2x png             | Bin 898 -> 404 bytes
 7 files changed, 103 insertions(+), 50 deletions(-)
---
diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee 
b/assets/javascripts/templates/pages/about_tmpl.coffee
index 0165ade2..d0c6fdb9 100644
--- a/assets/javascripts/templates/pages/about_tmpl.coffee
+++ b/assets/javascripts/templates/pages/about_tmpl.coffee
@@ -743,7 +743,7 @@ credits = [
     'http://tcl.tk/software/tcltk/license.html'
   ], [
     'TensorFlow',
-    '2018 The TensorFlow Authors',
+    '2019 The TensorFlow Authors',
     'CC BY',
     'https://creativecommons.org/licenses/by/3.0/'
   ], [
diff --git a/assets/stylesheets/pages/_tensorflow.scss b/assets/stylesheets/pages/_tensorflow.scss
index ebd5baef..3967e9c3 100644
--- a/assets/stylesheets/pages/_tensorflow.scss
+++ b/assets/stylesheets/pages/_tensorflow.scss
@@ -4,4 +4,5 @@
   h4 { @extend %block-label; }
   h3 + h3 { margin-top: .25rem; }
   > .toc ul ul { margin: .25rem 0; }
+  table { float: inherit }
 }
diff --git a/lib/docs/filters/tensorflow/clean_html.rb b/lib/docs/filters/tensorflow/clean_html.rb
index 5829c340..cdacee5c 100644
--- a/lib/docs/filters/tensorflow/clean_html.rb
+++ b/lib/docs/filters/tensorflow/clean_html.rb
@@ -4,7 +4,7 @@ module Docs
       def call
         @doc = at_css('.devsite-article-inner')
 
-        css('hr', '.devsite-nav', '.devsite-content-footer', '.devsite-article-body > br').remove
+        css('hr', '.devsite-nav', '.devsite-content-footer', '.devsite-article-body > br', 
'.devsite-article-meta', 'devsite-nav-buttons').remove
 
         css('aside.note').each do |node|
           node.name = 'blockquote'
diff --git a/lib/docs/filters/tensorflow/entries.rb b/lib/docs/filters/tensorflow/entries.rb
index 4e2757eb..f71c6b7f 100644
--- a/lib/docs/filters/tensorflow/entries.rb
+++ b/lib/docs/filters/tensorflow/entries.rb
@@ -7,35 +7,108 @@ module Docs
         name = at_css('h1').content.strip
         name.remove! 'class '
         name.remove! 'struct '
-        name.remove! 'module: '
+        name.remove! 'Module: '
         name.remove! %r{ \(.+\)}
         name.sub! %r{(?<!\ )\(.+\)}, '()'
         name.remove! %r{\.\z}
-        name.sub! 'tf.contrib', 'contrib' unless version == 'Guide'
         name
       end
 
-      TYPE_BY_DIR = {
-        'get_started' => 'Get Started',
-        'programmers_guide' => 'Guide',
-        'tutorials' => 'Tutorials',
-        'performance' => 'Performance',
-        'deploy' => 'Deploy',
-        'extend' => 'Extend'
-      }
-
       def get_type
-        return 'Guides' if base_url.path.start_with?('/api_guides')
-
-        if version == 'Guide'
-          TYPE_BY_DIR[subpath.split('/').first]
+        if version == 'Guide' and base_url.path.start_with?('/guide')
+          'Guides'
+        elsif version == 'Guide' and base_url.path.start_with?('/tutorials')
+          'Tutorials'
+        elsif slug.start_with?('tf/audio')
+          'tf.audio'
+        elsif slug.start_with?('tf/autograph')
+          'tf.autograph'
+        elsif slug.start_with?('tf/bitwise')
+          'tf.bitwise'
+        elsif slug.start_with?('tf/compat')
+          'tf.compat'
+        elsif slug.start_with?('tf/config')
+          'tf.config'
+        elsif slug.start_with?('tf/data')
+          'tf.data'
+        elsif slug.start_with?('tf/debugging')
+          'tf.debugging'
+        elsif slug.start_with?('tf/distribute')
+          'tf.distribute'
+        elsif slug.start_with?('tf/dtypes')
+          'tf.dtypes'
+        elsif slug.start_with?('tf/errors')
+          'tf.errors'
+        elsif slug.start_with?('tf/estimator')
+          'tf.estimator'
+        elsif slug.start_with?('tf/experimental')
+          'tf.experimental'
+        elsif slug.start_with?('tf/feature_column')
+          'tf.feature_column'
+        elsif slug.start_with?('tf/graph_util')
+          'tf.graph_util'
+        elsif slug.start_with?('tf/image')
+          'tf.image'
+        elsif slug.start_with?('tf/initializers')
+          'tf.initializers'
+        elsif slug.start_with?('tf/io')
+          'tf.io'
+        elsif slug.start_with?('tf/keras')
+          'tf.keras'
+        elsif slug.start_with?('tf/linalg')
+          'tf.linalg'
+        elsif slug.start_with?('tf/lite')
+          'tf.lite'
+        elsif slug.start_with?('tf/lookup')
+          'tf.lookup'
+        elsif slug.start_with?('tf/losses')
+          'tf.losses'
+        elsif slug.start_with?('tf/math')
+          'tf.math'
+        elsif slug.start_with?('tf/metrics')
+          'tf.metrics'
+        elsif slug.start_with?('tf/nest')
+          'tf.nest'
+        elsif slug.start_with?('tf/nn')
+          'tf.nn'
+        elsif slug.start_with?('tf/optimizers')
+          'tf.optimizers'
+        elsif slug.start_with?('tf/quantization')
+          'tf.quantization'
+        elsif slug.start_with?('tf/queue')
+          'tf.queue'
+        elsif slug.start_with?('tf/ragged')
+          'tf.ragged'
+        elsif slug.start_with?('tf/random')
+          'tf.random'
+        elsif slug.start_with?('tf/raw_ops')
+          'tf.raw_ops'
+        elsif slug.start_with?('tf/saved_model')
+          'tf.saved_model'
+        elsif slug.start_with?('tf/sets')
+          'tf.sets'
+        elsif slug.start_with?('tf/signal')
+          'tf.signal'
+        elsif slug.start_with?('tf/sparse')
+          'tf.sparse'
+        elsif slug.start_with?('tf/strings')
+          'tf.strings'
+        elsif slug.start_with?('tf/summary')
+          'tf.summary'
+        elsif slug.start_with?('tf/sysconfig')
+          'tf.sysconfig'
+        elsif slug.start_with?('tf/test')
+          'tf.test'
+        elsif slug.start_with?('tf/tpu')
+          'tf.tpu'
+        elsif slug.start_with?('tf/train')
+          'tf.train'
+        elsif slug.start_with?('tf/version')
+          'tf.version'
+        elsif slug.start_with?('tf/xla')
+          'tf.xla'
         else
-          node = at_css('.devsite-nav-item.devsite-nav-active')
-          node = node.ancestors('.devsite-nav-item').first.at_css('.devsite-nav-title')
-          type = node.content
-          type.remove! %r{\.\z}
-          type = 'tf.contrib' if type.start_with?('tf.contrib')
-          type
+          'tf'
         end
       end
     end
diff --git a/lib/docs/scrapers/tensorflow.rb b/lib/docs/scrapers/tensorflow.rb
index 9638b516..d352ccd4 100644
--- a/lib/docs/scrapers/tensorflow.rb
+++ b/lib/docs/scrapers/tensorflow.rb
@@ -4,7 +4,7 @@ module Docs
   class Tensorflow < UrlScraper
     self.name = 'TensorFlow'
     self.type = 'tensorflow'
-    self.release = '1.8'
+    self.release = '2.0'
     self.root_path = 'index.html'
     self.links = {
       home: 'https://www.tensorflow.org/',
@@ -16,44 +16,23 @@ module Docs
     options[:max_image_size] = 300_000
     options[:container] = '.devsite-main-content'
 
-    options[:fix_urls] = ->(url) do
-      url.sub! 'how_tos/../tutorials', 'tutorials'
-      url
-    end
-
     options[:attribution] = <<-HTML
-      &copy; 2018 The TensorFlow Authors. All rights reserved.<br>
+      &copy; 2019 The TensorFlow Authors. All rights reserved.<br>
       Licensed under the Creative Commons Attribution License 3.0.<br>
       Code samples licensed under the Apache 2.0 License.
     HTML
 
     version 'Python' do
-      include MultipleBaseUrls
-      self.base_urls = ['https://www.tensorflow.org/api_docs/python/', 
'https://www.tensorflow.org/api_guides/python/']
+      self.base_url = 'https://www.tensorflow.org/api_docs/python/'
     end
 
     version 'C++' do
-      include MultipleBaseUrls
-      self.base_urls = ['https://www.tensorflow.org/api_docs/cc/', 
'https://www.tensorflow.org/api_guides/cc/']
+      self.base_url = 'https://www.tensorflow.org/api_docs/cc/'
     end
 
     version 'Guide' do
-      self.base_url = 'https://www.tensorflow.org/'
-      self.root_path = 'get_started/get_started'
-      self.initial_paths = %w(
-        programmers_guide/reading_data
-        tutorials/mandelbrot
-        performance/performance_guide
-        deploy/hadoop
-        extend/architecture)
-
-      options[:only_patterns] = [
-        /\Aget_started/,
-        /\Aprogrammers_guide/,
-        /\Atutorials/,
-        /\Aperformance/,
-        /\Adeploy/,
-        /\Aextend/]
+      include MultipleBaseUrls
+      self.base_urls = ['https://www.tensorflow.org/guide/', 'https://www.tensorflow.org/tutorials/']
     end
 
     def get_latest_version(opts)
diff --git a/public/icons/docs/tensorflow/16.png b/public/icons/docs/tensorflow/16.png
index 07f894e5..8463d569 100644
Binary files a/public/icons/docs/tensorflow/16.png and b/public/icons/docs/tensorflow/16.png differ
diff --git a/public/icons/docs/tensorflow/16 2x png b/public/icons/docs/tensorflow/16 2x png
index 94eebc91..00a8af6d 100644
Binary files a/public/icons/docs/tensorflow/16 2x png and b/public/icons/docs/tensorflow/16 2x png differ


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]