History

Merge pull request #954 from filipesilva/rxjs

Add RxJS

Jasper van Merle committed 7 years ago

Commit 79acde02 parents 22f7bcf 17528d99 files · +296 −8Browse files

Unified · Split

9 files
  1. assets/javascripts/templates/pages/about_tmpl.coffee +10 −10
  2. assets/stylesheets/application.css.scss +1 −0
  3. assets/stylesheets/pages/_rxjs.scss +24 −0
  4. lib/docs/filters/rxjs/clean_html.rb +139 −0
  5. lib/docs/filters/rxjs/entries.rb +29 −0
  6. lib/docs/scrapers/rxjs.rb +94 −0
  7. public/icons/docs/rxjs/16.png +0 −0
  8. public/icons/docs/rxjs/16@2x.png +0 −0
  9. public/icons/docs/rxjs/SOURCE +1 −0
assets/javascripts/templates/pages/about_tmpl.coffee+10−10
@@ -211,8 +211,7 @@ credits = [ · 210 unmodified lines
211 '2017 Cypress.io',211 '2017 Cypress.io',
212 'MIT',212 'MIT',
213 'https://raw.githubusercontent.com/cypress-io/cypress-documentation/develop/LICENSE.md'213 'https://raw.githubusercontent.com/cypress-io/cypress-documentation/develop/LICENSE.md'
214 ],214 ], [
215 [
216 'D',215 'D',
217 '1999-2018 The D Language Foundation',216 '1999-2018 The D Language Foundation',
218 'Boost',217 'Boost',
@@ -572,8 +571,7 @@ credits = [ · 353 unmodified lines
572 '2016-2018, The Pony Developers & 2014-2015, Causality Ltd.',571 '2016-2018, The Pony Developers & 2014-2015, Causality Ltd.',
573 'BSD',572 'BSD',
574 'https://raw.githubusercontent.com/ponylang/ponyc/master/LICENSE'573 'https://raw.githubusercontent.com/ponylang/ponyc/master/LICENSE'
575 ],574 ], [
576 [
577 'PostgreSQL',575 'PostgreSQL',
578 '1996-2018 The PostgreSQL Global Development Group<br>&copy; 1994 The Regents of the University of California',576 '1996-2018 The PostgreSQL Global Development Group<br>&copy; 1994 The Regents of the University of California',
579 'PostgreSQL',577 'PostgreSQL',
@@ -648,13 +646,17 @@ credits = [ · 68 unmodified lines
648 '2010 The Rust Project Developers',646 '2010 The Rust Project Developers',
649 'MIT',647 'MIT',
650 'https://raw.githubusercontent.com/rust-lang/rust/master/LICENSE-MIT'648 'https://raw.githubusercontent.com/rust-lang/rust/master/LICENSE-MIT'
649 ], [
650 'RxJS',
651 '2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors',
652 'Apache',
653 'https://raw.githubusercontent.com/ReactiveX/rxjs/master/LICENSE.txt'
651 ], [654 ], [
652 'Salt Stack',655 'Salt Stack',
653 '2019 SaltStack',656 '2019 SaltStack',
654 'Apache',657 'Apache',
655 'https://raw.githubusercontent.com/saltstack/salt/develop/LICENSE'658 'https://raw.githubusercontent.com/saltstack/salt/develop/LICENSE'
656 ],659 ], [
657 [
658 'Sass',660 'Sass',
659 '2006-2016 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein',661 '2006-2016 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein',
660 'MIT',662 'MIT',
@@ -664,8 +666,7 @@ credits = [ · 3 unmodified lines
664 '2002-2019 EPFL, with contributions from Lightbend',666 '2002-2019 EPFL, with contributions from Lightbend',
665 'Apache',667 'Apache',
666 'https://raw.githubusercontent.com/scala/scala-lang/master/license.md'668 'https://raw.githubusercontent.com/scala/scala-lang/master/license.md'
667 ],669 ], [
668 [
669 'scikit-image',670 'scikit-image',
670 '2011 the scikit-image team',671 '2011 the scikit-image team',
671 'BSD',672 'BSD',
@@ -765,8 +766,7 @@ credits = [ · 93 unmodified lines
765 '2003-2019 WordPress Foundation',766 '2003-2019 WordPress Foundation',
766 'GPLv2+',767 'GPLv2+',
767 'https://wordpress.org/about/license/'768 'https://wordpress.org/about/license/'
768 ],769 ], [
769 [
770 'Yarn',770 'Yarn',
771 '2016-present Yarn Contributors',771 '2016-present Yarn Contributors',
772 'BSD',772 'BSD',
assets/stylesheets/application.css.scss+1−0
@@ -94,6 +94,7 @@ · 93 unmodified lines
94 'pages/rfc',94 'pages/rfc',
95 'pages/rubydoc',95 'pages/rubydoc',
96 'pages/rust',96 'pages/rust',
97 'pages/rxjs',
97 'pages/scala',98 'pages/scala',
98 'pages/sinon',99 'pages/sinon',
99 'pages/socketio',100 'pages/socketio',
assets/stylesheets/pages/_rxjs.scss+24−0
@@ -0,0 +1,24 @@
1._rxjs {
2 @extend %simple;
3
4 .pre-title { @extend %pre-heading; }
5
6 .breadcrumbs { @extend %note; }
7 .banner { @extend %note-green; }
8 code.stable { @extend %label-green; }
9 code.experimental { @extend %label-orange; }
10 code.deprecated { @extend %label-red; }
11 .alert.is-important { @extend %note-red; }
12 .alert.is-helpful, .breadcrumbs { @extend %note-blue; }
13
14 .breadcrumbs { padding-left: 2em; }
15
16 img { margin: 1em 0; }
17
18 .location-badge {
19 font-style: italic;
20 text-align: right;
21 }
22
23 td h3 { margin: 0 !important; }
24}
lib/docs/filters/rxjs/clean_html.rb+139−0
@@ -0,0 +1,139 @@
1module Docs
2 class Rxjs
3 class CleanHtmlFilter < Filter
4 def call
5 if root_page?
6 css('.card-container').remove
7 at_css('h1').content = 'RxJS Documentation'
8 end
9
10 if at_css('h1').nil?
11 title = subpath.rpartition('/').last.titleize
12 doc.prepend_child("<h1>#{title}</h1>")
13 end
14
15 css('br', 'hr', '.material-icons', '.header-link', '.breadcrumb').remove
16
17 css('.content', 'article', '.api-header', 'section', '.instance-member').each do |node|
18 node.before(node.children).remove
19 end
20
21 css('label', 'h2 > em', 'h3 > em').each do |node|
22 node.name = 'code'
23 end
24
25 css('h1 + code').each do |node|
26 node.before('<p></p>')
27 while node.next_element.name == 'code'
28 node.previous_element << ' '
29 node.previous_element << node.next_element
30 end
31 node.previous_element.prepend_child(node)
32 end
33
34 css('td h3', '.l-sub-section > h3', '.alert h3', '.row-margin > h3', '.api-heading ~ h3', '.api-heading + h2', '.metadata-member h3').each do |node|
35 node.name = 'h4'
36 end
37
38 css('.l-sub-section', '.alert', '.banner').each do |node|
39 node.name = 'blockquote'
40 end
41
42 css('.file').each do |node|
43 node.content = node.content.strip
44 end
45
46 css('.filetree .children').each do |node|
47 node.css('.file').each do |n|
48 n.content = " #{n.content}"
49 end
50 end
51
52 css('.filetree').each do |node|
53 node.content = node.css('.file').map(&:inner_html).join("\n")
54 node.name = 'pre'
55 node.remove_attribute('class')
56 end
57
58 css('pre').each do |node|
59 node.content = node.content.strip
60
61 node['data-language'] = 'typescript' if node['path'].try(:ends_with?, '.ts')
62 node['data-language'] = 'html' if node['path'].try(:ends_with?, '.html')
63 node['data-language'] = 'css' if node['path'].try(:ends_with?, '.css')
64 node['data-language'] = 'js' if node['path'].try(:ends_with?, '.js')
65 node['data-language'] = 'json' if node['path'].try(:ends_with?, '.json')
66 node['data-language'] = node['language'].sub(/\Ats/, 'typescript').strip if node['language']
67 node['data-language'] ||= 'typescript' if node.content.start_with?('@')
68
69 node.before(%(<div class="pre-title">#{node['title']}</div>)) if node['title']
70
71 if node['class'] && node['class'].include?('api-heading')
72 node.name = 'h3'
73
74 unless node.ancestors('.instance-method').empty?
75 matches = node.inner_html.scan(/([^(& ]+)[(&]/)
76
77 unless matches.empty? || matches[0][0] == 'constructor'
78 node['name'] = matches[0][0]
79 node['id'] = node['name'].downcase + '-'
80 end
81 end
82
83 node.inner_html = "<code>#{node.inner_html}</code>"
84 end
85
86 node.remove_attribute('path')
87 node.remove_attribute('region')
88 node.remove_attribute('linenums')
89 node.remove_attribute('title')
90 node.remove_attribute('language')
91 node.remove_attribute('hidecopy')
92 node.remove_attribute('class')
93 end
94
95 css('td > .overloads').each do |node|
96 node.replace node.at_css('.detail-contents')
97 end
98
99 css('td.short-description p').each do |node|
100 signature = node.parent.parent.next_element.at_css('h3[id]')
101 signature.after(node) unless signature.nil?
102 end
103
104 css('.method-table').each do |node|
105 node.replace node.at_css('tbody')
106 end
107
108 css('.api-body > table > caption').each do |node|
109 node.name = 'center'
110 lift_out_of_table node
111 end
112
113 css('.api-body > table > tbody > tr:not([class]) > td > *').each do |node|
114 lift_out_of_table node
115 end
116
117 css('.api-body > table').each do |node|
118 node.remove if node.content.strip.blank?
119 end
120
121 css('h1[class]').remove_attr('class')
122 css('table[class]').remove_attr('class')
123 css('table[width]').remove_attr('width')
124 css('tr[style]').remove_attr('style')
125
126 css('code code').each do |node|
127 node.before(node.children).remove
128 end
129
130 doc
131 end
132
133 def lift_out_of_table(node)
134 table = node.ancestors('table').first
135 table.previous_element.after(node)
136 end
137 end
138 end
139end
lib/docs/filters/rxjs/entries.rb+29−0
@@ -0,0 +1,29 @@
1module Docs
2 class Rxjs
3 class EntriesFilter < Docs::EntriesFilter
4 def get_name
5 title = at_css('h1')
6 name = title.nil? ? subpath.rpartition('/').last.titleize : title.content
7 name.prepend "#{$1}. " if subpath =~ /\-pt(\d+)/
8 name += '()' unless at_css('.api-type-label.function').nil?
9 name
10 end
11
12 def get_type
13 if slug.start_with?('guide')
14 'Guide'
15 elsif slug.start_with?('api/')
16 slug.split('/').second
17 else
18 'Miscellaneous'
19 end
20 end
21
22 def additional_entries
23 css('h3[id]').map do |node|
24 ["#{name}.#{node['name']}()", node['id']]
25 end
26 end
27 end
28 end
29end
lib/docs/scrapers/rxjs.rb+94−0
@@ -0,0 +1,94 @@
1require 'yajl/json_gem'
2
3module Docs
4 class Rxjs < UrlScraper
5 self.name = 'RxJS'
6 self.type = 'rxjs'
7 self.release = '6.5.2'
8 self.base_url = 'https://rxjs.dev/'
9 self.root_path = 'guide/overview'
10 self.links = {
11 home: 'https://rxjs.dev/',
12 code: 'https://github.com/ReactiveX/rxjs'
13 }
14
15 html_filters.push 'rxjs/clean_html', 'rxjs/entries'
16
17 options[:follow_links] = false
18 options[:only_patterns] = [/guide\//, /api\//]
19 options[:skip_patterns] = [/api\/([^\/]+)\.json/]
20 options[:fix_urls_before_parse] = ->(url) do
21 url.sub! %r{\Aguide/}, '/guide/'
22 url.sub! %r{\Aapi/}, '/api/'
23 url.sub! %r{\Agenerated/}, '/generated/'
24 url
25 end
26
27 options[:max_image_size] = 256_000
28
29 options[:attribution] = <<-HTML
30 &copy; 2015&ndash;2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.<br>
31 Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
32 HTML
33
34 def get_latest_version(opts)
35 json = fetch_json('https://rxjs.dev/generated/navigation.json', opts)
36 json['__versionInfo']['raw']
37 end
38
39 private
40
41 def initial_urls
42 initial_urls = []
43
44 Request.run "#{self.class.base_url}generated/navigation.json" do |response|
45 data = JSON.parse(response.body)
46 dig = ->(entry) do
47 initial_urls << url_for("generated/docs/#{entry['url']}.json") if entry['url'] && entry['url'] != 'api'
48 entry['children'].each(&dig) if entry['children']
49 end
50 data['SideNav'].each(&dig)
51 end
52
53 Request.run "#{self.class.base_url}generated/docs/api/api-list.json" do |response|
54 data = JSON.parse(response.body)
55 dig = ->(entry) do
56 initial_urls << url_for("generated/docs/#{entry['path']}.json") if entry['path']
57 initial_urls << url_for("generated/docs/api/#{entry['name']}.json") if entry['name'] && !entry['path']
58 entry['items'].each(&dig) if entry['items']
59 end
60 data.each(&dig)
61 end
62
63 initial_urls.select do |url|
64 options[:only_patterns].any? { |pattern| url =~ pattern } &&
65 options[:skip_patterns].none? { |pattern| url =~ pattern }
66 end
67 end
68
69 def handle_response(response)
70 if response.mime_type.include?('json')
71 begin
72 response.options[:response_body] = JSON.parse(response.body)['contents']
73 rescue JSON::ParserError
74 response.options[:response_body] = ''
75 end
76 response.headers['Content-Type'] = 'text/html'
77 response.url.path = response.url.path.sub('/generated/docs/', '/').remove('.json')
78 response.effective_url.path = response.effective_url.path.sub('/generated/docs/', '/').remove('.json')
79 end
80 super
81 end
82
83 def parse(response)
84 response.body.gsub! '<code-example', '<pre'
85 response.body.gsub! '</code-example', '</pre'
86 response.body.gsub! '<code-pane', '<pre'
87 response.body.gsub! '</code-pane', '</pre'
88 response.body.gsub! '<live-example></live-example>', 'live example'
89 response.body.gsub! '<live-example', '<span'
90 response.body.gsub! '</live-example', '</span'
91 super
92 end
93 end
94end
public/icons/docs/rxjs/16.png+0−0

Binary file not shown.

public/icons/docs/rxjs/16@2x.png+0−0

Binary file not shown.

public/icons/docs/rxjs/SOURCE+1−0
@@ -0,0 +1 @@
1https://github.com/ReactiveX/reactivex.github.io/blob/develop/favicon.ico