Update TensorFlow documentation (1.0)

pull/570/merge
Thibaut Courouble 8 years ago
parent 8ddb812035
commit 15fdab9a49

@ -561,7 +561,7 @@ credits = [
'http://tcl.tk/software/tcltk/license.html' 'http://tcl.tk/software/tcltk/license.html'
], [ ], [
'TensorFlow', 'TensorFlow',
'2015 The TensorFlow Authors', '2017 The TensorFlow Authors',
'CC BY', 'CC BY',
'https://creativecommons.org/licenses/by/3.0/' 'https://creativecommons.org/licenses/by/3.0/'
], [ ], [

@ -2,5 +2,6 @@
@extend %simple; @extend %simple;
h4 { @extend %block-label; } h4 { @extend %block-label; }
h3 + h3 { margin-top: .25rem; }
> .toc ul ul { margin: .25rem 0; } > .toc ul ul { margin: .25rem 0; }
} }

@ -21,6 +21,10 @@ module Docs
node.parent.before(node).remove node.parent.before(node).remove
end end
css('aside.note').each do |node|
node.name = 'blockquote'
end
css('pre').each do |node| css('pre').each do |node|
node.content = node.content.strip_heredoc node.content = node.content.strip_heredoc

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Docs module Docs
class Tensorflow class Tensorflow
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
@ -5,58 +7,37 @@ module Docs
name = at_css('h1').content.strip name = at_css('h1').content.strip
name.remove! 'class ' name.remove! 'class '
name.remove! 'struct ' name.remove! 'struct '
name.remove! 'module: '
name.remove! %r{ \(.+\)}
name.sub! %r{(?<!\ )\(.+\)}, '()'
name.remove! %r{\.\z} name.remove! %r{\.\z}
name.sub! 'tf.contrib', 'contrib' unless version == 'Guide' name.sub! 'tf.contrib', 'contrib' unless version == 'Guide'
name name
end end
def get_type TYPE_BY_DIR = {
if version == 'Guide' 'get_started' => 'Get Started',
type = subpath.start_with?('tutorials') ? 'Tutorials' : 'How-Tos' 'programmers_guide' => 'Guide',
'tutorials' => 'Tutorials',
'performance' => 'Performance',
'deploy' => 'Deploy',
'extend' => 'Extend'
}
if node = at_css('.devsite-nav-item.devsite-nav-active') def get_type
node = node.previous_element until !node || node['class'].include?('devsite-nav-item-heading') return 'Guides' if base_url.path.start_with?('/api_guides')
type << ": #{node.content}" if node
end
type if version == 'Guide'
elsif version == 'C++' TYPE_BY_DIR[subpath.split('/').first]
name.remove 'tensorflow::'
else else
node = at_css('.devsite-nav-item.devsite-nav-active') node = at_css('.devsite-nav-item.devsite-nav-active')
node = node.ancestors('.devsite-nav-item').first.at_css('.devsite-nav-title') node = node.ancestors('.devsite-nav-item').first.at_css('.devsite-nav-title')
type = node.content type = node.content
type.remove! %r{\.\z} type.remove! %r{\.\z}
type.prepend 'Contrib: ' if type.sub!(' (contrib)', '') type = 'tf.contrib' if type.start_with?('tf.contrib')
type type
end end
end end
def additional_entries
return [] if version == 'Guide'
if version == 'C++'
names = Set.new
css('table.constructors td:first-child code a:first-child',
'table.methods td:first-child code a:first-child',
'table.properties td:first-child code a:first-child').each_with_object [] do |node, entries|
name = node.content
name.prepend "#{self.name}::"
name << '()' unless node.ancestors('.properties').present?
next unless names.add?(name)
id = node['href'].remove('#')
entries << [name, id]
end
else
css('h2 code', 'h3 code', 'h4 code', 'h5 code').each_with_object [] do |node, entries|
name = node.content
name.sub! %r{\(.*}, '()'
next if name.include?(' || ')
name = name.split(' ').last
entries << [name, node.parent['id']]
end
end
end
end end
end end
end end

@ -1,9 +1,11 @@
# frozen_string_literal: true
module Docs module Docs
class Tensorflow < UrlScraper class Tensorflow < UrlScraper
self.name = 'TensorFlow' self.name = 'TensorFlow'
self.type = 'tensorflow' self.type = 'tensorflow'
self.release = '1.0'
self.root_path = 'index.html' self.root_path = 'index.html'
self.force_gzip = true
self.links = { self.links = {
home: 'https://www.tensorflow.org/', home: 'https://www.tensorflow.org/',
code: 'https://github.com/tensorflow/tensorflow' code: 'https://github.com/tensorflow/tensorflow'
@ -19,28 +21,49 @@ module Docs
end end
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
&copy; 2015 The TensorFlow Authors. All rights reserved.<br> &copy; 2017 The TensorFlow Authors. All rights reserved.<br>
Licensed under the Creative Commons Attribution License 3.0.<br> Licensed under the Creative Commons Attribution License 3.0.<br>
Code samples licensed under the Apache 2.0 License. Code samples licensed under the Apache 2.0 License.
HTML HTML
version 'Python' do version 'Python' do
self.base_url = 'https://www.tensorflow.org/api_docs/python/' include MultipleBaseUrls
self.release = '0.12' self.base_urls = ['https://www.tensorflow.org/api_docs/python/', 'https://www.tensorflow.org/api_guides/python/']
end end
version 'C++' do version 'C++' do
self.base_url = 'https://www.tensorflow.org/api_docs/cc/' include MultipleBaseUrls
self.release = '0.12' self.base_urls = ['https://www.tensorflow.org/api_docs/cc/', 'https://www.tensorflow.org/api_guides/cc/']
end end
version 'Guide' do version 'Guide' do
self.base_url = 'https://www.tensorflow.org/' self.base_url = 'https://www.tensorflow.org/'
self.release = '0.12' self.root_path = 'get_started/get_started'
self.root_path = 'tutorials/' self.initial_paths = %w(
self.initial_paths = %w(how_tos/) programmers_guide/reading_data
tutorials/mandelbrot
performance/performance_guide
deploy/hadoop
extend/architecture)
options[:only_patterns] = [
/\Aget_started/,
/\Aprogrammers_guide/,
/\Atutorials/,
/\Aperformance/,
/\Adeploy/,
/\Aextend/]
end
private
def parse(response)
unless response.url == root_url || self.class.version == 'Guide'
response.body.sub!(/<nav class="devsite-nav-responsive-sidebar.+?<\/nav>/m, '')
response.body.gsub!(/<li class="devsite-nav-item">.+?<\/li>/m, '')
end
options[:only_patterns] = [/\Atutorials/, /\Ahow_tos/] super
end end
end end
end end

Loading…
Cancel
Save