From cd55b861ca5001f2196137a517e71eb37adb0efc Mon Sep 17 00:00:00 2001 From: Jonas Meinertz Hansen Date: Tue, 9 Feb 2016 03:10:25 +0100 Subject: [PATCH] Add documentation for TensorFlow's python API --- assets/stylesheets/application-dark.css.scss | 1 + assets/stylesheets/application.css.scss | 1 + assets/stylesheets/pages/_tensorflow.scss | 12 +++++++ lib/docs/filters/tensorflow/clean_html.rb | 10 ++++++ lib/docs/filters/tensorflow/entries.rb | 33 +++++++++++++++++++ lib/docs/scrapers/tensorflow.rb | 18 ++++++++++ public/icons/docs/tensorflow/16.png | Bin 0 -> 647 bytes public/icons/docs/tensorflow/16@2x.png | Bin 0 -> 1076 bytes public/icons/docs/tensorflow/SOURCE | 1 + 9 files changed, 76 insertions(+) create mode 100644 assets/stylesheets/pages/_tensorflow.scss create mode 100644 lib/docs/filters/tensorflow/clean_html.rb create mode 100644 lib/docs/filters/tensorflow/entries.rb create mode 100644 lib/docs/scrapers/tensorflow.rb create mode 100644 public/icons/docs/tensorflow/16.png create mode 100644 public/icons/docs/tensorflow/16@2x.png create mode 100644 public/icons/docs/tensorflow/SOURCE diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index 48a664f4..48314be5 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -76,6 +76,7 @@ 'pages/sphinx', 'pages/sphinx_simple', 'pages/tcl_tk', + 'pages/tensorflow', 'pages/underscore', 'pages/vagrant', 'pages/vue', diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index e554c901..8ed497ce 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -76,6 +76,7 @@ 'pages/sphinx', 'pages/sphinx_simple', 'pages/tcl_tk', + 'pages/tensorflow', 'pages/underscore', 'pages/vagrant', 'pages/vue', diff --git a/assets/stylesheets/pages/_tensorflow.scss b/assets/stylesheets/pages/_tensorflow.scss new file mode 100644 index 00000000..8ad840d7 --- /dev/null +++ b/assets/stylesheets/pages/_tensorflow.scss @@ -0,0 +1,12 @@ +._tensorflow { + h2, h3, h4 { @extend %block-heading, %label-blue; } + p > code, li > code { @extend %label; } + + // These are used for lists of arguments and return values in the docs. + b > code { + @extend %label; + background-color: initial; + font-weight: 500; + font-size: 1.1em; + } +} diff --git a/lib/docs/filters/tensorflow/clean_html.rb b/lib/docs/filters/tensorflow/clean_html.rb new file mode 100644 index 00000000..1967a7e0 --- /dev/null +++ b/lib/docs/filters/tensorflow/clean_html.rb @@ -0,0 +1,10 @@ +module Docs + class Tensorflow + class CleanHtmlFilter < Filter + def call + css('hr').remove + doc + end + end + end +end diff --git a/lib/docs/filters/tensorflow/entries.rb b/lib/docs/filters/tensorflow/entries.rb new file mode 100644 index 00000000..7b86b504 --- /dev/null +++ b/lib/docs/filters/tensorflow/entries.rb @@ -0,0 +1,33 @@ +module Docs + class Tensorflow + class EntriesFilter < Docs::EntriesFilter + def get_name + at_css('h1').content + end + + def get_type + at_css('h1').content + end + + def include_default_entry? + false + end + + def additional_entries + entries = [] + + # Just get everything that is a code tag inside a header tag. I haven't + # checked if all of these are necessary. + ents = css('h5 code') + css('h4 code') + css('h3 code') + css('h2 code') + + ents.each do |node| + name = node.content.sub(/\(.*\)/, '()') + id = node.parent['id'] + entries << [name, id, get_name] + end + + entries + end + end + end +end diff --git a/lib/docs/scrapers/tensorflow.rb b/lib/docs/scrapers/tensorflow.rb new file mode 100644 index 00000000..c6436cdd --- /dev/null +++ b/lib/docs/scrapers/tensorflow.rb @@ -0,0 +1,18 @@ +module Docs + class Tensorflow < UrlScraper + self.name = 'TensorFlow' + self.slug = 'tensorflow' + self.type = 'tensorflow' + self.release = '0.6.0-py' + self.base_url = 'https://www.tensorflow.org/versions/0.6.0/api_docs/python/' + + options[:container] = '#content' + + html_filters.push 'tensorflow/entries', 'tensorflow/clean_html', 'clean_html' + + options[:attribution] = <<-HTML + © The TensorFlow Authors. All rights reserved.
+ Licensed under the Apache 2.0 License. + HTML + end +end diff --git a/public/icons/docs/tensorflow/16.png b/public/icons/docs/tensorflow/16.png new file mode 100644 index 0000000000000000000000000000000000000000..2ec8a330c2f7fd537666ebc97c85b5d154698059 GIT binary patch literal 647 zcmV;20(kw2P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;(#7eog=Y0r*KoK~y+Tm6A(K8&MR;hgP%;kxH>$NMAsH*N%>D?dS!Ce!Q+*%h)V-2~BOe4-1xDlL>kg{tUH{RYL28(p}x#nNOZ zlSGruoZh*;nGt+M|8Tf-&pqeIc?@%tU@!8}D#|lvQC_pqizn3GS+F}oa9*dz`Z?8{(E+4|DGb=RA+}ZDdx@U_N^vn}J1d!h zn>5FP@%E{6|GhBK3)9T~aza$faq*M_cIwL<&-_h>BIUSnsJ|J8s>(L2IsUt*2)J*7 zB%iGhL2E}!05JFLS(TON{gteDf())Lm=1R98UO3btS4jxNvTN@8lS@M(6*yLD{J1) z|AGU+rYk`>D~v$na|mjSxGj~B(6H-u5zw|;o+IrT>fjv!xCP^#53df-VvhY~Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;(#7eog=Y1EonsK~z{r?Nv)?6Hyc$6;!IY5JaU-YTH;R zsjao`Ox=kaQ4m*(C|E(7TI)h7MXjO%LB&r?6My)FDvF{gT4|{?X|W4G8<#G`MMb(0 zlqQpzd}rSE&g6||GOzWMST`OxB$>JQoRgXN?&Ico*a5)Jq$Pg`WJstaA>oM@5{YS^O$_pi3^z8?^1^`(u33oU-DsR* z8D|q~G_1W%M#K`@{^x)Pp4s@g_o3idmf2LqAc`6kk3e625taKrkYM9ReBAF?;s%EV zNZs>5>}(Ba{Q|p2XHXnNZo&02gGx^gG_AtML7Pw((~qkmex(dz0VhOSd63#XkhoNf zq1g30wIN|N8LX?LHg=HF+C^GWysU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