Skip to content

Commit c824912

Browse files
committed
Merge pull request freeCodeCamp#1144 from lgeiger/upgrade-tensorflow
Upgrade TensorFlow 2.1
2 parents 2a95294 + b63a796 commit c824912

File tree

7 files changed

+103
-50
lines changed

7 files changed

+103
-50
lines changed

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ credits = [
748748
'http://tcl.tk/software/tcltk/license.html'
749749
], [
750750
'TensorFlow',
751-
'2018 The TensorFlow Authors',
751+
'2019 The TensorFlow Authors',
752752
'CC BY',
753753
'https://creativecommons.org/licenses/by/3.0/'
754754
], [

assets/stylesheets/pages/_tensorflow.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
h4 { @extend %block-label; }
55
h3 + h3 { margin-top: .25rem; }
66
> .toc ul ul { margin: .25rem 0; }
7+
table { float: inherit }
78
}

lib/docs/filters/tensorflow/clean_html.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class CleanHtmlFilter < Filter
44
def call
55
@doc = at_css('.devsite-article-inner')
66

7-
css('hr', '.devsite-nav', '.devsite-content-footer', '.devsite-article-body > br').remove
7+
css('hr', '.devsite-nav', '.devsite-content-footer', '.devsite-article-body > br', '.devsite-article-meta', 'devsite-nav-buttons').remove
88

99
css('aside.note').each do |node|
1010
node.name = 'blockquote'

lib/docs/filters/tensorflow/entries.rb

Lines changed: 94 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,108 @@ def get_name
77
name = at_css('h1').content.strip
88
name.remove! 'class '
99
name.remove! 'struct '
10-
name.remove! 'module: '
10+
name.remove! 'Module: '
1111
name.remove! %r{ \(.+\)}
1212
name.sub! %r{(?<!\ )\(.+\)}, '()'
1313
name.remove! %r{\.\z}
14-
name.sub! 'tf.contrib', 'contrib' unless version == 'Guide'
1514
name
1615
end
1716

18-
TYPE_BY_DIR = {
19-
'get_started' => 'Get Started',
20-
'programmers_guide' => 'Guide',
21-
'tutorials' => 'Tutorials',
22-
'performance' => 'Performance',
23-
'deploy' => 'Deploy',
24-
'extend' => 'Extend'
25-
}
26-
2717
def get_type
28-
return 'Guides' if base_url.path.start_with?('/api_guides')
29-
30-
if version == 'Guide'
31-
TYPE_BY_DIR[subpath.split('/').first]
18+
if version == 'Guide' and base_url.path.start_with?('/guide')
19+
'Guides'
20+
elsif version == 'Guide' and base_url.path.start_with?('/tutorials')
21+
'Tutorials'
22+
elsif slug.start_with?('tf/audio')
23+
'tf.audio'
24+
elsif slug.start_with?('tf/autograph')
25+
'tf.autograph'
26+
elsif slug.start_with?('tf/bitwise')
27+
'tf.bitwise'
28+
elsif slug.start_with?('tf/compat')
29+
'tf.compat'
30+
elsif slug.start_with?('tf/config')
31+
'tf.config'
32+
elsif slug.start_with?('tf/data')
33+
'tf.data'
34+
elsif slug.start_with?('tf/debugging')
35+
'tf.debugging'
36+
elsif slug.start_with?('tf/distribute')
37+
'tf.distribute'
38+
elsif slug.start_with?('tf/dtypes')
39+
'tf.dtypes'
40+
elsif slug.start_with?('tf/errors')
41+
'tf.errors'
42+
elsif slug.start_with?('tf/estimator')
43+
'tf.estimator'
44+
elsif slug.start_with?('tf/experimental')
45+
'tf.experimental'
46+
elsif slug.start_with?('tf/feature_column')
47+
'tf.feature_column'
48+
elsif slug.start_with?('tf/graph_util')
49+
'tf.graph_util'
50+
elsif slug.start_with?('tf/image')
51+
'tf.image'
52+
elsif slug.start_with?('tf/initializers')
53+
'tf.initializers'
54+
elsif slug.start_with?('tf/io')
55+
'tf.io'
56+
elsif slug.start_with?('tf/keras')
57+
'tf.keras'
58+
elsif slug.start_with?('tf/linalg')
59+
'tf.linalg'
60+
elsif slug.start_with?('tf/lite')
61+
'tf.lite'
62+
elsif slug.start_with?('tf/lookup')
63+
'tf.lookup'
64+
elsif slug.start_with?('tf/losses')
65+
'tf.losses'
66+
elsif slug.start_with?('tf/math')
67+
'tf.math'
68+
elsif slug.start_with?('tf/metrics')
69+
'tf.metrics'
70+
elsif slug.start_with?('tf/nest')
71+
'tf.nest'
72+
elsif slug.start_with?('tf/nn')
73+
'tf.nn'
74+
elsif slug.start_with?('tf/optimizers')
75+
'tf.optimizers'
76+
elsif slug.start_with?('tf/quantization')
77+
'tf.quantization'
78+
elsif slug.start_with?('tf/queue')
79+
'tf.queue'
80+
elsif slug.start_with?('tf/ragged')
81+
'tf.ragged'
82+
elsif slug.start_with?('tf/random')
83+
'tf.random'
84+
elsif slug.start_with?('tf/raw_ops')
85+
'tf.raw_ops'
86+
elsif slug.start_with?('tf/saved_model')
87+
'tf.saved_model'
88+
elsif slug.start_with?('tf/sets')
89+
'tf.sets'
90+
elsif slug.start_with?('tf/signal')
91+
'tf.signal'
92+
elsif slug.start_with?('tf/sparse')
93+
'tf.sparse'
94+
elsif slug.start_with?('tf/strings')
95+
'tf.strings'
96+
elsif slug.start_with?('tf/summary')
97+
'tf.summary'
98+
elsif slug.start_with?('tf/sysconfig')
99+
'tf.sysconfig'
100+
elsif slug.start_with?('tf/test')
101+
'tf.test'
102+
elsif slug.start_with?('tf/tpu')
103+
'tf.tpu'
104+
elsif slug.start_with?('tf/train')
105+
'tf.train'
106+
elsif slug.start_with?('tf/version')
107+
'tf.version'
108+
elsif slug.start_with?('tf/xla')
109+
'tf.xla'
32110
else
33-
node = at_css('.devsite-nav-item.devsite-nav-active')
34-
node = node.ancestors('.devsite-nav-item').first.at_css('.devsite-nav-title')
35-
type = node.content
36-
type.remove! %r{\.\z}
37-
type = 'tf.contrib' if type.start_with?('tf.contrib')
38-
type
111+
'tf'
39112
end
40113
end
41114
end

