Skip to content

Commit 77abbf2

Browse files
committed
Update Flow documentation (0.330.0)
1 parent b6de13f commit 77abbf2

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

lib/docs/filters/flow/clean_html.rb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ class Flow
33
class CleanHtmlFilter < Filter
44
def call
55
root_page? ? root : other
6+
css('footer', 'header', 'svg').remove
67
doc
78
end
89

910
def root
10-
@doc = at_css('.bg-faded + .container')
11+
@doc = at_css('article')
1112

1213
css('.row', '.col-lg-4', '.card-block').each do |node|
1314
node.before(node.children).remove
@@ -23,9 +24,9 @@ def root
2324
end
2425

2526
def other
26-
@doc = at_css('.article')
27+
@doc = at_css('article')
2728

28-
css('.nav-tabs', '#select-platform', '.guide-controls + .list-group', '.guide-controls', 'hr').remove
29+
css('.theme-doc-breadcrumbs', '.theme-doc-toc-mobile', '.nav-tabs', '#select-platform', '.guide-controls + .list-group', '.guide-controls', 'hr').remove
2930

3031
css('.guide-content', '.tabs', '.tab-content').each do |node|
3132
node.before(node.children).remove
@@ -36,6 +37,18 @@ def other
3637
node.remove
3738
end
3839

40+
css('pre').each do |node|
41+
token_lines = node.css('.token-line')
42+
next if token_lines.empty?
43+
44+
node.css('[class*="codeBlockLineNumber"]').remove
45+
node.content = token_lines.map(&:content).join("\n")
46+
node['data-language'] = 'typescript'
47+
node.remove_attribute('class')
48+
node.remove_attribute('style')
49+
node.ancestors('[class*="codeBlockContainer"]').first.replace(node)
50+
end
51+
3952
unless at_css('h2')
4053
css('h3', 'h4', 'h5').each do |node|
4154
node.name = node.name.sub(/\d/) { |i| i.to_i - 1 }

lib/docs/filters/flow/entries.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ def get_name
66
end
77

88
def get_type
9-
return 'React' if slug.start_with?('react')
10-
type = at_css('.guide-nav .nav-item').content.strip
11-
type.remove! %r{ \(.*}
12-
type
9+
css('.breadcrumbs__item .breadcrumbs__link')[-2]&.content&.strip.presence || get_name
1310
end
1411
end
1512
end

lib/docs/scrapers/flow.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Docs
22
class Flow < UrlScraper
33
self.type = 'simple'
4-
self.release = '0.186.0'
4+
self.release = '0.330.0'
55
self.base_url = 'https://flow.org/en/docs/'
66
self.links = {
77
home: 'https://flow.org/',

0 commit comments

Comments
 (0)