diff --git a/assets/images/docs.png b/assets/images/docs.png index d84bec93..443d6ae3 100644 Binary files a/assets/images/docs.png and b/assets/images/docs.png differ diff --git a/assets/images/docs@2x.png b/assets/images/docs@2x.png index de70a95a..fe55770b 100644 Binary files a/assets/images/docs@2x.png and b/assets/images/docs@2x.png differ diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index d67f87eb..daa5dbc2 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,5 +1,8 @@ [ [ + "2016-11-20", + "New documentation: Immutable.js" + ], [ "2016-10-10", "New documentations: scikit-learn and Statsmodels" ], [ diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 3ac46435..8d4ee90a 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -254,6 +254,11 @@ credits = [ '2005-2016 Haxe Foundation', 'MIT', 'http://haxe.org/foundation/open-source.html' + ], [ + 'Immutable.js', + '2014-2016 Facebook, Inc.', + 'BSD', + 'https://raw.githubusercontent.com/facebook/immutable-js/master/LICENSE' ], [ 'InfluxData', '2015 InfluxData, Inc.', diff --git a/assets/javascripts/views/pages/simple.coffee b/assets/javascripts/views/pages/simple.coffee index 89e63acc..9627c658 100644 --- a/assets/javascripts/views/pages/simple.coffee +++ b/assets/javascripts/views/pages/simple.coffee @@ -22,6 +22,7 @@ app.views.ElixirPage = app.views.EmberPage = app.views.ExpressPage = app.views.GoPage = +app.views.ImmutablePage = app.views.InfluxdataPage = app.views.KnockoutPage = app.views.KotlinPage = diff --git a/assets/stylesheets/global/_icons.scss b/assets/stylesheets/global/_icons.scss index c481c560..e193f036 100644 --- a/assets/stylesheets/global/_icons.scss +++ b/assets/stylesheets/global/_icons.scss @@ -72,6 +72,7 @@ ._icon-angularjs:before { background-position: -9rem -1rem; } ._icon-coffeescript:before { background-position: 0 -2rem; @extend %darkIconFix !optional; } ._icon-ember:before { background-position: -1rem -2rem; } +._icon-immutable:before { background-position: -3rem -2rem; @extend %darkIconFix !optional; } ._icon-jqueryui:before { background-position: -4rem -2rem; } ._icon-jquerymobile:before { background-position: -5rem -2rem; } ._icon-lodash:before { background-position: -6rem -2rem; } diff --git a/assets/stylesheets/pages/_simple.scss b/assets/stylesheets/pages/_simple.scss index 0205a6f6..1d15a1a4 100644 --- a/assets/stylesheets/pages/_simple.scss +++ b/assets/stylesheets/pages/_simple.scss @@ -25,6 +25,7 @@ ._gnu, ._grunt, ._haxe, +._immutable, ._influxdata, ._less, ._lodash, diff --git a/lib/docs/filters/immutable/clean_html.rb b/lib/docs/filters/immutable/clean_html.rb new file mode 100644 index 00000000..b1e29e60 --- /dev/null +++ b/lib/docs/filters/immutable/clean_html.rb @@ -0,0 +1,48 @@ +module Docs + class Immutable + class CleanHtmlFilter < Filter + def call + css('section', 'span', 'div[data-reactid]').each do |node| + node.before(node.children).remove + end + + css('.codeBlock').each do |node| + node.name = 'pre' + node.content = node.content + node['data-language'] = 'js' + end + + css('*[data-reactid]').remove_attr('data-reactid') + css('a[target]').remove_attr('target') + + css('a[href^="#"]').each do |node| + node['href'] = node['href'].sub(/\A#\//, '#').gsub('/', '.').downcase + end + + type = type_id = nil + css('*').each do |node| + if node.name == 'h1' + node['id'] = type_id = node.content.strip.downcase + type = node.content.strip + elsif node.name == 'h3' + node['id'] = node.content.strip.downcase + node['id'] = node['id'].remove('()') unless node['id'] == "#{type_id}()" + + unless node['id'].start_with?(type_id) + node.content = "#{type}##{node.content}" + node['id'] = "#{type_id}.#{node['id']}" unless node['id'].start_with?("#{type_id}.") + end + end + end + + css('h4.groupTitle').each do |node| + node.name = 'h2' + end + + css('*[class]').remove_attr('class') + + doc + end + end + end +end diff --git a/lib/docs/filters/immutable/entries.rb b/lib/docs/filters/immutable/entries.rb new file mode 100644 index 00000000..0ef05a75 --- /dev/null +++ b/lib/docs/filters/immutable/entries.rb @@ -0,0 +1,23 @@ +module Docs + class Immutable + class EntriesFilter < Docs::EntriesFilter + def additional_entries + entries = [] + type = nil + + css('*').each do |node| + if node.name == 'h1' + name = node.content + type = node.content.split('.').first + entries << [name, node['id'], type] + elsif node.name == 'h3' + name = node.content + entries << [name, node['id'], type] + end + end + + entries + end + end + end +end diff --git a/lib/docs/scrapers/immutable.rb b/lib/docs/scrapers/immutable.rb new file mode 100644 index 00000000..3a316ea8 --- /dev/null +++ b/lib/docs/scrapers/immutable.rb @@ -0,0 +1,58 @@ +module Docs + class Immutable < UrlScraper + self.name = 'Immutable.js' + self.slug = 'immutable' + self.type = 'immutable' + self.release = '3.8.1' + self.base_url = 'https://facebook.github.io/immutable-js/docs/' + self.links = { + home: 'https://facebook.github.io/immutable-js/', + code: 'https://github.com/facebook/immutable-js' + } + + html_filters.push 'immutable/clean_html', 'immutable/entries', 'title' + + options[:skip_links] = true + options[:container] = '.docContents' + options[:root_title] = 'Immutable.js' + + options[:attribution] = <<-HTML + © 2014–2015 Facebook, Inc.
+ Licensed under the 3-clause BSD License. + HTML + + stub '' do + capybara = load_capybara_selenium + capybara.app_host = 'https://facebook.github.io' + capybara.visit(URL.parse(self.base_url).path) + capybara.execute_script <<-JS + var content, event, links, link; + + event = document.createEvent('Event'); + event.initEvent('hashchange', false, false); + + content = document.querySelector('.docContents section').cloneNode(true); + links = Array.prototype.slice.call(document.querySelectorAll('.sideBar .scrollContent a')); + + while (link = links.shift()) { + if (!document.body.contains(link)) { + document.body.appendChild(link); + } + + link.click(); + dispatchEvent(event); + content.innerHTML += document.querySelector('.docContents').innerHTML; + + document.querySelectorAll('.sideBar .scrollContent .groupTitle').forEach(function(el) { + if (el.textContent == 'Types') { + Array.prototype.unshift.apply(links, Array.prototype.slice.call(el.parentNode.querySelectorAll('a'))); + } + }); + } + + document.querySelector('.docContents').innerHTML = content.innerHTML; + JS + capybara.html + end + end +end diff --git a/public/icons/docs/immutable/16.png b/public/icons/docs/immutable/16.png new file mode 100644 index 00000000..6bdd99d6 Binary files /dev/null and b/public/icons/docs/immutable/16.png differ diff --git a/public/icons/docs/immutable/16@2x.png b/public/icons/docs/immutable/16@2x.png new file mode 100644 index 00000000..2a29e481 Binary files /dev/null and b/public/icons/docs/immutable/16@2x.png differ diff --git a/public/icons/docs/immutable/SOURCE b/public/icons/docs/immutable/SOURCE new file mode 100644 index 00000000..4ab56fe0 --- /dev/null +++ b/public/icons/docs/immutable/SOURCE @@ -0,0 +1 @@ +https://raw.githubusercontent.com/facebook/immutable-js/master/pages/src/static/favicon.png