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'
], [
'TensorFlow',
'2015 The TensorFlow Authors',
'2017 The TensorFlow Authors',
'CC BY',
'https://creativecommons.org/licenses/by/3.0/'
], [

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

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

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Docs
class Tensorflow
class EntriesFilter < Docs::EntriesFilter
@ -5,58 +7,37 @@ module Docs
name = at_css('h1').content.strip
name.remove! 'class '
name.remove! 'struct '
name.remove! 'module: '
name.remove! %r{ \(.+\)}
name.sub! %r{(?<!\ )\(.+\)}, '()'
name.remove! %r{\.\z}
name.sub! 'tf.contrib', 'contrib' unless version == 'Guide'
name
end
def get_type
if version == 'Guide'
type = subpath.start_with?('tutorials') ? 'Tutorials' : 'How-Tos'
TYPE_BY_DIR = {
'get_started' => 'Get Started',
'programmers_guide' => 'Guide',
'tutorials' => 'Tutorials',
'performance' => 'Performance',
'deploy' => 'Deploy',
'extend' => 'Extend'
}
if node = at_css('.devsite-nav-item.devsite-nav-active')
node = node.previous_element until !node || node['class'].include?('devsite-nav-item-heading')
type << ": #{node.content}" if node
end
def get_type
return 'Guides' if base_url.path.start_with?('/api_guides')
type
elsif version == 'C++'
name.remove 'tensorflow::'
if version == 'Guide'
TYPE_BY_DIR[subpath.split('/').first]
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.prepend 'Contrib: ' if type.sub!(' (contrib)', '')
type = 'tf.contrib' if type.start_with?('tf.contrib')
type
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

@ -1,9 +1,11 @@
# frozen_string_literal: true
module Docs
class Tensorflow < UrlScraper
self.name = 'TensorFlow'
self.type = 'tensorflow'
self.release = '1.0'
self.root_path = 'index.html'
self.force_gzip = true
self.links = {
home: 'https://www.tensorflow.org/',
code: 'https://github.com/tensorflow/tensorflow'
@ -19,28 +21,49 @@ module Docs
end
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>
Code samples licensed under the Apache 2.0 License.
HTML
version 'Python' do
self.base_url = 'https://www.tensorflow.org/api_docs/python/'
self.release = '0.12'
include MultipleBaseUrls
self.base_urls = ['https://www.tensorflow.org/api_docs/python/', 'https://www.tensorflow.org/api_guides/python/']
end
version 'C++' do
self.base_url = 'https://www.tensorflow.org/api_docs/cc/'
self.release = '0.12'
include MultipleBaseUrls
self.base_urls = ['https://www.tensorflow.org/api_docs/cc/', 'https://www.tensorflow.org/api_guides/cc/']
end
version 'Guide' do
self.base_url = 'https://www.tensorflow.org/'
self.release = '0.12'
self.root_path = 'tutorials/'
self.initial_paths = %w(how_tos/)
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/]
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

Loading…
Cancel
Save