History

Add documentation for TensorFlow's python API

Jonas Meinertz Hansen committed 10 years ago

Commit cd55b861 parent 9c9b2ac9 files · +74 −-2Browse files

Showing the changes to lib/docs (3 of 9 files). Show all

Unified · Split

3 files
  1. lib/docs/filters/tensorflow/clean_html.rb +10 −0
  2. lib/docs/filters/tensorflow/entries.rb +33 −0
  3. lib/docs/scrapers/tensorflow.rb +18 −0
lib/docs/filters/tensorflow/clean_html.rb+10−0
@@ -0,0 +1,10 @@
1module Docs
2 class Tensorflow
3 class CleanHtmlFilter < Filter
4 def call
5 css('hr').remove
6 doc
7 end
8 end
9 end
10end
lib/docs/filters/tensorflow/entries.rb+33−0
@@ -0,0 +1,33 @@
1module Docs
2 class Tensorflow
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 at_css('h1').content
6 end
7
8 def get_type
9 at_css('h1').content
10 end
11
12 def include_default_entry?
13 false
14 end
15
16 def additional_entries
17 entries = []
18
19 # Just get everything that is a code tag inside a header tag. I haven't
20 # checked if all of these are necessary.
21 ents = css('h5 code') + css('h4 code') + css('h3 code') + css('h2 code')
22
23 ents.each do |node|
24 name = node.content.sub(/\(.*\)/, '()')
25 id = node.parent['id']
26 entries << [name, id, get_name]
27 end
28
29 entries
30 end
31 end
32 end
33end
lib/docs/scrapers/tensorflow.rb+18−0
@@ -0,0 +1,18 @@
1module Docs
2 class Tensorflow < UrlScraper
3 self.name = 'TensorFlow'
4 self.slug = 'tensorflow'
5 self.type = 'tensorflow'
6 self.release = '0.6.0-py'
7 self.base_url = 'https://www.tensorflow.org/versions/0.6.0/api_docs/python/'
8
9 options[:container] = '#content'
10
11 html_filters.push 'tensorflow/entries', 'tensorflow/clean_html', 'clean_html'
12
13 options[:attribution] = <<-HTML
14 &copy; The TensorFlow Authors. All rights reserved.<br>
15 Licensed under the Apache 2.0 License.
16 HTML
17 end
18end