From 02e4a384b67ca71bd669e59a4fbf41a6653540ff Mon Sep 17 00:00:00 2001 From: Lukas Geiger Date: Thu, 26 Dec 2019 21:45:45 +0100 Subject: [PATCH] Upgrade TensorFlow docs to v2.0 --- .../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{(? '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 - © 2018 The TensorFlow Authors. All rights reserved.
+ © 2019 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
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 07f894e51489afda315f6c5da39ace2d9280ea45..8463d5699f47fe7db6b702b5a30c64ba74d85afb 100644 GIT binary patch delta 575 zcmV-F0>J&f1=j?SBYyx1a7bBm000XU000XU0RWnu7ytkQ2}wjjR5*>5lgn#UQ4oi} zb8~V7HEJYAqDCoATiSwAYQP6d!3TtZ73@Ngx~OiVv~Cpf4^VI+E==(Ok_tBNbRn3E ziknmkwxR^7(NZj8u$pL7uLL!Z<07e;n=aZ}&iv*(^EyH)MSq>8?z%}_I>who2NKw@ zeFFcP2u(dRW~rzFe4lC{IlP}&*ZaxO?8eG-Bp}(zDtDYsp+TB^A7l6CYXLvMN)p%n zByXQ2H`R?~Wi|0B60oud9nhJ>>Ag?W(W|ta7{|7zC{*g9i_t3syo>c=#ZyfLiwR%@ z^lD7p`+GL} zN65bJrI2&hr0b4vtlc_H?nMw~v?9?sF+64*v#~u^Q`WCN&DGnRA;(aE2Ag^Hj0Km?_4}UcVuvHxlC?s z7ph!XIzTQju;WG)<81_e#lK5jLJJDyGJ)q{wuZZ~R#_JI)epEHpjiy;?l}3+-B7Nq zQ)s_va5%>i7Q-wTb>F#Mg4szIj|Teq_{4_dikkeUDh N002ovPDHLkV1i`a2R;A* delta 678 zcmV;X0$Kgn1ib~2BYy&fNklC>`tG*bx{dLhdFPow^X&$7`Ac~g_t~qHL)J2K$g&&<66;5qqb>ga zUbvylUl_~$sXUW|mR$L;E zf_;sUa)gk7et#l0N(x|`5$+N$i*e?d(y%B6WS?0k+YJC-Z{xN zK;KZBm#&W&`x-L6$Oj1Xjk%k@hb*5ZaS`$}_D& zLq!9I`6Dt$W%kM@rSc9jl^Uc9v@{cZB?)q1eN0GRsDZb*QPVJUYpm(ts37Y0>7&?B zu+dYN(tiZJ?=3*=%@aaL87gDpE@G1@^4+40^6@K!EFSLh8saWAz%!G3MEmLUo$!YS zX+|qGAYx{?R5o0sPnxXJE8K4lqzpr2SE>DD!&qc0ACK3oy=r`tpET3 M07*qoM6N<$f-W~r6#xJL diff --git a/public/icons/docs/tensorflow/16@2x.png b/public/icons/docs/tensorflow/16@2x.png index 94eebc919259cfd6d5dc8904b08684baf2a45bbd..00a8af6dabc6bd2705678240ab4a59398f490e80 100644 GIT binary patch delta 378 zcmV-=0fqj82b2SlBYy!~NklbWUp}x zZee%_FF+E28Gr&LzQXejW&mg00{w{0I>v+1jue{8DL$D zh8@ySfEQrny>k{E!4dQI9gOn304pwb{AgvDFmMU;4PwOV07*qoM6N<$g64^l^Z)<= delta 876 zcmV-y1C#ue1A+&TBYy))NklrBrBUNp8-*f)vd;kAE-B5Kc*wN_@-o*Cj&Fp0Uc?|!voC03c@kb$2y%fpr+=i>fAFza9!K-V80;ru zQo=Do9J_(HurJobIUDZA?ao2NeB`rTbf>wV|Wz!Hzi6#81a4_h?`YD_{jVB zaHiyu_|N|&Cmu@z-+CPhl>{JiO^E?+U$Ur&D_3?t93D8ve2l?gS9#9)iilt$YbMQ; z;Bv~)gJ)431dk+xe;axf2p;7D>_ek2`c^04MTxjL5P#T>=Uk+e3?{M-*L-SCr7wy? zpd910WNah=ndlrB4S}6WCFgt~9=t2aIae)ysp=V+LfvjlrF&b`^uI&^jI9QMpmaUB z7w9StbIn$X0uaAHvJDTS=REZDhyh@@A2nSZ0Og#b5f7fD0{f7c!Jb1`3J~^9i_)O? z{;~kBJb#(lvGj#lGKK&gsSLomQ0{e%e2M%&5&$ojcXKpN{31c{Aq0=wej_@T^dWE~?lk;rIBx8-HoJwW`0TXdfm&ivid&_264ho~>Am zjs^EhRd=fHB@RI37>O-+b7DA{JB%%QRmo*@=E-_DH~^7ratyZD@V#hU03!EdMe_o1 z=gNCE96%Ng&gp8fXVVb?_|_fxf+l>KtG%Z|0fbd9m4jn~R%qYOMG79f+$Pte7hfRr z8f6@S$hA-bp2f;{$@oSGAfE-T7oZ)$lNF=3rqZ8D0C1i>`8u9FyM`*DsN1aR`YyN| zKZF5t<(FJ}FS1l))-UNv_gk~+DbA&`J|U>O`uz{`kU3y8-V3V$0000