lib/docs/scrapers/tensorflow.rb

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Docs
44
class Tensorflow < UrlScraper
55
self.name = 'TensorFlow'
66
self.type = 'tensorflow'
7-
self.release = '1.8'
7+
self.release = '2.1'
88
self.root_path = 'index.html'
99
self.links = {
1010
home: 'https://www.tensorflow.org/',
@@ -16,44 +16,23 @@ class Tensorflow < UrlScraper
1616
options[:max_image_size] = 300_000
1717
options[:container] = '.devsite-main-content'
1818

19-
options[:fix_urls] = ->(url) do
20-
url.sub! 'how_tos/../tutorials', 'tutorials'
21-
url
22-
end
23-
2419
options[:attribution] = <<-HTML
25-
&copy; 2018 The TensorFlow Authors. All rights reserved.<br>
20+
&copy; 2019 The TensorFlow Authors. All rights reserved.<br>
2621
Licensed under the Creative Commons Attribution License 3.0.<br>
2722
Code samples licensed under the Apache 2.0 License.
2823
HTML
2924

3025
version 'Python' do
31-
include MultipleBaseUrls
32-
self.base_urls = ['https://www.tensorflow.org/api_docs/python/', 'https://www.tensorflow.org/api_guides/python/']
26+
self.base_url = 'https://www.tensorflow.org/api_docs/python/'
3327
end
3428

3529
version 'C++' do
36-
include MultipleBaseUrls
37-
self.base_urls = ['https://www.tensorflow.org/api_docs/cc/', 'https://www.tensorflow.org/api_guides/cc/']
30+
self.base_url = 'https://www.tensorflow.org/api_docs/cc/'
3831
end
3932

4033
version 'Guide' do
41-
self.base_url = 'https://www.tensorflow.org/'
42-
self.root_path = 'get_started/get_started'
43-
self.initial_paths = %w(
44-
programmers_guide/reading_data
45-
tutorials/mandelbrot
46-
performance/performance_guide
47-
deploy/hadoop
48-
extend/architecture)
49-
50-
options[:only_patterns] = [
51-
/\Aget_started/,
52-
/\Aprogrammers_guide/,
53-
/\Atutorials/,
54-
/\Aperformance/,
55-
/\Adeploy/,
56-
/\Aextend/]
34+
include MultipleBaseUrls
35+
self.base_urls = ['https://www.tensorflow.org/guide/', 'https://www.tensorflow.org/tutorials/']
5736
end
5837

5938
def get_latest_version(opts)
-102 Bytes
Loading
-494 Bytes
Loading

0 commit comments

Comments
 (0)