History

Add Flow documentation

Thibaut committed 10 years ago

Commit 2bf94f51 parent 693986511 files · +30 −3Browse files

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

Unified · Split

3 files
  1. lib/docs/filters/react/clean_html.rb +6 −2
  2. lib/docs/filters/react/entries.rb +2 −2
  3. lib/docs/scrapers/flow.rb +22 −0
lib/docs/filters/react/clean_html.rb+6−2
@@ -2,7 +2,7 @@ module Docs · 1 unmodified line
2 class React2 class React
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 @doc = at_css('.inner-content')5 @doc = at_css('.inner-content, article.withtoc')
6 6
7 if root_page?7 if root_page?
8 at_css('h1').content = context[:root_title]8 at_css('h1').content = context[:root_title]
@@ -16,10 +16,14 @@ module Docs · 7 unmodified lines
16 16
17 css('.highlight').each do |node|17 css('.highlight').each do |node|
18 node.name = 'pre'18 node.name = 'pre'
19 node['data-lang'] = node.at_css('[data-lang]')['data-lang']19 node['data-lang'] = node.at_css('[data-lang]').try(:[], 'data-lang') || 'js'
20 node.content = node.content20 node.content = node.content
21 end21 end
22 22
23 css('table.highlighttable').each do |node|
24 node.replace(node.at_css('pre.highlight'))
25 end
26
23 css('.prism').each do |node|27 css('.prism').each do |node|
24 node.name = 'pre'28 node.name = 'pre'
25 node['data-lang'] = node['class'][/(?<=language\-)(\w+)/]29 node['data-lang'] = node['class'][/(?<=language\-)(\w+)/]
lib/docs/filters/react/entries.rb+2−2
@@ -18,8 +18,8 @@ module Docs · 17 unmodified lines
18 end18 end
19 19
20 def get_type20 def get_type
21 link = at_css('.nav-docs-section .active')21 link = at_css('.nav-docs-section .active, .toc .active')
22 section = link.ancestors('.nav-docs-section').first22 section = link.ancestors('.nav-docs-section, section').first
23 type = section.at_css('h3').content.strip23 type = section.at_css('h3').content.strip
24 type = REPLACE_TYPES[type] || type24 type = REPLACE_TYPES[type] || type
25 type += ": #{name}" if type == 'Components'25 type += ": #{name}" if type == 'Components'
lib/docs/scrapers/flow.rb+22−0
@@ -0,0 +1,22 @@
1module Docs
2 class Flow < React
3 self.type = 'react'
4 self.version = '0.18'
5 self.base_url = 'http://flowtype.org/docs/'
6 self.root_path = 'about-flow.html'
7 self.links = {
8 home: 'http://flowtype.org/',
9 code: 'https://github.com/facebook/flow'
10 }
11
12 options[:container] = '.content'
13 options[:root_title] = 'Flow Documentation'
14 options[:only_patterns] = nil
15 options[:skip] = %w(coming-soon.html)
16
17 options[:attribution] = <<-HTML
18 &copy; 2013&ndash;2015 Facebook Inc.<br>
19 Licensed under the BSD License.
20 HTML
21 end
22end