Upgrade TensorFlow docs to v2.0

This commit is contained in:
Lukas Geiger 2019-12-26 21:45:45 +01:00
parent 58c44bf332
commit 02e4a384b6
7 changed files with 103 additions and 50 deletions

View file

@ -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/'
], [

View file

@ -4,4 +4,5 @@
h4 { @extend %block-label; }
h3 + h3 { margin-top: .25rem; }
> .toc ul ul { margin: .25rem 0; }
table { float: inherit }
}

View file

@ -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'

View file

@ -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

View file

@ -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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 898 B

After

Width:  |  Height:  |  Size: 404 B