[devdocsgjs/main: 562/1867] Add ReactiveX documentation




commit d0cf5d745ca35b46aaf8c4361f88e489c6943cec
Author: Jasper van Merle <jaspervmerle gmail com>
Date:   Sat Jan 26 23:09:27 2019 +0100

    Add ReactiveX documentation

 .../javascripts/templates/pages/about_tmpl.coffee  |   5 ++
 assets/stylesheets/application.css.scss            |   1 +
 assets/stylesheets/pages/_reactivex.scss           |  11 ++++
 lib/docs/filters/reactivex/clean_html.rb           |  65 +++++++++++++++++++++
 lib/docs/filters/reactivex/entries.rb              |  14 +++++
 lib/docs/scrapers/reactivex.rb                     |  23 ++++++++
 public/icons/docs/reactivex/SOURCE                 |   1 +
 public/icons/docs/reactivex/logo.png               | Bin 0 -> 1521 bytes
 public/icons/docs/reactivex/logo 2x png            | Bin 0 -> 5084 bytes
 9 files changed, 120 insertions(+)
---
diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee 
b/assets/javascripts/templates/pages/about_tmpl.coffee
index 5d997403..8e8eebc2 100644
--- a/assets/javascripts/templates/pages/about_tmpl.coffee
+++ b/assets/javascripts/templates/pages/about_tmpl.coffee
@@ -595,6 +595,11 @@ credits = [
     '2013-present Facebook Inc.',
     'MIT',
     'https://raw.githubusercontent.com/facebook/react/master/LICENSE'
+  ], [
+    'ReactiveX',
+    'ReactiveX contributors',
+    'Apache',
+    'https://raw.githubusercontent.com/ReactiveX/reactivex.github.io/develop/LICENSE'
   ], [
     'Redis',
     '2009-2018 Salvatore Sanfilippo',
diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss
index 2a64e5c9..0f239f81 100644
--- a/assets/stylesheets/application.css.scss
+++ b/assets/stylesheets/application.css.scss
@@ -89,6 +89,7 @@
         'pages/ramda',
         'pages/rdoc',
         'pages/react_native',
+        'pages/reactivex',
         'pages/redis',
         'pages/rethinkdb',
         'pages/rfc',
diff --git a/assets/stylesheets/pages/_reactivex.scss b/assets/stylesheets/pages/_reactivex.scss
new file mode 100644
index 00000000..f544865d
--- /dev/null
+++ b/assets/stylesheets/pages/_reactivex.scss
@@ -0,0 +1,11 @@
+._reactivex {
+  @extend %simple;
+
+  img {
+    max-width: 50%;
+  }
+
+  figure {
+    margin: 0;
+  }
+}
diff --git a/lib/docs/filters/reactivex/clean_html.rb b/lib/docs/filters/reactivex/clean_html.rb
new file mode 100644
index 00000000..2338bb5c
--- /dev/null
+++ b/lib/docs/filters/reactivex/clean_html.rb
@@ -0,0 +1,65 @@
+module Docs
+  class Reactivex
+    class CleanHtmlFilter < Filter
+      def call
+        # Can't use options[:container] because then the navigation bar wouldn't be scraped
+        @doc = at_css(root_page? ? '.col-md-8' : '.col-sm-8')
+
+        # Remove breadcrumbs
+        css('.breadcrumb').remove
+
+        # Replace interactive demo's with links to them
+        css('rx-marbles').each do |node|
+          node.name = 'a'
+          node.content = 'Open interactive diagram on rxmarbles.com'
+          node['href'] = "https://rxmarbles.com/##{node['key']}"
+          node.remove_attribute('key')
+        end
+
+        # Syntax-highlighted code blocks
+        css('.code').each do |node|
+          language = node['class'].gsub('code', '').strip
+
+          pre = node.at_css('pre')
+          pre['data-language'] = language
+          pre.content = pre.content.strip
+
+          node.replace(pre)
+        end
+
+        # Assume JavaScript syntax for code blocks not surrounded by a div.code
+        css('pre').each do |node|
+          next if node['data-language']
+
+          node.content = node.content.strip
+          node['data-language'] = 'javascript'
+        end
+
+        # Make language specific implementation titles prettier
+        css('.panel-title').each do |node|
+          # Remove the link, keep the text
+          node.content = node.content
+
+          # Transform it into a header for better styling
+          node.name = 'h3'
+        end
+
+        # Remove language specific implementations that are TBD
+        css('span').each do |node|
+          next unless node.content == 'TBD'
+          node.xpath('./ancestor::div[contains(@class, "panel-default")][1]').remove
+        end
+
+        # Remove the : at the end of "Language-Specific Information:"
+        css('h2').each do |node|
+          node.inner_html = node.inner_html.gsub('Information:', 'Information')
+        end
+
+        # Remove attributes to reduce file size
+        css('div').remove_attr('class')
+
+        doc
+      end
+    end
+  end
+end
diff --git a/lib/docs/filters/reactivex/entries.rb b/lib/docs/filters/reactivex/entries.rb
new file mode 100644
index 00000000..d238ffb4
--- /dev/null
+++ b/lib/docs/filters/reactivex/entries.rb
@@ -0,0 +1,14 @@
+module Docs
+  class Reactivex
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        at_css('h1').content
+      end
+
+      def get_type
+        links = css('.breadcrumb > li:nth-child(2) > a')
+        links.size > 0 ? links.first.content : 'Manual'
+      end
+    end
+  end
+end
diff --git a/lib/docs/scrapers/reactivex.rb b/lib/docs/scrapers/reactivex.rb
new file mode 100644
index 00000000..1374468b
--- /dev/null
+++ b/lib/docs/scrapers/reactivex.rb
@@ -0,0 +1,23 @@
+module Docs
+  class Reactivex < UrlScraper
+    self.type = 'reactivex'
+    self.name = 'ReactiveX'
+    self.base_url = 'http://reactivex.io/'
+    self.root_path = 'intro.html'
+    self.links = {
+      home: 'http://reactivex.io/'
+    }
+
+    html_filters.push 'reactivex/entries', 'reactivex/clean_html'
+
+    options[:download_images] = false
+
+    options[:only_patterns] = [/documentation\//]
+    options[:skip_patterns] = [/ko\//]
+
+    options[:attribution] = <<-HTML
+      &copy; ReactiveX contributors<br>
+      Licensed under the Apache License 2.0.
+    HTML
+  end
+end
diff --git a/public/icons/docs/reactivex/SOURCE b/public/icons/docs/reactivex/SOURCE
new file mode 100644
index 00000000..f9c25e1e
--- /dev/null
+++ b/public/icons/docs/reactivex/SOURCE
@@ -0,0 +1 @@
+https://github.com/ReactiveX/reactivex.github.io/blob/develop/assets/Rx_Icon.png
diff --git a/public/icons/docs/reactivex/logo.png b/public/icons/docs/reactivex/logo.png
new file mode 100644
index 00000000..790f8390
Binary files /dev/null and b/public/icons/docs/reactivex/logo.png differ
diff --git a/public/icons/docs/reactivex/logo 2x png b/public/icons/docs/reactivex/logo 2x png
new file mode 100644
index 00000000..a45cd5cb
Binary files /dev/null and b/public/icons/docs/reactivex/logo 2x png differ


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]